From bfe35997681e54f6610c1db09fd2955eaf110418 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 9 May 2019 14:44:44 +0200 Subject: [PATCH] ProjectExplorer: Don't let the "import project" action fail silently Fixes: QTCREATORBUG-17839 Change-Id: I3c57ca36f793aa1858558024566518c0dfdb4097 Reviewed-by: hjk --- src/plugins/projectexplorer/projectimporter.cpp | 15 ++++++++++----- src/plugins/projectexplorer/projectimporter.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/projectexplorer/projectimporter.cpp b/src/plugins/projectexplorer/projectimporter.cpp index 34ba3206f53..3c6e48733af 100644 --- a/src/plugins/projectexplorer/projectimporter.cpp +++ b/src/plugins/projectexplorer/projectimporter.cpp @@ -99,10 +99,18 @@ const QList ProjectImporter::import(const Utils::FileName &importPath const Utils::FileName absoluteImportPath = Utils::FileName::fromString(fi.absoluteFilePath()); + const auto handleFailure = [this, importPath, silent] { + if (silent) + return; + QMessageBox::critical(Core::ICore::mainWindow(), tr("No Build Found"), + tr("No build found in %1 matching project %2.") + .arg(importPath.toUserOutput(), projectFilePath().toUserOutput())); + }; qCDebug(log) << "Examining directory" << absoluteImportPath.toString(); QList dataList = examineDirectory(absoluteImportPath); if (dataList.isEmpty()) { qCDebug(log) << "Nothing to import found in" << absoluteImportPath.toString(); + handleFailure(); return result; } @@ -141,11 +149,8 @@ const QList ProjectImporter::import(const Utils::FileName &importPath deleteDirectoryData(dd); dataList.clear(); - if (result.isEmpty() && !silent) - QMessageBox::critical(Core::ICore::mainWindow(), - QCoreApplication::translate("ProjectExplorer::ProjectImporter", "No Build Found"), - QCoreApplication::translate("ProjectExplorer::ProjectImporter", "No build found in %1 matching project %2.") - .arg(importPath.toUserOutput()).arg(projectFilePath().toUserOutput())); + if (result.isEmpty()) + handleFailure(); return result; } diff --git a/src/plugins/projectexplorer/projectimporter.h b/src/plugins/projectexplorer/projectimporter.h index 133cb811ddd..87ee21a7b8e 100644 --- a/src/plugins/projectexplorer/projectimporter.h +++ b/src/plugins/projectexplorer/projectimporter.h @@ -44,6 +44,7 @@ class ToolChain; // Documentation inside. class PROJECTEXPLORER_EXPORT ProjectImporter : public QObject { + Q_OBJECT public: struct ToolChainData { QList tcs;