fix crash where a shared lib is loaded/unloaded repeatedly
When a shared lib which uses nana is dynamic loaded/unloaded multiple times, the crash would occur when creating a form after reloading the shared lib
This commit is contained in:
parent
15a015aa4e
commit
e37cc5ec37
@ -173,15 +173,22 @@ namespace detail
|
||||
|
||||
static LRESULT WINAPI Bedrock_WIN32_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
HINSTANCE windows_module_handle()
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
static int dummy;
|
||||
VirtualQuery(&dummy, &mbi, sizeof(mbi));
|
||||
return reinterpret_cast<HINSTANCE>(mbi.AllocationBase);
|
||||
}
|
||||
|
||||
bedrock::bedrock()
|
||||
: pi_data_(new pi_data),
|
||||
impl_(new private_impl)
|
||||
{
|
||||
nana::detail::platform_spec::instance(); //to guaranty the platform_spec object is initialized before using.
|
||||
|
||||
|
||||
WNDCLASSEX wincl;
|
||||
wincl.hInstance = ::GetModuleHandle(0);
|
||||
wincl.hInstance = windows_module_handle();
|
||||
wincl.lpszClassName = L"NanaWindowInternal";
|
||||
wincl.lpfnWndProc = &Bedrock_WIN32_WindowProc;
|
||||
wincl.style = CS_DBLCLKS | CS_OWNDC;
|
||||
@ -229,6 +236,8 @@ namespace detail
|
||||
|
||||
delete impl_;
|
||||
delete pi_data_;
|
||||
|
||||
::UnregisterClass(L"NanaWindowInternal", windows_module_handle());
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,6 +34,10 @@ namespace nana{
|
||||
namespace detail{
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
|
||||
//This function is defined in bedrock_windows.cpp
|
||||
HINSTANCE windows_module_handle();
|
||||
|
||||
class tray_manager
|
||||
{
|
||||
struct window_extra_t
|
||||
@ -315,7 +319,7 @@ namespace nana{
|
||||
HWND native_wd = ::CreateWindowEx(style_ex, L"NanaWindowInternal", L"Nana Window",
|
||||
style,
|
||||
pt.x, pt.y, 100, 100,
|
||||
reinterpret_cast<HWND>(owner), 0, ::GetModuleHandle(0), 0);
|
||||
reinterpret_cast<HWND>(owner), 0, windows_module_handle(), 0);
|
||||
|
||||
//A window may have a border, this should be adjusted the client area fit for the specified size.
|
||||
::RECT client;
|
||||
@ -504,7 +508,7 @@ namespace nana{
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS,
|
||||
r.x, r.y, r.width, r.height,
|
||||
reinterpret_cast<HWND>(parent), // The window is a child-window to desktop
|
||||
0, ::GetModuleHandle(0), 0);
|
||||
0, windows_module_handle(), 0);
|
||||
#elif defined(NANA_X11)
|
||||
nana::detail::platform_scope_guard psg;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user