Showing the changes to interface/src/Menu.cpp (1 of 1 file). Show all
Unified · Split
| @@ -1320,17 +1320,25 @@ void Menu::addSeparator(const QString& menuName, const QString& separatorName) { · 1319 unmodified lines | ||
| 1320 | 1320 | |
| 1321 | 1321 | void Menu::removeSeparator(const QString& menuName, const QString& separatorName) { |
| 1322 | 1322 | QMenu* menu = getMenu(menuName); |
| 1323 | + bool separatorRemoved = false; | |
| 1323 | 1324 | if (menu) { |
| 1324 | 1325 | int textAt = findPositionOfMenuItem(menu, separatorName); |
| 1325 | 1326 | QList<QAction*> menuActions = menu->actions(); |
| 1326 | 1327 | 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 | + } | |
| 1331 | 1337 | } |
| 1332 | 1338 | } |
| 1333 | − QMenuBar::repaint(); | |
| 1339 | + if (separatorRemoved) { | |
| 1340 | + QMenuBar::repaint(); | |
| 1341 | + } | |
| 1334 | 1342 | } |
| 1335 | 1343 | |
| 1336 | 1344 | void Menu::addMenuItem(const MenuItemProperties& properties) { |