Fix crash by not assuming standard shortcuts are present.

Neither of the two standard shortcuts used here are *guaranteed* to be
present (kdelibs filters both with some KAuthorized magic, and
help_contents also depends on the documentation subsystem), so avoid
crashing just because they're not around.

First noticed on my Gentoo-provided Konsole which is compiled without
the handbook USE flag.
(cherry picked from commit 8950584966)
This commit is contained in:
Michael Pyne
2013-06-08 13:39:16 -04:00
parent 136851bad3
commit e61326fd0b

View File

@@ -176,15 +176,15 @@ void MainWindow::correctStandardShortcuts()
{
// replace F1 shortcut for help contents
QAction* helpAction = actionCollection()->action("help_contents");
Q_ASSERT(helpAction);
helpAction->setShortcut(QKeySequence());
if (helpAction) {
helpAction->setShortcut(QKeySequence());
}
// replace Ctrl+B shortcut for bookmarks only if user hasn't already
// changed the shortcut; however, if the user changed it to Ctrl+B
// this will still get changed to Ctrl+Shift+B
QAction* bookmarkAction = actionCollection()->action("add_bookmark");
Q_ASSERT(bookmarkAction);
if (bookmarkAction->shortcut() == QKeySequence(Qt::CTRL + Qt::Key_B)) {
if (bookmarkAction && bookmarkAction->shortcut() == QKeySequence(Qt::CTRL + Qt::Key_B)) {
bookmarkAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B));
}
}