diff options
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/PlatWin.cxx | 50 | ||||
| -rw-r--r-- | win32/PlatWin.h | 2 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 16 | 
3 files changed, 38 insertions, 30 deletions
| diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 082a177e6..507075a77 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -3280,31 +3280,33 @@ void Platform_Initialise(void *hInstance) {  #pragma warning(default: 4996)  #endif -void Platform_Finalise() { +void Platform_Finalise(bool fromDllMain) {  #if defined(USE_D2D) -	if (defaultRenderingParams) { -		defaultRenderingParams->Release(); -		defaultRenderingParams = 0; -	} -	if (customClearTypeRenderingParams) { -		customClearTypeRenderingParams->Release(); -		customClearTypeRenderingParams = 0; -	} -	if (pIDWriteFactory) { -		pIDWriteFactory->Release(); -		pIDWriteFactory = 0; -	} -	if (pD2DFactory) { -		pD2DFactory->Release(); -		pD2DFactory = 0; -	} -	if (hDLLDWrite) { -		FreeLibrary(hDLLDWrite); -		hDLLDWrite = NULL; -	} -	if (hDLLD2D) { -		FreeLibrary(hDLLD2D); -		hDLLD2D = NULL; +	if (!fromDllMain) { +		if (defaultRenderingParams) { +			defaultRenderingParams->Release(); +			defaultRenderingParams = 0; +		} +		if (customClearTypeRenderingParams) { +			customClearTypeRenderingParams->Release(); +			customClearTypeRenderingParams = 0; +		} +		if (pIDWriteFactory) { +			pIDWriteFactory->Release(); +			pIDWriteFactory = 0; +		} +		if (pD2DFactory) { +			pD2DFactory->Release(); +			pD2DFactory = 0; +		} +		if (hDLLDWrite) { +			FreeLibrary(hDLLDWrite); +			hDLLDWrite = NULL; +		} +		if (hDLLD2D) { +			FreeLibrary(hDLLD2D); +			hDLLD2D = NULL; +		}  	}  #endif  	if (reverseArrowCursor != NULL) diff --git a/win32/PlatWin.h b/win32/PlatWin.h index 93e1d7253..c284d42d3 100644 --- a/win32/PlatWin.h +++ b/win32/PlatWin.h @@ -14,7 +14,7 @@ namespace Scintilla {  extern bool IsNT();  extern void Platform_Initialise(void *hInstance); -extern void Platform_Finalise(); +extern void Platform_Finalise(bool fromDllMain);  #if defined(USE_D2D)  extern bool LoadD2D(); diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 762960685..d4f0415e8 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -2907,25 +2907,31 @@ int Scintilla_RegisterClasses(void *hInstance) {  	return result;  } -// This function is externally visible so it can be called from container when building statically. -int Scintilla_ReleaseResources() { +static int ResourcesRelease(bool fromDllMain) {  	bool result = ScintillaWin::Unregister();  	if (commctrl32) {  		FreeLibrary(commctrl32);  		commctrl32 = NULL;  	} -	Platform_Finalise(); +	Platform_Finalise(fromDllMain);  	return result;  } +// This function is externally visible so it can be called from container when building statically. +int Scintilla_ReleaseResources() { +	return ResourcesRelease(false); +} +  #ifndef STATIC_BUILD -extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID) { +extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved) {  	//Platform::DebugPrintf("Scintilla::DllMain %d %d\n", hInstance, dwReason);  	if (dwReason == DLL_PROCESS_ATTACH) {  		if (!Scintilla_RegisterClasses(hInstance))  			return FALSE;  	} else if (dwReason == DLL_PROCESS_DETACH) { -		Scintilla_ReleaseResources(); +		if (lpvReserved == NULL) { +			ResourcesRelease(true); +		}  	}  	return TRUE;  } | 
