[前][次][番号順一覧][スレッド一覧]

ruby-changes:26816

From: nobu <ko1@a...>
Date: Fri, 18 Jan 2013 11:28:28 +0900 (JST)
Subject: [ruby-changes:26816] nobu:r38868 (trunk): win32ole: OLE uninitialize

nobu	2013-01-18 11:24:35 +0900 (Fri, 18 Jan 2013)

  New Revision: 38868

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38868

  Log:
    win32ole: OLE uninitialize
    
    * ext/win32ole/win32ole.c (ole_initialize): uninitialize OLE at thread
      ends.  [Bug #2618] [ruby-core:27634]

  Modified files:
    trunk/ChangeLog
    trunk/ext/win32ole/win32ole.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38867)
+++ ChangeLog	(revision 38868)
@@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Fri Jan 18 11:23:34 2013  Nobuyoshi Nakada  <nobu@r...>
+Fri Jan 18 11:24:33 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/win32ole/win32ole.c (ole_initialize): uninitialize OLE at thread
+	  ends.  [Bug #2618] [ruby-core:27634]
 
 	* ext/win32ole/win32ole.c (ole_initialize): initialize OLE for each
 	  threads.  [Bug #2618] [ruby-core:27634]
Index: ext/win32ole/win32ole.c
===================================================================
--- ext/win32ole/win32ole.c	(revision 38867)
+++ ext/win32ole/win32ole.c	(revision 38868)
@@ -224,6 +224,7 @@ static volatile DWORD g_ole_initialized_ https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L224
 # define g_ole_initialized_init() (g_ole_initialized_key = TlsAlloc())
 # define g_ole_initialized_set(val) TlsSetValue(g_ole_initialized_key, (void*)(val))
 #endif
+static BOOL g_uninitialize_hooked = FALSE;
 static BOOL g_cp_installed = FALSE;
 static BOOL g_lcid_installed = FALSE;
 static HINSTANCE ghhctrl = NULL;
@@ -1210,15 +1211,27 @@ ole_raise(HRESULT hr, VALUE ecs, const c https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L1211
 void
 ole_uninitialize(void)
 {
+    if (!g_ole_initialized) return;
     OleUninitialize();
     g_ole_initialized_set(FALSE);
 }
 
 static void
+ole_uninitialize_hook(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
+{
+    ole_uninitialize();
+}
+
+static void
 ole_initialize(void)
 {
     HRESULT hr;
 
+    if(!g_uninitialize_hooked) {
+	rb_add_event_hook(ole_uninitialize_hook, RUBY_EVENT_THREAD_END, Qnil);
+	g_uninitialize_hooked = TRUE;
+    }
+
     if(g_ole_initialized == FALSE) {
         hr = OleInitialize(NULL);
         if(FAILED(hr)) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]