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
This commit is contained in:
Paul Cornett
2012-06-05 16:49:28 +00:00
parent c7001dcd53
commit 12a5cf1324
2 changed files with 14 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ public:
wxMenuBar(); wxMenuBar();
wxMenuBar(long style); wxMenuBar(long style);
wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0); wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
~wxMenuBar();
// implement base class (pure) virtuals // implement base class (pure) virtuals
virtual bool Append( wxMenu *menu, const wxString &title ); virtual bool Append( wxMenu *menu, const wxString &title );

View File

@@ -58,6 +58,18 @@ static void DoCommonMenuCallbackCode(wxMenu *menu, wxMenuEvent& event)
// wxMenuBar // 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) void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long style)
{ {
#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
@@ -91,7 +103,7 @@ void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long st
GTKApplyWidgetStyle(); GTKApplyWidgetStyle();
#endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2/!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 #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 ) for (size_t i = 0; i < n; ++i )
Append(menus[i], titles[i]); Append(menus[i], titles[i]);