X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1a6944fd74cfb70ace96d60bde31a7c8e0a5896d..d93f63db9d836a7d303343e60fb034dc9a1360d0:/src/gtk1/dialog.cpp diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index b38fedf806..6411ba1930 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -17,6 +17,10 @@ #include "wx/app.h" #include "wx/gtk/win_gtk.h" +//----------------------------------------------------------------------------- + +extern wxList wxPendingDelete; + //----------------------------------------------------------------------------- // delete @@ -50,7 +54,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxWindow) wxDialog::wxDialog(void) { m_title = ""; - m_modalShowing = TRUE; + m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); }; @@ -59,6 +63,7 @@ wxDialog::wxDialog( wxWindow *parent, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); Create( parent, id, title, pos, size, style, name ); }; @@ -72,8 +77,6 @@ bool wxDialog::Create( wxWindow *parent, PreCreation( parent, id, pos, size, style, name ); - m_modalShowing = ((m_windowStyle & wxDIALOG_MODAL) == wxDIALOG_MODAL); - m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); @@ -167,6 +170,14 @@ bool wxDialog::OnClose(void) return FALSE; } +bool wxDialog::Destroy(void) +{ + if (!wxPendingDelete.Member(this)) + wxPendingDelete.Append(this); + + return TRUE; +} + void wxDialog::OnCloseWindow(wxCloseEvent& event) { if (GetEventHandler()->OnClose() || event.GetForce()) @@ -177,7 +188,7 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event) bool wxDialog::Show( bool show ) { - if (!show && m_modalShowing) + if (!show && IsModal() && m_modalShowing) { EndModal( wxID_CANCEL ); }; @@ -186,26 +197,32 @@ bool wxDialog::Show( bool show ) if (show) InitDialog(); - if (show && m_modalShowing) - { - gtk_grab_add( m_widget ); - gtk_main(); - gtk_grab_remove( m_widget ); - }; - return TRUE; }; int wxDialog::ShowModal(void) { + if (m_modalShowing) return GetReturnCode(); + Show( TRUE ); + + m_modalShowing = TRUE; + + gtk_grab_add( m_widget ); + gtk_main(); + gtk_grab_remove( m_widget ); + return GetReturnCode(); }; void wxDialog::EndModal( int retCode ) { - gtk_main_quit(); SetReturnCode( retCode ); + + if (!m_modalShowing) return; + m_modalShowing = FALSE; + + gtk_main_quit(); }; void wxDialog::InitDialog(void)