]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/dialog.cpp
corrected off by 1 error in cMB2WC() call (thanks valgrind)
[wxWidgets.git] / src / gtk / dialog.cpp
index 2ff8564b786a6a256c27a8f00a1171603e928fd7..63c13c0c98e22210d5ad4fb0ea1430c9a4dd1fdf 100644 (file)
@@ -30,7 +30,8 @@
 // global data
 //-----------------------------------------------------------------------------
 
-extern int g_openDialogs;
+// Don't allow window closing if there are open dialogs
+int g_openDialogs;
 
 //-----------------------------------------------------------------------------
 // wxDialog
@@ -115,14 +116,11 @@ int wxDialog::ShowModal()
     // forbidden
     if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) )
     {
-        wxWindow *parent = wxTheApp->GetTopWindow();
-        if ( parent &&
-                parent != this &&
-                    parent->IsBeingDeleted() &&
-                        !(parent->GetExtraStyle() & wxWS_EX_TRANSIENT) )
+        wxWindow * const parent = GetParentForModalDialog();
+        if ( parent && parent != this )
         {
-            m_parent = parent;
-            gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(parent->m_widget) );
+            gtk_window_set_transient_for( GTK_WINDOW(m_widget),
+                                          GTK_WINDOW(parent->m_widget) );
         }
     }
 
@@ -137,7 +135,7 @@ int wxDialog::ShowModal()
     // NOTE: gtk_window_set_modal internally calls gtk_grab_add() !
     gtk_window_set_modal(GTK_WINDOW(m_widget), TRUE);
 
-    wxEventLoop().Run();
+    wxGUIEventLoop().Run();
 
     gtk_window_set_modal(GTK_WINDOW(m_widget), FALSE);