From 6bf6dc4af23d63b608560e09cb5b382e496e1a19 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 25 Apr 2014 10:23:16 +1000 Subject: Free system libraries at finalization. --- win32/ScintillaWin.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'win32/ScintillaWin.cxx') 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; } -- cgit v1.2.3