From 135f55589ef230ab009e3b961895a6d3b12cdc87 Mon Sep 17 00:00:00 2001 From: Kevin Smith <git@kismith.co.uk> Date: Thu, 23 Dec 2010 10:32:29 +0000 Subject: Add a timer so 20 seconds after requesting a quit, it'll quit regardless of receiving a stream close diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index b925857..660c12f 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -554,6 +554,9 @@ void MainController::handleNotificationClicked(const JID& jid) { void MainController::handleQuitRequest() { if (client_ && client_->isActive()) { quitRequested_ = true; + quitTimer_ = networkFactories_->getTimerFactory()->createTimer(SecondsToWaitBeforeForceQuitting * 1000); + quitTimer_->onTick.connect(boost::bind(&MainController::handleForceQuit, this)); + quitTimer_->start(); client_->disconnect(); } else { @@ -562,4 +565,12 @@ void MainController::handleQuitRequest() { } } +void MainController::handleForceQuit() { + delete client_; + client_ = NULL; + handleQuitRequest(); +} + +const int MainController::SecondsToWaitBeforeForceQuitting = 20; + } diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index aece80f..8489f71 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -102,6 +102,7 @@ namespace Swift { void reconnectAfterError(); void setManagersOffline(); void handleNotificationClicked(const JID& jid); + void handleForceQuit(); private: EventLoop* eventLoop_; @@ -141,8 +142,10 @@ namespace Swift { UserSearchController* userSearchController_; int timeBeforeNextReconnect_; Timer::ref reconnectTimer_; + Timer::ref quitTimer_; StatusTracker* statusTracker_; bool myStatusLooksOnline_; bool quitRequested_; + static const int SecondsToWaitBeforeForceQuitting; }; } -- cgit v0.10.2-6-g49f6