mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
win32ole: OLE uninitialize
* ext/win32ole/win32ole.c (ole_initialize): uninitialize OLE at thread ends. [Bug #2618] [ruby-core:27634] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
588504b20f
commit
27ed294c71
2 changed files with 17 additions and 1 deletions
|
@ -1,4 +1,7 @@
|
|||
Fri Jan 18 11:23:34 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Fri Jan 18 11:24:33 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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]
|
||||
|
|
|
@ -224,6 +224,7 @@ static volatile DWORD g_ole_initialized_key = TLS_OUT_OF_INDEXES;
|
|||
# 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 char *fmt, ...)
|
|||
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)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue