]> git.saurik.com Git - wxWidgets.git/commitdiff
bug in menu accelerators code corrected (don't create empty accel table,
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Jun 1999 22:12:36 +0000 (22:12 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Jun 1999 22:12:36 +0000 (22:12 +0000)
this exposes a bug in Win32 API :-)

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

src/msw/menu.cpp

index 3fbfd1f1ca858a8fce3bce00c8098fdc5d44c7bb..59fc836e29ff7331a9b17e7dd45af3fa094cb5e7 100644 (file)
@@ -1014,7 +1014,7 @@ void wxMenuBar::Attach(wxFrame *frame)
 
     m_menuBarFrame = frame;
 
-    // create the accel table - we consider that the toolbar construction is
+    // create the accel table - we consider that the menubar construction is
     // finished
     size_t nAccelCount = 0;
     int i;
@@ -1023,17 +1023,20 @@ void wxMenuBar::Attach(wxFrame *frame)
         nAccelCount += m_menus[i]->GetAccelCount();
     }
 
-    wxAcceleratorEntry *accelEntries = new wxAcceleratorEntry[nAccelCount];
-
-    nAccelCount = 0;
-    for ( i = 0; i < m_menuCount; i++ )
+    if ( nAccelCount )
     {
-        nAccelCount += m_menus[i]->CopyAccels(&accelEntries[nAccelCount]);
-    }
+        wxAcceleratorEntry *accelEntries = new wxAcceleratorEntry[nAccelCount];
 
-    m_accelTable = wxAcceleratorTable(nAccelCount, accelEntries);
+        nAccelCount = 0;
+        for ( i = 0; i < m_menuCount; i++ )
+        {
+            nAccelCount += m_menus[i]->CopyAccels(&accelEntries[nAccelCount]);
+        }
+
+        m_accelTable = wxAcceleratorTable(nAccelCount, accelEntries);
 
-    delete [] accelEntries;
+        delete [] accelEntries;
+    }
 }
 
 // ---------------------------------------------------------------------------