From 8faa7c54d442413fc16e9882a1e8bf3c1cca4458 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 23 Sep 2014 17:42:26 +0000 Subject: [PATCH] check the return value of DoInsert and DoAppend, if failed, return NULL immediately git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77824 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/univ/menu.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index 87a2f14f8d..a45f476090 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -1127,7 +1127,10 @@ wxMenuItem* wxMenu::DoAppend(wxMenuItem *item) // for now it has just one element item->SetAsRadioGroupStart(); item->SetRadioGroupEnd(m_startRadioGroup); - wxMenuBase::DoAppend(item); + + if ( !wxMenuBase::DoAppend(item) ) + return NULL; + item->Check(true); } else // extend the current radio group @@ -1144,13 +1147,17 @@ wxMenuItem* wxMenu::DoAppend(wxMenuItem *item) { wxFAIL_MSG( wxT("where is the radio group start item?") ); } - wxMenuBase::DoAppend(item); + + if ( !wxMenuBase::DoAppend(item) ) + return NULL; } } else // not a radio item { EndRadioGroup(); - wxMenuBase::DoAppend(item); + + if ( !wxMenuBase::DoAppend(item) ) + return NULL; } OnItemAdded(item); @@ -1160,8 +1167,6 @@ wxMenuItem* wxMenu::DoAppend(wxMenuItem *item) wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item) { - bool result = false; - if ( item->GetKind() == wxITEM_RADIO ) { unsigned int start, end; @@ -1175,7 +1180,10 @@ wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item) // set this element as the first of radio group item->SetAsRadioGroupStart(); item->SetRadioGroupEnd(m_startRadioGroup); - result = wxMenuBase::DoInsert(pos, item); + + if ( !wxMenuBase::DoInsert(pos, item) ) + return NULL; + item->Check(true); } else // extend the current radio group @@ -1212,14 +1220,16 @@ wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item) wxFAIL_MSG( wxT("where is the radio group start item?") ); } } - result = wxMenuBase::DoInsert(pos, item); + + if ( !wxMenuBase::DoInsert(pos, item) ) + return NULL; } } else - result = wxMenuBase::DoInsert(pos, item); - - if ( !result ) - return NULL; + { + if ( !wxMenuBase::DoInsert(pos, item) ) + return NULL; + } OnItemAdded(item);