Dirty hack to prevent double destruction of file dialog.
authorRobert Roebling <robert@roebling.de>
Sun, 28 Nov 2004 22:54:13 +0000 (22:54 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 28 Nov 2004 22:54:13 +0000 (22:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30812 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/filedlg.h
include/wx/gtk1/filedlg.h
src/gtk/filedlg.cpp
src/gtk1/filedlg.cpp

index 70e26820cf6356f2c9ff7714a4f79751b2ba55f3..4aa8521e9ba7ac34e38b487a42651a28e57add1e 100644 (file)
@@ -43,9 +43,11 @@ public:
     virtual void SetFilename(const wxString& name);
     virtual void SetWildcard(const wxString& wildCard);
     virtual void SetFilterIndex(int filterIndex);
-
+            
+//private:
+    bool m_destroyed_by_delete;
+    
     void UpdateFromDialog();
-private:
     void UpdateDialog();
     
     DECLARE_DYNAMIC_CLASS(wxFileDialog)
index 70e26820cf6356f2c9ff7714a4f79751b2ba55f3..4aa8521e9ba7ac34e38b487a42651a28e57add1e 100644 (file)
@@ -43,9 +43,11 @@ public:
     virtual void SetFilename(const wxString& name);
     virtual void SetWildcard(const wxString& wildCard);
     virtual void SetFilterIndex(int filterIndex);
-
+            
+//private:
+    bool m_destroyed_by_delete;
+    
     void UpdateFromDialog();
-private:
     void UpdateDialog();
     
     DECLARE_DYNAMIC_CLASS(wxFileDialog)
index 20bc8b05589b8c6752b62376a152ebcdf966f362..adb8f61207321d7791d2a68b1db9999a25af7c53 100644 (file)
@@ -110,8 +110,13 @@ static void gtk_filedialog_response_callback(GtkWidget *w,
     
     if (response == GTK_RESPONSE_ACCEPT)
         gtk_filedialog_ok_callback(w, dialog);
-    else
+    else if (response == GTK_RESPONSE_CANCEL)
+        gtk_filedialog_cancel_callback(w, dialog);
+    else // "delete"
+    {
         gtk_filedialog_cancel_callback(w, dialog);
+        dialog->m_destroyed_by_delete = TRUE;
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -129,6 +134,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
                        wildCard, style, pos)
 {
     m_needParent = FALSE;
+    m_destroyed_by_delete = FALSE;
 
     if (!PreCreation(parent, pos, wxDefaultSize) ||
         !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
@@ -182,6 +188,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
 
 wxFileDialog::~wxFileDialog()
 {
+    if (m_destroyed_by_delete)
+        m_widget = NULL;
 }
 
 void wxFileDialog::GetFilenames(wxArrayString& files) const 
index 20bc8b05589b8c6752b62376a152ebcdf966f362..adb8f61207321d7791d2a68b1db9999a25af7c53 100644 (file)
@@ -110,8 +110,13 @@ static void gtk_filedialog_response_callback(GtkWidget *w,
     
     if (response == GTK_RESPONSE_ACCEPT)
         gtk_filedialog_ok_callback(w, dialog);
-    else
+    else if (response == GTK_RESPONSE_CANCEL)
+        gtk_filedialog_cancel_callback(w, dialog);
+    else // "delete"
+    {
         gtk_filedialog_cancel_callback(w, dialog);
+        dialog->m_destroyed_by_delete = TRUE;
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -129,6 +134,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
                        wildCard, style, pos)
 {
     m_needParent = FALSE;
+    m_destroyed_by_delete = FALSE;
 
     if (!PreCreation(parent, pos, wxDefaultSize) ||
         !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
@@ -182,6 +188,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
 
 wxFileDialog::~wxFileDialog()
 {
+    if (m_destroyed_by_delete)
+        m_widget = NULL;
 }
 
 void wxFileDialog::GetFilenames(wxArrayString& files) const