if (show && CanDoLayoutAdaptation())
         DoLayoutAdaptation();
 
-    bool ret = wxWindow::Show( show );
+    bool ret = wxDialogBase::Show(show);
 
-    if (show) InitDialog();
+    if (show)
+        InitDialog();
 
     return ret;
 }
 
+wxDialog::~wxDialog()
+{
+    m_isBeingDeleted = true;
+
+    // if the dialog is modal, this will end its event loop
+    if ( IsModal() )
+        EndModal(wxID_CANCEL);
+}
+
 bool wxDialog::IsModal() const
 {
     return m_modalShowing;
 
     if (!IsModal())
     {
-        wxFAIL_MSG( wxT("wxDialog:EndModal called twice") );
+        wxFAIL_MSG( "either wxDialog:EndModal called twice or ShowModal wasn't called" );
         return;
     }