]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/filepicker.cpp
missing commit
[wxWidgets.git] / src / gtk / filepicker.cpp
index 104d7d5d92ab7fd35df7ea8d906c4d352c4a65b7..bebcf84931e415d05d90a0f17bbbc7e4173c1bec 100644 (file)
@@ -103,7 +103,18 @@ bool wxFileButton::Create( wxWindow *parent, wxWindowID id,
 
 wxFileButton::~wxFileButton()
 {
-    delete m_dialog;
+    if ( m_dialog )
+    {
+        // We need to delete the C++ dialog object here but we shouldn't delete
+        // its widget which is used by our GtkFileChooserButton and will be
+        // deleted by it when it is itself destroyed in our base class dtor. So
+        // take the widget ownership away from the dialog to avoid GTK+ errors
+        // that would happen if GtkFileChooserButton tried to access the
+        // already destroyed dialog widget.
+        g_object_unref(m_dialog->m_widget);
+        m_dialog->m_widget = NULL;
+        delete m_dialog;
+    }
 }
 
 void wxFileButton::OnDialogOK(wxCommandEvent& ev)