]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dlgcmn.cpp
compilation fix for wxUSE_INTL=0
[wxWidgets.git] / src / common / dlgcmn.cpp
index ec5a528ad43d8e6cf87d8598771ae927f6e2fd14..8430081563dd78102287bc3ce7bb9f90f03f240f 100644 (file)
@@ -27,6 +27,7 @@
 #include "wx/dialog.h"
 
 #ifndef WX_PRECOMP
+    #include "wx/app.h"
     #include "wx/button.h"
     #include "wx/dcclient.h"
     #include "wx/intl.h"
@@ -71,6 +72,17 @@ void wxDialogBase::Init()
     WX_INIT_CONTROL_CONTAINER();
 }
 
+// helper of GetParentForModalDialog()
+static bool CanBeUsedAsParent(wxWindow *parent)
+{
+    extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete;
+
+    return !parent->HasExtraStyle(wxWS_EX_TRANSIENT) &&
+                parent->IsShownOnScreen() &&
+                    !wxPendingDelete.Member(parent) &&
+                        parent->IsBeingDeleted();
+}
+
 wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const
 {
     // creating a parent-less modal dialog will result (under e.g. wxGTK2)
@@ -78,10 +90,10 @@ wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const
     if ( parent )
         parent = wxGetTopLevelParent(parent);
 
-    if ( !parent || parent->HasExtraStyle(wxWS_EX_TRANSIENT) )
+    if ( !parent || !CanBeUsedAsParent(parent) )
         parent = wxTheApp->GetTopWindow();
 
-    if ( parent && parent->HasExtraStyle(wxWS_EX_TRANSIENT) )
+    if ( parent && !CanBeUsedAsParent(parent) )
     {
         // can't use this one, it's going to disappear
         parent = NULL;