From 90a37594798346f22e994e99383f6c719d68fd84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 8 Aug 2018 09:00:04 +0200 Subject: [PATCH] Refactoring: early return --- gui/mainwindow.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index cd92766ef..646d6439f 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1650,28 +1650,27 @@ void MainWindow::enableProjectOpenActions(bool enable) void MainWindow::openRecentProject() { QAction *action = qobject_cast(sender()); - if (action) { - const QString project = action->data().toString(); - QFileInfo inf(project); - if (inf.exists()) { - loadProjectFile(project); - } else { - const QString text(tr("The project file\n\n%1\n\n could not be found!\n\n" - "Do you want to remove the file from the recently " - "used projects -list?").arg(project)); + if (!action) + return; + const QString project = action->data().toString(); + QFileInfo inf(project); + if (inf.exists()) { + loadProjectFile(project); + } else { + const QString text(tr("The project file\n\n%1\n\n could not be found!\n\n" + "Do you want to remove the file from the recently " + "used projects -list?").arg(project)); - QMessageBox msg(QMessageBox::Warning, - tr("Cppcheck"), - text, - QMessageBox::Yes | QMessageBox::No, - this); - - msg.setDefaultButton(QMessageBox::No); - int rv = msg.exec(); - if (rv == QMessageBox::Yes) { - removeProjectMRU(project); - } + QMessageBox msg(QMessageBox::Warning, + tr("Cppcheck"), + text, + QMessageBox::Yes | QMessageBox::No, + this); + msg.setDefaultButton(QMessageBox::No); + int rv = msg.exec(); + if (rv == QMessageBox::Yes) { + removeProjectMRU(project); } } }