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
This commit is contained in:
Vadim Zeitlin
2014-09-23 17:42:26 +00:00
parent cc93948936
commit 8faa7c54d4

View File

@@ -1127,7 +1127,10 @@ wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
// for now it has just one element // for now it has just one element
item->SetAsRadioGroupStart(); item->SetAsRadioGroupStart();
item->SetRadioGroupEnd(m_startRadioGroup); item->SetRadioGroupEnd(m_startRadioGroup);
wxMenuBase::DoAppend(item);
if ( !wxMenuBase::DoAppend(item) )
return NULL;
item->Check(true); item->Check(true);
} }
else // extend the current radio group 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?") ); wxFAIL_MSG( wxT("where is the radio group start item?") );
} }
wxMenuBase::DoAppend(item);
if ( !wxMenuBase::DoAppend(item) )
return NULL;
} }
} }
else // not a radio item else // not a radio item
{ {
EndRadioGroup(); EndRadioGroup();
wxMenuBase::DoAppend(item);
if ( !wxMenuBase::DoAppend(item) )
return NULL;
} }
OnItemAdded(item); OnItemAdded(item);
@@ -1160,8 +1167,6 @@ wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item) wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
{ {
bool result = false;
if ( item->GetKind() == wxITEM_RADIO ) if ( item->GetKind() == wxITEM_RADIO )
{ {
unsigned int start, end; 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 // set this element as the first of radio group
item->SetAsRadioGroupStart(); item->SetAsRadioGroupStart();
item->SetRadioGroupEnd(m_startRadioGroup); item->SetRadioGroupEnd(m_startRadioGroup);
result = wxMenuBase::DoInsert(pos, item);
if ( !wxMenuBase::DoInsert(pos, item) )
return NULL;
item->Check(true); item->Check(true);
} }
else // extend the current radio group 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?") ); wxFAIL_MSG( wxT("where is the radio group start item?") );
} }
} }
result = wxMenuBase::DoInsert(pos, item);
if ( !wxMenuBase::DoInsert(pos, item) )
return NULL;
} }
} }
else else
result = wxMenuBase::DoInsert(pos, item); {
if ( !wxMenuBase::DoInsert(pos, item) )
if ( !result ) return NULL;
return NULL; }
OnItemAdded(item); OnItemAdded(item);