From d810c5b77ffc0b09f3ded01cd2758dd13211b33c Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 18 Oct 2018 15:14:48 +0200 Subject: [PATCH] Fix crash when pressing wrong shortcuts in welcome mode Fixes: QTCREATORBUG-21302 Change-Id: Ib7e50f3cbd3e6e8f995b8cda7ad965f0cafde511 Reviewed-by: Orgad Shaneh --- src/plugins/projectexplorer/projectwelcomepage.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp index 9cf3167a24a..08842aabeaa 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.cpp +++ b/src/plugins/projectexplorer/projectwelcomepage.cpp @@ -127,12 +127,18 @@ ProjectWelcomePage::ProjectWelcomePage() auto act = new QAction(tr("Open Session #%1").arg(i), this); Command *cmd = ActionManager::registerAction(act, sessionBase.withSuffix(i), welcomeContext); cmd->setDefaultKeySequence(QKeySequence((useMacShortcuts ? tr("Ctrl+Meta+%1") : tr("Ctrl+Alt+%1")).arg(i))); - connect(act, &QAction::triggered, this, [this, i] { openSessionAt(i - 1); }); + connect(act, &QAction::triggered, this, [this, i] { + if (i <= m_sessionModel->rowCount()) + openSessionAt(i - 1); + }); act = new QAction(tr("Open Recent Project #%1").arg(i), this); cmd = ActionManager::registerAction(act, projectBase.withSuffix(i), welcomeContext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+%1").arg(i))); - connect(act, &QAction::triggered, this, [this, i] { openProjectAt(i - 1); }); + connect(act, &QAction::triggered, this, [this, i] { + if (i <= m_projectModel->rowCount(QModelIndex())) + openProjectAt(i - 1); + }); } }