From 3ca5e2db2da8c7356df54f8232aeb62bc949affa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 22 May 2013 13:36:10 +0000 Subject: [PATCH] Fix GTK+ errors during wxFilePickerCtrl destruction after recent changes. We do need to destroy the dialog (see #15156), but we must not destroy its GtkWidget as it is owned by GtkFileChooserButton itself, so amend the changes of r74030 to only destroy the C++ object, not GTK+ one. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74042 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/filepicker.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gtk/filepicker.cpp b/src/gtk/filepicker.cpp index 104d7d5d92..bebcf84931 100644 --- a/src/gtk/filepicker.cpp +++ b/src/gtk/filepicker.cpp @@ -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)