From: Václav Slavík Date: Sun, 3 Oct 2004 21:00:45 +0000 (+0000) Subject: fixed menu destruction if it was removed from menubar with Remove X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a761df69a31c5bdbf6af7a80709bfd9cc8a854b3 fixed menu destruction if it was removed from menubar with Remove git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 83ba105c00..c72c5a8ee2 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -982,8 +982,12 @@ wxMenu::~wxMenu() if ( GTK_IS_WIDGET( m_menu )) { - gtk_widget_unref( m_menu ); // see wxMenu::Init - gtk_widget_destroy( m_menu ); + // see wxMenu::Init + gtk_widget_unref( m_menu ); + // if the menu is inserted in another menu at this time, there was + // one more reference to it: + if ( m_owner ) + gtk_widget_destroy( m_menu ); } } diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 83ba105c00..c72c5a8ee2 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -982,8 +982,12 @@ wxMenu::~wxMenu() if ( GTK_IS_WIDGET( m_menu )) { - gtk_widget_unref( m_menu ); // see wxMenu::Init - gtk_widget_destroy( m_menu ); + // see wxMenu::Init + gtk_widget_unref( m_menu ); + // if the menu is inserted in another menu at this time, there was + // one more reference to it: + if ( m_owner ) + gtk_widget_destroy( m_menu ); } }