diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 6f69ff297..59568a44c 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -317,6 +317,7 @@ Settings MainWindow::GetCppcheckSettings() if (QFile::exists(projfile)) { qDebug() << "Reading project file " << projfile; + pfile = new ProjectFile(); projectRead = pfile->Read(projfile); } } @@ -352,6 +353,9 @@ Settings MainWindow::GetCppcheckSettings() } } + if (!mProject) + delete pfile; + result._debug = false; result._checkCodingStyle = true; result._errorsOnly = false; @@ -685,8 +689,7 @@ void MainWindow::OpenHtmlHelpContents() void MainWindow::OpenProjectFile() { - if (mProject != NULL) - delete mProject; + delete mProject; const QString filter = tr("Project files (*.cppcheck);;All files(*.*)"); QString filepath = QFileDialog::getOpenFileName(this, @@ -747,8 +750,7 @@ void MainWindow::NewProjectFile() const QString filename = inf.fileName(); FormatAndSetTitle(tr("Project:") + QString(" ") + filename); - if (mProject) - delete mProject; + delete mProject; mProject = new Project(filepath, this); mProject->Create(); mProject->Edit();