GUI: Close application cleanly when exiting while checking.

Earlier commit allowed cppcheck to exit immediately while checking.
This however leads crashes and error logs shown since the thread
termination leaves things in inconsistent state. I thought cppcheck
would close fast enough so these could be ignored. But apparently
not.

So this commits adds new bool mExiting for MainWindow and sets that
to true when exiting while checking. When the checking is ready this
attribute is checked and if it is true the application can now be
cleanly exited.
This commit is contained in:
Kimmo Varis 2010-07-17 23:52:50 +03:00
parent 3261f848c3
commit 0b463dadb9
2 changed files with 19 additions and 4 deletions

View File

@ -47,7 +47,8 @@ MainWindow::MainWindow() :
mApplications(new ApplicationList(this)),
mTranslation(new TranslationHandler(this)),
mLanguages(new QActionGroup(this)),
mLogView(NULL)
mLogView(NULL),
mExiting(false)
{
mUI.setupUi(this);
mUI.mResults->Initialize(mSettings, mApplications);
@ -399,6 +400,12 @@ QStringList MainWindow::RemoveUnacceptedFiles(const QStringList &list)
void MainWindow::CheckDone()
{
if (mExiting)
{
close();
return;
}
mUI.mResults->CheckingFinished();
EnableCheckButtons(true);
mUI.mActionSettings->setEnabled(true);
@ -522,9 +529,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
// exiting it doesn't matter.
mThread->Stop();
SaveSettings();
event->accept();
mExiting = true;
}
else
event->ignore();
}
}

View File

@ -343,6 +343,15 @@ protected:
*/
LogView *mLogView;
private:
/**
* @brief Are we exiting the cppcheck?
* If this is true then the cppcheck is waiting for check threads to exit
* so that the application can be closed.
*/
bool mExiting;
};
/// @}
#endif // MAINWINDOW_H