X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cca410b336cd5628a944ede9e9944fdbb04552d4..8dd7fd4e5d0c7585a8fc8278b95362771b5fbdaf:/src/gtk/dialog.cpp diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index dc66c23778..c70813d557 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -20,12 +20,8 @@ #include -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -// Don't allow window closing if there are open dialogs -int g_openDialogs; +// this is defined in src/gtk/toplevel.cpp +extern int wxOpenModalDialogsCount; //----------------------------------------------------------------------------- // wxDialog @@ -70,13 +66,26 @@ bool wxDialog::Show( bool show ) EndModal( wxID_CANCEL ); } - bool ret = wxWindow::Show( show ); + if (show && CanDoLayoutAdaptation()) + DoLayoutAdaptation(); + + 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; @@ -120,7 +129,7 @@ int wxDialog::ShowModal() m_modalShowing = true; - g_openDialogs++; + wxOpenModalDialogsCount++; // NOTE: gtk_window_set_modal internally calls gtk_grab_add() ! gtk_window_set_modal(GTK_WINDOW(m_widget), TRUE); @@ -129,7 +138,7 @@ int wxDialog::ShowModal() gtk_window_set_modal(GTK_WINDOW(m_widget), FALSE); - g_openDialogs--; + wxOpenModalDialogsCount--; return GetReturnCode(); } @@ -140,7 +149,7 @@ void wxDialog::EndModal( int retCode ) if (!IsModal()) { - wxFAIL_MSG( wxT("wxDialog:EndModal called twice") ); + wxFAIL_MSG( "either wxDialog:EndModal called twice or ShowModal wasn't called" ); return; }