Skip to content

Commit 0d6575d

Browse files
committed
gui: improved error message when project import fails
1 parent aa73427 commit 0d6575d

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

gui/mainwindow.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,38 @@ void MainWindow::analyzeProject(const ProjectFile *projectFile, const bool check
16871687
prjfile = inf.canonicalPath() + '/' + projectFile->getImportProject();
16881688
}
16891689
try {
1690-
p.import(prjfile.toStdString());
1690+
1691+
const ImportProject::Type result = p.import(prjfile.toStdString());
1692+
1693+
QString errorMessage;
1694+
switch (result) {
1695+
case ImportProject::Type::COMPILE_DB:
1696+
case ImportProject::Type::VS_SLN:
1697+
case ImportProject::Type::VS_VCXPROJ:
1698+
case ImportProject::Type::BORLAND:
1699+
case ImportProject::Type::CPPCHECK_GUI:
1700+
// Loading was successful
1701+
break;
1702+
case ImportProject::Type::MISSING:
1703+
errorMessage = tr("Failed to open file");
1704+
break;
1705+
case ImportProject::Type::UNKNOWN:
1706+
errorMessage = tr("Unknown project file format");
1707+
break;
1708+
case ImportProject::Type::FAILURE:
1709+
errorMessage = tr("Failed to import project file");
1710+
break;
1711+
}
1712+
1713+
if (!errorMessage.isEmpty()) {
1714+
QMessageBox msg(QMessageBox::Critical,
1715+
tr("Cppcheck"),
1716+
tr("Failed to import '%1': %2\n\nAnalysis is stopped.").arg(prjfile).arg(errorMessage),
1717+
QMessageBox::Ok,
1718+
this);
1719+
msg.exec();
1720+
return;
1721+
}
16911722
} catch (InternalError &e) {
16921723
QMessageBox msg(QMessageBox::Critical,
16931724
tr("Cppcheck"),

0 commit comments

Comments
 (0)