X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/717a57c2fabb054c8f00dc5dae70df1d03cfe532..270a909e20a2c652fd816ad14407113ad0319c9d:/src/common/menucmn.cpp diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index b5e8cd4266..5d91787665 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -51,7 +51,8 @@ WX_DEFINE_LIST(wxMenuItemList); wxMenuItemBase::~wxMenuItemBase() { - delete m_subMenu; + if (m_subMenu) + delete m_subMenu; } #if wxUSE_ACCEL @@ -124,11 +125,16 @@ void wxMenuBase::Init(long style) m_style = style; m_clientData = (void *)NULL; m_eventHandler = this; + +#if wxUSE_MENU_CALLBACK + m_callback = (wxFunction) NULL; +#endif // wxUSE_MENU_CALLBACK } wxMenuBase::~wxMenuBase() { - // nothing to do, wxMenuItemList dtor will delete the menu items + // nothing to do, wxMenuItemList dtor will delete the menu items. + // Actually, in GTK, the submenus have to get deleted first. } // ---------------------------------------------------------------------------- @@ -301,16 +307,19 @@ wxMenuItem *wxMenuBase::FindChildItem(int id, size_t *ppos) const size_t pos; for ( pos = 0; node; pos++ ) { - item = node->GetData(); - if ( item->GetId() == id ) + if ( node->GetData()->GetId() == id ) + { + item = node->GetData(); + break; + } node = node->GetNext(); } if ( ppos ) { - *ppos = item ? pos : wxNOT_FOUND; + *ppos = item ? pos : (size_t)wxNOT_FOUND; } return item;