From: Vadim Zeitlin Date: Tue, 20 Apr 2010 11:59:46 +0000 (+0000) Subject: Check for menu title being non-empty when appending it to the menu bar. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b871bb951a69addc7799f211f7c597cffbe5a44c Check for menu title being non-empty when appending it to the menu bar. It doesn't make sense to add a menu with empty title to the menu bar so assert that the title is not empty and fail to add the menu if it is. See r64033 in wxQT branch. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64058 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/interface/wx/menu.h b/interface/wx/menu.h index 98f2eb56eb..56757d6a2d 100644 --- a/interface/wx/menu.h +++ b/interface/wx/menu.h @@ -73,7 +73,7 @@ public: @param menu The menu to add. Do not deallocate this menu after calling Append(). @param title - The title of the menu. + The title of the menu, must be non-empty. @return @true on success, @false if an error occurred. @@ -497,7 +497,7 @@ public: this string in the status line. @param kind May be @c wxITEM_SEPARATOR, @c wxITEM_NORMAL, @c wxITEM_CHECK or @c wxITEM_RADIO. - + Example: @code m_pFileMenu->Append(ID_NEW_FILE, "&New file\tCTRL+N", "Creates a new XYZ document"); diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 65adec344f..5f7c8cd9b4 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -616,9 +616,10 @@ wxMenu *wxMenuBarBase::GetMenu(size_t pos) const return node->GetData(); } -bool wxMenuBarBase::Append(wxMenu *menu, const wxString& WXUNUSED(title)) +bool wxMenuBarBase::Append(wxMenu *menu, const wxString& title) { wxCHECK_MSG( menu, false, wxT("can't append NULL menu") ); + wxCHECK_MSG( !title.empty(), false, wxT("can't append menu with empty title") ); m_menus.Append(menu); menu->Attach(this);