diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e3f3631f3..6b0aab0db 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1687,7 +1687,38 @@ void MainWindow::analyzeProject(const ProjectFile *projectFile, const bool check prjfile = inf.canonicalPath() + '/' + projectFile->getImportProject(); } try { - p.import(prjfile.toStdString()); + + const ImportProject::Type result = p.import(prjfile.toStdString()); + + QString errorMessage; + switch (result) { + case ImportProject::Type::COMPILE_DB: + case ImportProject::Type::VS_SLN: + case ImportProject::Type::VS_VCXPROJ: + case ImportProject::Type::BORLAND: + case ImportProject::Type::CPPCHECK_GUI: + // Loading was successful + break; + case ImportProject::Type::MISSING: + errorMessage = tr("Failed to open file"); + break; + case ImportProject::Type::UNKNOWN: + errorMessage = tr("Unknown project file format"); + break; + case ImportProject::Type::FAILURE: + errorMessage = tr("Failed to import project file"); + break; + } + + if (!errorMessage.isEmpty()) { + QMessageBox msg(QMessageBox::Critical, + tr("Cppcheck"), + tr("Failed to import '%1': %2\n\nAnalysis is stopped.").arg(prjfile).arg(errorMessage), + QMessageBox::Ok, + this); + msg.exec(); + return; + } } catch (InternalError &e) { QMessageBox msg(QMessageBox::Critical, tr("Cppcheck"),