fix Gtk-CRITICAL errors when deleting wxDirButton

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74619 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2013-08-02 17:01:03 +00:00
parent 4ae5ada038
commit 7eb84cdd47

View File

@@ -104,14 +104,13 @@ wxFileButton::~wxFileButton()
{ {
if ( m_dialog ) if ( m_dialog )
{ {
// We need to delete the C++ dialog object here but we shouldn't delete // when m_dialog is deleted, it will destroy the widget it is sharing
// its widget which is used by our GtkFileChooserButton and will be // with GtkFileChooserButton, which results in a bunch of Gtk-CRITICAL
// deleted by it when it is itself destroyed in our base class dtor. So // errors from GtkFileChooserButton. To avoid this, call gtk_widget_destroy()
// take the widget ownership away from the dialog to avoid GTK+ errors // on GtkFileChooserButton first (our base dtor will do it again, but
// that would happen if GtkFileChooserButton tried to access the // that does no harm). m_dialog holds a reference to the shared widget,
// already destroyed dialog widget. // so it won't go away until m_dialog base dtor unrefs it.
g_object_unref(m_dialog->m_widget); gtk_widget_destroy(m_widget);
m_dialog->m_widget = NULL;
delete m_dialog; delete m_dialog;
} }
} }
@@ -269,8 +268,13 @@ bool wxDirButton::Create( wxWindow *parent, wxWindowID id,
wxDirButton::~wxDirButton() wxDirButton::~wxDirButton()
{ {
if (m_dialog)
{
// see ~wxFileButton() comment
gtk_widget_destroy(m_widget);
delete m_dialog; delete m_dialog;
} }
}
void wxDirButton::GTKUpdatePath(const char *gtkpath) void wxDirButton::GTKUpdatePath(const char *gtkpath)
{ {