History

fix crash in Menu.removeSeparator() if the menu item doesn't exist or isn't a separator

ZappoMan committed 12 years ago

Commit 13985f81 parent 7a8d2621 file · +13 −5Browse files

Showing the changes to interface/src/Menu.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Menu.cpp+13−5
@@ -1320,17 +1320,25 @@ void Menu::addSeparator(const QString& menuName, const QString& separatorName) { · 1319 unmodified lines
13201320
13211321 void Menu::removeSeparator(const QString& menuName, const QString& separatorName) {
13221322 QMenu* menu = getMenu(menuName);
1323+ bool separatorRemoved = false;
13231324 if (menu) {
13241325 int textAt = findPositionOfMenuItem(menu, separatorName);
13251326 QList<QAction*> menuActions = menu->actions();
13261327 QAction* separatorText = menuActions[textAt];
1327− QAction* separatorLine = menuActions[textAt - 1];
1328− if (separatorLine->isSeparator()) {
1329− menu->removeAction(separatorText);
1330− menu->removeAction(separatorLine);
1328+ if (textAt > 0 && textAt < menuActions.size()) {
1329+ QAction* separatorLine = menuActions[textAt - 1];
1330+ if (separatorLine) {
1331+ if (separatorLine->isSeparator()) {
1332+ menu->removeAction(separatorText);
1333+ menu->removeAction(separatorLine);
1334+ separatorRemoved = true;
1335+ }
1336+ }
13311337 }
13321338 }
1333− QMenuBar::repaint();
1339+ if (separatorRemoved) {
1340+ QMenuBar::repaint();
1341+ }
13341342 }
13351343
13361344 void Menu::addMenuItem(const MenuItemProperties& properties) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t