From 5b0a5672409629c00efecd22eeec13d0761eee28 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 26 Jun 2021 11:25:27 +0400 Subject: [PATCH 1/2] Use unique_ptr instead of gsl::finally in Wayland helper --- linux_wayland_helper/linux_wayland_helper.cpp | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/linux_wayland_helper/linux_wayland_helper.cpp b/linux_wayland_helper/linux_wayland_helper.cpp index c3de899..cbcbeaf 100644 --- a/linux_wayland_helper/linux_wayland_helper.cpp +++ b/linux_wayland_helper/linux_wayland_helper.cpp @@ -11,8 +11,6 @@ #include #include -#include - #define LOAD_SYMBOL(handle, func) LoadSymbol(handle, #func, func) namespace Wayland { @@ -173,10 +171,16 @@ void wl_argument_from_va_list( } } -using Handle = void*; +struct HandleDeleter { + void operator()(void *handle) { + dlclose(handle); + } +}; + +using Handle = std::unique_ptr; bool LoadLibrary(Handle &handle, const char *name) { - handle = dlopen(name, RTLD_LAZY | RTLD_NODELETE); + handle = Handle(dlopen(name, RTLD_LAZY | RTLD_NODELETE)); if (handle) { return true; } @@ -185,9 +189,9 @@ bool LoadLibrary(Handle &handle, const char *name) { } template -inline bool LoadSymbol(Handle handle, const char *name, Function &func) { +inline bool LoadSymbol(const Handle &handle, const char *name, Function &func) { func = handle - ? reinterpret_cast(dlsym(handle, name)) + ? reinterpret_cast(dlsym(handle.get(), name)) : nullptr; if (const auto error = dlerror()) { g_warning("Failed to load function '%s': %s", name, error); @@ -200,17 +204,6 @@ bool Resolve() { auto egl = Handle(); auto cursor = Handle(); auto client = Handle(); - const auto guard = gsl::finally([&] { - if (egl) { - dlclose(egl); - } - if (cursor) { - dlclose(cursor); - } - if (client) { - dlclose(client); - } - }); return LoadLibrary(egl, "libwayland-egl.so.1") && LOAD_SYMBOL(egl, wl_egl_window_create) && LOAD_SYMBOL(egl, wl_egl_window_destroy) From 1d59503a24227ba1a8477d25c6fa33df0e38abd6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 26 Jun 2021 13:26:05 +0300 Subject: [PATCH 2/2] Fix NuGet WinRT header generation. --- nuget.cmake | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nuget.cmake b/nuget.cmake index bae1b55..6fc9fd6 100644 --- a/nuget.cmake +++ b/nuget.cmake @@ -90,6 +90,7 @@ function(nuget_add_winrt target_name) /? OUTPUT_FILE ${winrt_version_test} + COMMAND_ERROR_IS_FATAL ANY ) execute_process( COMMAND @@ -97,6 +98,7 @@ function(nuget_add_winrt target_name) ${winrt_sdk_version} OUTPUT_FILE ${sdk_version_test} + COMMAND_ERROR_IS_FATAL ANY ) execute_process( COMMAND @@ -118,11 +120,10 @@ function(nuget_add_winrt target_name) ${winrt_loc}/bin/cppwinrt -input ${winrt_sdk_version} -output ${gen_dst} - COMMAND - cp ${winrt_version_test} ${winrt_version_key} - COMMAND - cp ${sdk_version_test} ${sdk_version_key} + COMMAND_ERROR_IS_FATAL ANY ) + file(RENAME ${winrt_version_test} ${winrt_version_key}) + file(RENAME ${sdk_version_test} ${sdk_version_key}) endif() target_include_directories(${target_name}