Skip to content

Commit

Permalink
Make sure that the application closes properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederick Thomssen committed May 12, 2016
1 parent a96f126 commit ce29055
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions RedTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "RedTimer.h"
#include "logging.h"

#include <QEventLoop>
#include <QMessageBox>
#include <QMenu>
#include <QNetworkInterface>
Expand Down Expand Up @@ -314,9 +315,21 @@ RedTimer::exit()
case QMessageBox::Save:
{
DEBUG() << "Saving time entry before closing the application";
connect( this, &RedTimer::timeEntrySaved, [=](){ app_->quit(); } );

// Only go on with closing the window if saving was successful
// If saving was successful before the blocker has been started, do not start it at all
QEventLoop* blocker = new QEventLoop();
bool startBlocker = true;
connect( this, &RedTimer::timeEntrySaved, [&]()
{
startBlocker = false;
blocker->exit();
} );

stop();
return;

if( startBlocker )
blocker->exec();
}

default:
Expand Down

0 comments on commit ce29055

Please sign in to comment.