From f52aa93c3d6d5976b072d31f3d3336beb1596ece Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Fri, 15 Oct 2010 18:09:08 +0200
Subject: Fixed a segfault with pending events.

Release-Notes: Fixed a potential crash on signout when events are pending.

diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp
index 381a5a1..f2fdcfe 100644
--- a/Swift/Controllers/XMPPEvents/EventController.cpp
+++ b/Swift/Controllers/XMPPEvents/EventController.cpp
@@ -18,6 +18,12 @@ namespace Swift {
 EventController::EventController() {
 }
 
+EventController::~EventController() {
+	foreach(boost::shared_ptr<StanzaEvent> event, events_) {
+		event->onConclusion.disconnect(boost::bind(&EventController::handleEventConcluded, this, event));
+	}
+}
+
 void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent) {
 	boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(sourceEvent);
 	boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(sourceEvent);
diff --git a/Swift/Controllers/XMPPEvents/EventController.h b/Swift/Controllers/XMPPEvents/EventController.h
index 61c5c47..1e0a069 100644
--- a/Swift/Controllers/XMPPEvents/EventController.h
+++ b/Swift/Controllers/XMPPEvents/EventController.h
@@ -17,10 +17,12 @@
 
 namespace Swift {
 	typedef std::vector<boost::shared_ptr<StanzaEvent> > EventList;
-	class EventController : public boost::bsignals::trackable{
+	class EventController {
 		public:
 
 			EventController();
+			~EventController();
+
 			void handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent);
 			boost::signal<void (int)> onEventQueueLengthChange;
 			boost::signal<void (boost::shared_ptr<StanzaEvent>)> onEventQueueEventAdded;
-- 
cgit v0.10.2-6-g49f6