Commit 9b9c204c authored by Ahmad Samir's avatar Ahmad Samir Committed by Kurt Hindenburg
Browse files

SessionContoller: fix crash when closing session from Konsole KPart

_preventClose has to be set to false right at the end, so as to prevent
crashes if the user selects the "close session" action from the context
menu in a Konsole KPart (e.g. the terminal panel in Dolphin).

Check menu object isn't null before deleting actions from it.

BUG: 429538
(cherry picked from commit 043c424a)
parent 9a16c251
......@@ -1821,25 +1821,25 @@ void SessionController::showDisplayContextMenu(const QPoint& position)
// check for validity of the pointer to the popup menu
if (!popup.isNull()) {
delete contentSeparator;
// Remove the 'Open with' actions from it.
QList<QAction*> toDelete;
for (auto *action : popup->actions()) {
if (action->text().toLower().remove(QLatin1Char('&')).contains(i18n("open with"))) {
toDelete.append(action);
}
}
qDeleteAll(toDelete);
// Remove the Accelerator for the copy shortcut so we don't have two actions with same shortcut.
copy->setShortcut({});
}
// This should be at the end, to prevent crashes if the session
// is closed from the menu in e.g. konsole kpart
_preventClose = false;
if ((chosen != nullptr) && chosen->objectName() == QLatin1String("close-session")) {
chosen->trigger();
}
// Remove the 'Open with' actions from it.
QList<QAction*> toDelete;
for (auto *action : popup->actions()) {
if (action->text().toLower().remove(QLatin1Char('&')).contains(i18n("open with"))) {
toDelete.append(action);
}
}
qDeleteAll(toDelete);
// Remove the Accelerator for the copy shortcut so we don't have two actions with same shortcut.
copy->setShortcut({});
} else {
qCDebug(KonsoleDebug) << "Unable to display popup menu for session"
<< _sessionDisplayConnection->session()->title(Session::NameRole)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment