]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't try to extract accelerators from menu items which don't have any.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 3 Dec 2010 12:39:48 +0000 (12:39 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 3 Dec 2010 12:39:48 +0000 (12:39 +0000)
We don't need to call wxAcceleratorEntry::Create() in wxMenuItem::GetAccel()
if the menu item doesn't have any accelerator at all, i.e. if there is no TAB
in its label.

Calling wxAcceleratorEntry::Create() is useless and won't work correctly any
more when Create() is updated to allow passing it strings without TAB in them
in the next commit.

See #12745.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/menucmn.cpp

index 4c7abae78dbeedb04f4e4ad023d705f2a0dc13f0..75ab6ef07c23a6bc578fa16a80328b83e30a528a 100644 (file)
@@ -114,7 +114,9 @@ wxMenuItemBase::~wxMenuItemBase()
 
 wxAcceleratorEntry *wxMenuItemBase::GetAccel() const
 {
-    return wxAcceleratorEntry::Create(GetItemLabel());
+    const wxString accel = GetItemLabel().AfterFirst(wxT('\t'));
+
+    return accel.empty() ? NULL : wxAcceleratorEntry::Create(accel);
 }
 
 void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel)