commit eb7ad0ace9be1c7cceb0b7f09e56ff2a68575d6d
parent e02c54b17db2fbd3e951115676be2bd4d2bf89cf
Author: cfillion <cfillion@users.noreply.github.com>
Date: Mon, 6 Feb 2017 22:36:10 -0500
dialog: don't emit a WM_DESTROY event to call onClose
This caused issues with the linux version of SWELL where WM_DESTROY
changes internal data preventing any GUI refresh or even DestroyWindow
to do its job of closing the window.
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/dialog.cpp b/src/dialog.cpp
@@ -146,6 +146,10 @@ Dialog::~Dialog()
for(Control *control : m_controls | boost::adaptors::map_values)
delete control;
+ // Unregistering the instance right now before DestroyWindow prevents WM_DESTROY
+ // from calling the default implementation of onClose (because we're in the
+ // destructor – no polymorphism here). Instead, the right onClose is called
+ // directly by close() for modeless dialogs, or by the OS/SWELL for modal dialogs.
s_instances.erase(m_handle);
DestroyWindow(m_handle);
@@ -194,7 +198,7 @@ void Dialog::close(const INT_PTR result)
EndDialog(m_handle, result);
break;
case Modeless:
- SendMessage(m_handle, WM_DESTROY, 0, (LPARAM)this);
+ onClose();
m_closeHandler(result);
break;
}