don't keep dangling m_prevRadio pointer (2nd part of patch 1836644)
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 28 Nov 2007 02:54:14 +0000 (02:54 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 28 Nov 2007 02:54:14 +0000 (02:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50298 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/menu.cpp

index 85587d91ffa347da3b38fa3a3b01e2e6736f6274..42eb67b2205a371327848109bf3f1f4539ee956d 100644 (file)
@@ -1245,11 +1245,19 @@ wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
 {
     if ( !wxMenuBase::DoRemove(item) )
-        return (wxMenuItem *)NULL;
+        return NULL;
+
+    GtkWidget * const mitem = item->GetMenuItem();
+    if ( m_prevRadio == mitem )
+    {
+        // deleting an item starts a new radio group (has to as we shouldn't
+        // keep a deleted pointer anyhow)
+        m_prevRadio = NULL;
+    }
 
     // TODO: this code doesn't delete the item factory item and this seems
     //       impossible as of GTK 1.2.6.
-    gtk_widget_destroy( item->GetMenuItem() );
+    gtk_widget_destroy( mitem );
 
     return item;
 }