[gtk+/gtk-3-18] Win32: move CoInitialize to dnd init



commit c9f370a13fb0551890eed9549835be87b83e4c17
Author: Paolo Borelli <pborelli gnome org>
Date:   Mon Dec 14 19:40:25 2015 +0100

    Win32: move CoInitialize to dnd init
    
    Functions requiring CoInitialize are called just in two places:
     - the filechooser thread which calls its own CoInitializeEx
     - the dnd code
    
    Moving CoInitialize in the dnd specific init is cleaner and
    we can pair it with the corresponding CoUninitialize since
    CoUninitialize should be called as many times as CoInitialize.
    Note that it is ok to call this function multiple times, so it
    will not break if another codepath will need it in the future.
    
    The patch also replaces the deprecated CoInitialize with the
    equivalent call to CoInitializeEx (already used in the filechooser).

 gdk/win32/gdkdnd-win32.c  |    4 ++++
 gdk/win32/gdkmain-win32.c |    2 --
 2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index e78c336..de41cca 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -1569,6 +1569,8 @@ add_format (GArray *fmts,
 void
 _gdk_dnd_init (void)
 {
+  CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
+
   if (getenv ("GDK_WIN32_USE_EXPERIMENTAL_OLE2_DND"))
     use_ole2_dnd = TRUE;
 
@@ -1615,6 +1617,8 @@ _gdk_win32_dnd_exit (void)
     {
       OleUninitialize ();
     }
+
+  CoUninitialize ();
 }
 
 /* Source side */
diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c
index 64d5654..c66b540 100644
--- a/gdk/win32/gdkmain-win32.c
+++ b/gdk/win32/gdkmain-win32.c
@@ -97,8 +97,6 @@ _gdk_win32_windowing_init (void)
   GDK_NOTE (EVENTS, g_print ("input_locale:%p, codepage:%d\n",
                             _gdk_input_locale, _gdk_input_codepage));
 
-  CoInitialize (NULL);
-
   _gdk_selection = gdk_atom_intern_static_string ("GDK_SELECTION");
   _wm_transient_for = gdk_atom_intern_static_string ("WM_TRANSIENT_FOR");
   _targets = gdk_atom_intern_static_string ("TARGETS");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]