From: Paul Cornett Date: Tue, 5 Jun 2012 16:49:28 +0000 (+0000) Subject: Workaround for Ubuntu 12.04 run time warning X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/12a5cf1324e20089b9a3417ae26823b35fd8a0d6?ds=sidebyside Workaround for Ubuntu 12.04 run time warning "LIBDBUSMENU-GLIB-WARNING **: Trying to remove a child that doesn't believe we're it's parent." Avoid calling gtk_widget_destroy() on a wxMenuBar attached to a frame Fixes #14292 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71648 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/menu.h b/include/wx/gtk/menu.h index 9e2f53f5a2..92bb3146d4 100644 --- a/include/wx/gtk/menu.h +++ b/include/wx/gtk/menu.h @@ -21,6 +21,7 @@ public: wxMenuBar(); wxMenuBar(long style); wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0); + ~wxMenuBar(); // implement base class (pure) virtuals virtual bool Append( wxMenu *menu, const wxString &title ); diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 83bece8ee6..f0dbd471f7 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -58,6 +58,18 @@ static void DoCommonMenuCallbackCode(wxMenu *menu, wxMenuEvent& event) // wxMenuBar //----------------------------------------------------------------------------- +wxMenuBar::~wxMenuBar() +{ + if (m_widget) + { + // Work around a probable bug in Ubuntu 12.04 which causes a warning if + // gtk_widget_destroy() is called on a wxMenuBar attached to a frame + GtkWidget* widget = m_widget; + m_widget = NULL; + g_object_unref(widget); + } +} + void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long style) { #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 @@ -91,7 +103,7 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st GTKApplyWidgetStyle(); #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2/!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 - g_object_ref(m_widget); + g_object_ref_sink(m_widget); for (size_t i = 0; i < n; ++i ) Append(menus[i], titles[i]);