From 9022ac596b8c3710834a6c36a39e1c37cb88a32f Mon Sep 17 00:00:00 2001 From: LAGonauta Date: Wed, 20 May 2020 21:28:58 -0300 Subject: [PATCH] Every call to CoInitialize() must be balanced with a call to CoUninitialize() --- libdino/src/application.vala | 3 --- libdino/src/service/util.vala | 11 +++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libdino/src/application.vala b/libdino/src/application.vala index 4cb54a42..f381c21d 100644 --- a/libdino/src/application.vala +++ b/libdino/src/application.vala @@ -61,9 +61,6 @@ public interface Application : GLib.Application { }); shutdown.connect(() => { stream_interactor.connection_manager.make_offline_all(); -#if _WIN32 - Dino.Util.CoUninitialize(); -#endif }); open.connect((files, hint) => { if (files.length != 1) { diff --git a/libdino/src/service/util.vala b/libdino/src/service/util.vala index dbc98b2a..66cee1c4 100644 --- a/libdino/src/service/util.vala +++ b/libdino/src/service/util.vala @@ -8,14 +8,17 @@ public class Util { private static extern int ShellExecuteA(int* hwnd, string operation, string file, string parameters, string directory, int showCmd); [CCode (cname = "CoInitialize")] - public static extern int CoInitialize(void* reserved); + private static extern int CoInitialize(void* reserved); [CCode (cname = "CoUninitialize")] - public static extern void CoUninitialize(); + private static extern void CoUninitialize(); private static int ShellExecute(string operation, string file) { CoInitialize(null); - return ShellExecuteA(null, operation, file, null, null, 1); + var result = ShellExecuteA(null, operation, file, null, null, 1); + CoUninitialize(); + + return result; } #endif @@ -46,7 +49,7 @@ public class Util { public static void launch_default_for_uri(string file_uri) { #if _WIN32 - Dino.Util.ShellExecute("open", file_uri); + ShellExecute("open", file_uri); #else AppInfo.launch_default_for_uri(file_uri, null); #endif