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;