From b5b2247de50e20e7db3c64e786aab788d9f49148 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 6 Jun 2020 10:09:29 +1000 Subject: Defer most initialisation until Scintilla window is created. Previously, more initialisation was performed inside DllMain but some actions such as loading libraries are unsafe inside DllMain. Avoid listbox UnregisterClass if no attempt to register which will occur if no Scintilla windows were created. std::call_once is used to ensure initialisation is performed at most once. --- win32/PlatWin.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'win32/PlatWin.cxx') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index a7bc5626c..96f642824 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -3243,8 +3243,10 @@ bool ListBoxX_Register() noexcept { return ::RegisterClassEx(&wndclassc) != 0; } -bool ListBoxX_Unregister() noexcept { - return ::UnregisterClass(ListBoxX_ClassName, hinstPlatformRes) != 0; +void ListBoxX_Unregister() noexcept { + if (hinstPlatformRes) { + ::UnregisterClass(ListBoxX_ClassName, hinstPlatformRes); + } } } @@ -3374,7 +3376,7 @@ void Platform::Assert(const char *c, const char *file, int line) { } } -void Platform_Initialise(void *hInstance) { +void Platform_Initialise(void *hInstance) noexcept { hinstPlatformRes = static_cast(hInstance); LoadDpiForWindow(); ListBoxX_Register(); -- cgit v1.2.3