wxDialog::~wxDialog()
{
- m_isBeingDeleted = true;
+ SendDestroyEvent();
+
+ // if the dialog is modal, this will end its event loop
+ Show(false);
delete m_eventLoop;
if( !wxWindowBase::Show( show ) )
return false;
+ if ( !show && IsModal() )
+ EndModal(wxID_CANCEL);
+
m_isShown = show;
if (show)