1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-21 20:10:05 +00:00

Fixed crash on exit for Win32

This commit is contained in:
Chuck Walbourn 2016-09-02 01:29:53 -07:00
parent 0bbee8c588
commit fd11ad4533
4 changed files with 12 additions and 28 deletions

View File

@ -701,13 +701,9 @@ namespace
IWICImagingFactory* _GetWIC()
{
static ComPtr<IWICImagingFactory> s_Factory;
if ( s_Factory )
return s_Factory.Get();
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
IWICImagingFactory* factory = nullptr;
InitOnceExecuteOnce(&s_initOnce,
[](PINIT_ONCE, PVOID, PVOID *factory) -> BOOL
{
@ -745,9 +741,9 @@ namespace
__uuidof(IWICImagingFactory),
factory) ) ? TRUE : FALSE;
#endif
}, nullptr, reinterpret_cast<LPVOID*>(s_Factory.GetAddressOf()));
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
return s_Factory.Get();
return factory;
}
} // anonymous namespace

View File

@ -781,13 +781,9 @@ namespace
IWICImagingFactory2* _GetWIC()
{
static ComPtr<IWICImagingFactory2> s_Factory;
if ( s_Factory )
return s_Factory.Get();
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
IWICImagingFactory2* factory = nullptr;
(void)InitOnceExecuteOnce(&s_initOnce,
[](PINIT_ONCE, PVOID, PVOID *factory) -> BOOL
{
@ -797,9 +793,9 @@ namespace
CLSCTX_INPROC_SERVER,
__uuidof(IWICImagingFactory2),
factory) ) ? TRUE : FALSE;
}, nullptr, reinterpret_cast<LPVOID*>(s_Factory.GetAddressOf()));
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
return s_Factory.Get();
return factory;
}
} // anonymous namespace

View File

@ -168,13 +168,9 @@ namespace
//--------------------------------------------------------------------------------------
IWICImagingFactory* _GetWIC()
{
static ComPtr<IWICImagingFactory> s_Factory;
if ( s_Factory )
return s_Factory.Get();
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
IWICImagingFactory* factory = nullptr;
InitOnceExecuteOnce(&s_initOnce,
[](PINIT_ONCE, PVOID, PVOID *factory) -> BOOL
{
@ -212,9 +208,9 @@ namespace
__uuidof(IWICImagingFactory),
factory) ) ? TRUE : FALSE;
#endif
}, nullptr, reinterpret_cast<LPVOID*>(s_Factory.GetAddressOf()));
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
return s_Factory.Get();
return factory;
}
//---------------------------------------------------------------------------------

View File

@ -149,13 +149,9 @@ namespace
IWICImagingFactory2* _GetWIC()
{
static ComPtr<IWICImagingFactory2> s_Factory;
if ( s_Factory )
return s_Factory.Get();
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
IWICImagingFactory2* factory = nullptr;
(void)InitOnceExecuteOnce(&s_initOnce,
[](PINIT_ONCE, PVOID, PVOID *factory) -> BOOL
{
@ -165,9 +161,9 @@ namespace
CLSCTX_INPROC_SERVER,
__uuidof(IWICImagingFactory2),
factory) ) ? TRUE : FALSE;
}, nullptr, reinterpret_cast<LPVOID*>(s_Factory.GetAddressOf()));
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
return s_Factory.Get();
return factory;
}
//---------------------------------------------------------------------------------