mirror of
https://github.com/overte-org/overte.git
synced 2025-04-24 02:13:28 +02:00
fix crash in Menu.removeSeparator() if the menu item doesn't exist or isn't a separator
This commit is contained in:
parent
7a8d26247a
commit
13985f8149
1 changed files with 13 additions and 5 deletions
|
@ -1320,17 +1320,25 @@ void Menu::addSeparator(const QString& menuName, const QString& separatorName) {
|
|||
|
||||
void Menu::removeSeparator(const QString& menuName, const QString& separatorName) {
|
||||
QMenu* menu = getMenu(menuName);
|
||||
bool separatorRemoved = false;
|
||||
if (menu) {
|
||||
int textAt = findPositionOfMenuItem(menu, separatorName);
|
||||
QList<QAction*> menuActions = menu->actions();
|
||||
QAction* separatorText = menuActions[textAt];
|
||||
QAction* separatorLine = menuActions[textAt - 1];
|
||||
if (separatorLine->isSeparator()) {
|
||||
menu->removeAction(separatorText);
|
||||
menu->removeAction(separatorLine);
|
||||
if (textAt > 0 && textAt < menuActions.size()) {
|
||||
QAction* separatorLine = menuActions[textAt - 1];
|
||||
if (separatorLine) {
|
||||
if (separatorLine->isSeparator()) {
|
||||
menu->removeAction(separatorText);
|
||||
menu->removeAction(separatorLine);
|
||||
separatorRemoved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QMenuBar::repaint();
|
||||
if (separatorRemoved) {
|
||||
QMenuBar::repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::addMenuItem(const MenuItemProperties& properties) {
|
||||
|
|
Loading…
Reference in a new issue