From 568abcbd3a43662d72cd61f0195c0097660a552f Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 10 Jun 2003 23:48:46 +0000 Subject: [PATCH] Ensure that a wxMenuItem's parent menu is updated if it is removed from one and added to another menu. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@21027 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/menuitem.h | 1 + src/common/menucmn.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/wx/menuitem.h b/include/wx/menuitem.h index b8d23c5edd..f20ed360d4 100644 --- a/include/wx/menuitem.h +++ b/include/wx/menuitem.h @@ -49,6 +49,7 @@ public: // the menu we're in wxMenu *GetMenu() const { return m_parentMenu; } + void SetMenu(wxMenu* menu) { m_parentMenu = menu; } // get/set id void SetId(int id) { m_id = id; } diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 095f494ff7..99bd5987a7 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -332,6 +332,7 @@ bool wxMenuBase::DoAppend(wxMenuItem *item) wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Append()") ); m_items.Append(item); + item->SetMenu((wxMenu*)this); if ( item->IsSubMenu() ) { AddSubMenu(item->GetSubMenu()); @@ -365,6 +366,7 @@ bool wxMenuBase::DoInsert(size_t pos, wxMenuItem *item) wxCHECK_MSG( node, FALSE, wxT("invalid index in wxMenu::Insert()") ); m_items.Insert(node, item); + item->SetMenu((wxMenu*)this); if ( item->IsSubMenu() ) { AddSubMenu(item->GetSubMenu()); @@ -393,6 +395,7 @@ wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item) m_items.DeleteNode(node); // item isn't attached to anything any more + item->SetMenu((wxMenu *)NULL); wxMenu *submenu = item->GetSubMenu(); if ( submenu ) {