diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-06-18 21:17:26 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-06-18 21:27:59 (GMT) |
commit | 154bf14ac15fc7bff918c20814b29b5cc3bc5ba4 (patch) | |
tree | 28f18493bb6bc1cbf85b90f391daa6c4e1ecb3aa /Swift/Controllers | |
parent | b763087e13f25e08aa51a6568b03727f136de34e (diff) | |
download | swift-contrib-154bf14ac15fc7bff918c20814b29b5cc3bc5ba4.zip swift-contrib-154bf14ac15fc7bff918c20814b29b5cc3bc5ba4.tar.bz2 |
Fix crash on reconnect.
BoostTimer isn't supposed to be constructed as a non-shared-ptr. Making
constructor private to avoid this error in the future.
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/MainController.cpp | 16 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 3e3affd..4ca38cc 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -15,7 +15,6 @@ #include "Swiften/Application/Application.h" #include "Swiften/Application/ApplicationMessageDisplay.h" #include "Swiften/Network/TimerFactory.h" -#include "Swiften/Network/BoostTimerFactory.h" #include "Swiften/Network/BoostIOServiceThread.h" #include "Swiften/Network/MainBoostIOServiceThread.h" #include "Swift/Controllers/BuildVersion.h" @@ -81,7 +80,6 @@ MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowF presenceSender_ = NULL; client_ = NULL; mucSearchController_ = NULL; - reconnectTimer_ = NULL; timeBeforeNextReconnect_ = -1; mucSearchWindowFactory_ = mucSearchWindowFactory; @@ -170,8 +168,10 @@ void MainController::resetClient() { void MainController::handleConnected() { timeBeforeNextReconnect_ = -1; - delete reconnectTimer_; - reconnectTimer_ = NULL; + if (reconnectTimer_) { + reconnectTimer_->stop(); + reconnectTimer_.reset(); + } loginWindow_->setIsLoggingIn(false); if (lastDisconnectError_) { lastDisconnectError_->conclude(); @@ -395,7 +395,7 @@ void MainController::setReconnectTimer() { } else { timeBeforeNextReconnect_ = timeBeforeNextReconnect_ >= 150 ? 300 : timeBeforeNextReconnect_ * 2; } - reconnectTimer_ = new BoostTimer(timeBeforeNextReconnect_ * 1000, &MainBoostIOServiceThread::getInstance().getIOService()); + reconnectTimer_ = timerFactory_.createTimer(timeBeforeNextReconnect_ * 1000); reconnectTimer_->onTick.connect(boost::bind(&MainController::reconnectAfterError, this)); reconnectTimer_->start(); } @@ -413,8 +413,10 @@ void MainController::signOut() { } void MainController::logout() { - delete reconnectTimer_; - reconnectTimer_ = 0; + if (reconnectTimer_) { + reconnectTimer_->stop(); + reconnectTimer_.reset(); + } if (client_ /*&& client_->isAvailable()*/) { client_->disconnect(); } diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index ad2cac8..5fc5e8f 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -132,6 +132,6 @@ namespace Swift { MUCSearchController* mucSearchController_; MUCSearchWindowFactory* mucSearchWindowFactory_; int timeBeforeNextReconnect_; - BoostTimer* reconnectTimer_; + Timer::ref reconnectTimer_; }; } |