]> git.saurik.com Git - wxWidgets.git/commitdiff
reference count the GtkMenuItem in wxMenuItem as well
authorPaul Cornett <paulcor@bullseye.com>
Sat, 29 Dec 2012 07:07:29 +0000 (07:07 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Sat, 29 Dec 2012 07:07:29 +0000 (07:07 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73311 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/menuitem.h
src/gtk/menu.cpp

index 6d155103065717d36a19c2866636ae69b9e135ad..157602bb93983279adc51ca6c1ff0aea3adf18fe 100644 (file)
@@ -36,7 +36,7 @@ public:
     virtual const wxBitmap& GetBitmap() const { return m_bitmap; }
 
     // implementation
-    void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
+    void SetMenuItem(GtkWidget *menuItem);
     GtkWidget *GetMenuItem() const { return m_menuItem; }
     void SetGtkLabel();
 
index 898fb2f5f72c411679282122ceda6e1a5b860c41..694c0d503a759c7f1fc89fd62147741b6ca2d631 100644 (file)
@@ -597,9 +597,20 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu,
 
 wxMenuItem::~wxMenuItem()
 {
+    if (m_menuItem)
+        g_object_unref(m_menuItem);
    // don't delete menu items, the menus take care of that
 }
 
+void wxMenuItem::SetMenuItem(GtkWidget* menuItem)
+{
+    if (m_menuItem)
+        g_object_unref(m_menuItem);
+    m_menuItem = menuItem;
+    if (menuItem)
+        g_object_ref(menuItem);
+}
+
 void wxMenuItem::SetItemLabel( const wxString& str )
 {
 #if wxUSE_ACCEL