diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index af96b1116d..5625dd8f63 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -59,6 +59,27 @@ wxMenuItemBase::wxMenuItemBase(wxMenu *parentMenu, wxItemKind kind, wxMenu *subMenu) { + switch ( id ) + { + case wxID_ANY: + m_id = wxWindow::NewControlId(); + break; + + case wxID_SEPARATOR: + m_id = wxID_SEPARATOR; + m_kind = wxITEM_SEPARATOR; + break; + + default: + // ids are limited to 16 bits under MSW so portable code shouldn't + // use ids outside of this range (negative ids generated by wx are + // fine though) + wxASSERT_MSG( (id >= 0 && id < SHRT_MAX) || + (id >= wxID_AUTO_LOWEST && id <= wxID_AUTO_HIGHEST), + wxS("invalid id value") ); + m_id = id; + } + // notice that parentMenu can be NULL: the item can be attached to the menu // later with SetMenu() @@ -68,10 +89,6 @@ wxMenuItemBase::wxMenuItemBase(wxMenu *parentMenu, m_isChecked = false; m_id = id; m_kind = kind; - if (m_id == wxID_ANY) - m_id = wxWindow::NewControlId(); - if (m_id == wxID_SEPARATOR) - m_kind = wxITEM_SEPARATOR; SetItemLabel(text); SetHelp(help);