summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-01-22 12:24:02 (GMT)
committerTobias Markmann <tm@ayena.de>2016-01-22 12:24:02 (GMT)
commit52e685379436794cc0e4c2687c35f5e69a2f09a7 (patch)
tree8306420ffd1c9cd221545fb1382b13fc0496c6be /Swift
parent8480bdda831e4d18c1979f40badb1bc985e78865 (diff)
downloadswift-52e685379436794cc0e4c2687c35f5e69a2f09a7.zip
swift-52e685379436794cc0e4c2687c35f5e69a2f09a7.tar.bz2
Add missing Timer related cleanup code
This commit adds explicit code to stop timers which are connected to objects that are about to be deleted from memory. Test-Information: ./scons test=system passes on OS X 10.11.3. Change-Id: I139314f3a223e3dc63b78b96be17d3ae53cd3de3
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp
index f4b715c..4a84a6e 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.cpp
+++ b/Swift/Controllers/Chat/ChatControllerBase.cpp
@@ -54,6 +54,11 @@ ChatControllerBase::ChatControllerBase(const JID& self, StanzaChannel* stanzaCha
}
ChatControllerBase::~ChatControllerBase() {
+ if (dateChangeTimer_) {
+ dateChangeTimer_->onTick.disconnect(boost::bind(&ChatControllerBase::handleDayChangeTick, this));
+ dateChangeTimer_->stop();
+ }
+
delete highlighter_;
delete chatWindow_;
}
@@ -85,7 +90,7 @@ void ChatControllerBase::createDayChangeTimer() {
boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
boost::posix_time::ptime midnight(now.date() + boost::gregorian::days(1));
int millisecondsUntilMidnight = boost::numeric_cast<int>((midnight - now).total_milliseconds());
- dateChangeTimer_ = boost::shared_ptr<Timer>(timerFactory_->createTimer(millisecondsUntilMidnight));
+ dateChangeTimer_ = timerFactory_->createTimer(millisecondsUntilMidnight);
dateChangeTimer_->onTick.connect(boost::bind(&ChatControllerBase::handleDayChangeTick, this));
dateChangeTimer_->start();
}