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
@ -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
|
* ext/win32ole/win32ole.c (ole_initialize): initialize OLE for each
|
||||||
threads. [Bug #2618] [ruby-core:27634]
|
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_init() (g_ole_initialized_key = TlsAlloc())
|
||||||
# define g_ole_initialized_set(val) TlsSetValue(g_ole_initialized_key, (void*)(val))
|
# define g_ole_initialized_set(val) TlsSetValue(g_ole_initialized_key, (void*)(val))
|
||||||
#endif
|
#endif
|
||||||
|
static BOOL g_uninitialize_hooked = FALSE;
|
||||||
static BOOL g_cp_installed = FALSE;
|
static BOOL g_cp_installed = FALSE;
|
||||||
static BOOL g_lcid_installed = FALSE;
|
static BOOL g_lcid_installed = FALSE;
|
||||||
static HINSTANCE ghhctrl = NULL;
|
static HINSTANCE ghhctrl = NULL;
|
||||||
@ -1210,15 +1211,27 @@ ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...)
|
|||||||
void
|
void
|
||||||
ole_uninitialize(void)
|
ole_uninitialize(void)
|
||||||
{
|
{
|
||||||
|
if (!g_ole_initialized) return;
|
||||||
OleUninitialize();
|
OleUninitialize();
|
||||||
g_ole_initialized_set(FALSE);
|
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
|
static void
|
||||||
ole_initialize(void)
|
ole_initialize(void)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
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) {
|
if(g_ole_initialized == FALSE) {
|
||||||
hr = OleInitialize(NULL);
|
hr = OleInitialize(NULL);
|
||||||
if(FAILED(hr)) {
|
if(FAILED(hr)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user