gui: Handle errors in creating build directory (#3295)

If user doesn't create a build directory, it is not possible to run the
addons, because addons are trying to check dump files in non-existent
build directory.
This commit is contained in:
Georgiy Komarov 2021-06-09 12:21:23 +03:00 committed by GitHub
parent fc6558c22b
commit b74618d989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -1590,13 +1590,21 @@ void MainWindow::analyzeProject(const ProjectFile *projectFile, const bool check
if (!QDir::isAbsolutePath(buildDir))
buildDir = inf.canonicalPath() + '/' + buildDir;
if (!QDir(buildDir).exists()) {
QMessageBox msg(QMessageBox::Critical,
QMessageBox msg(QMessageBox::Question,
tr("Cppcheck"),
tr("Build dir '%1' does not exist, create it?").arg(buildDir),
QMessageBox::Yes | QMessageBox::No,
this);
if (msg.exec() == QMessageBox::Yes) {
QDir().mkpath(buildDir);
} else if (!projectFile->getAddons().isEmpty()) {
QMessageBox m(QMessageBox::Critical,
tr("Cppcheck"),
tr("To check the project using addons, you need a build directory."),
QMessageBox::Ok,
this);
m.exec();
return;
}
}
}