diff options
-rw-r--r-- | win32/PlatWin.cxx | 24 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 9 |
2 files changed, 29 insertions, 4 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 53b889896..315af73db 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -103,6 +103,9 @@ ID2D1Factory *pD2DFactory = 0; IDWriteRenderingParams *defaultRenderingParams = 0; IDWriteRenderingParams *customClearTypeRenderingParams = 0; +static HMODULE hDLLD2D = NULL; +static HMODULE hDLLDWrite = NULL; + bool LoadD2D() { static bool triedLoadingD2D = false; if (!triedLoadingD2D) { @@ -111,7 +114,7 @@ bool LoadD2D() { typedef HRESULT (WINAPI *DWriteCFSig)(DWRITE_FACTORY_TYPE factoryType, REFIID iid, IUnknown **factory); - HMODULE hDLLD2D = ::LoadLibraryEx(TEXT("D2D1.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/); + hDLLD2D = ::LoadLibraryEx(TEXT("D2D1.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/); if (hDLLD2D) { D2D1CFSig fnD2DCF = (D2D1CFSig)::GetProcAddress(hDLLD2D, "D2D1CreateFactory"); if (fnD2DCF) { @@ -122,7 +125,7 @@ bool LoadD2D() { reinterpret_cast<IUnknown**>(&pD2DFactory)); } } - HMODULE hDLLDWrite = ::LoadLibraryEx(TEXT("DWRITE.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/); + hDLLDWrite = ::LoadLibraryEx(TEXT("DWRITE.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/); if (hDLLDWrite) { DWriteCFSig fnDWCF = (DWriteCFSig)::GetProcAddress(hDLLDWrite, "DWriteCreateFactory"); if (fnDWCF) { @@ -3266,12 +3269,27 @@ void Platform_Finalise() { pD2DFactory->Release(); pD2DFactory = 0; } - + if (hDLLDWrite) { + FreeLibrary(hDLLDWrite); + hDLLDWrite = NULL; + } + if (hDLLD2D) { + FreeLibrary(hDLLD2D); + hDLLD2D = NULL; + } #endif if (reverseArrowCursor != NULL) ::DestroyCursor(reverseArrowCursor); ListBoxX_Unregister(); ::DeleteCriticalSection(&crPlatformLock); + if (hDLLUser32) { + FreeLibrary(hDLLUser32); + hDLLUser32 = NULL; + } + if (hDLLImage) { + FreeLibrary(hDLLImage); + hDLLImage = NULL; + } } #ifdef SCI_NAMESPACE diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 0e2308c70..a0372f574 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -125,6 +125,8 @@ class ScintillaWin; // Forward declaration for COM interface subobjects typedef void VFunction(void); +static HMODULE commctrl32 = 0; + /** */ class FormatEnumerator { @@ -383,7 +385,8 @@ void ScintillaWin::Initialise() { TrackMouseEventFn = (TrackMouseEventSig)::GetProcAddress(user32, "TrackMouseEvent"); if (TrackMouseEventFn == NULL) { // Windows 95 has an emulation in comctl32.dll:_TrackMouseEvent - HMODULE commctrl32 = ::LoadLibrary(TEXT("comctl32.dll")); + if (!commctrl32) + commctrl32 = ::LoadLibrary(TEXT("comctl32.dll")); if (commctrl32 != NULL) { TrackMouseEventFn = (TrackMouseEventSig) ::GetProcAddress(commctrl32, "_TrackMouseEvent"); @@ -2872,6 +2875,10 @@ int Scintilla_RegisterClasses(void *hInstance) { // This function is externally visible so it can be called from container when building statically. int Scintilla_ReleaseResources() { bool result = ScintillaWin::Unregister(); + if (commctrl32) { + FreeLibrary(commctrl32); + commctrl32 = NULL; + } Platform_Finalise(); return result; } |