From 874ed4f42dd29fc2b8e7b905072e6a1b9a26582c Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Fri, 8 Oct 2010 11:18:20 +0100
Subject: Fix for very unlikely timing-related crash when quitting during event
 handling


diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index ccefa4b..06b231c 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -178,6 +178,7 @@ MainController::MainController(
 }
 
 MainController::~MainController() {
+	eventController_->disconnectAll();
 	delete systemTrayController_;
 	delete soundEventController_;
 	delete xmlConsoleController_;
diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp
index b14ff46..4e70978 100644
--- a/Swift/Controllers/XMPPEvents/EventController.cpp
+++ b/Swift/Controllers/XMPPEvents/EventController.cpp
@@ -35,4 +35,9 @@ void EventController::handleEventConcluded(boost::shared_ptr<StanzaEvent> event)
 	onEventQueueLengthChange(events_.size());
 }
 
+void EventController::disconnectAll() {
+	onEventQueueLengthChange.disconnect_all_slots();
+	onEventQueueEventAdded.disconnect_all_slots();
+}
+
 }
diff --git a/Swift/Controllers/XMPPEvents/EventController.h b/Swift/Controllers/XMPPEvents/EventController.h
index 59bc55f..ba571df 100644
--- a/Swift/Controllers/XMPPEvents/EventController.h
+++ b/Swift/Controllers/XMPPEvents/EventController.h
@@ -25,6 +25,7 @@ namespace Swift {
 			boost::signal<void (int)> onEventQueueLengthChange;
 			boost::signal<void (boost::shared_ptr<StanzaEvent>)> onEventQueueEventAdded;
 			const EventList& getEvents() const {return events_;}
+			void disconnectAll();
 
 		private:
 			void handleEventConcluded(boost::shared_ptr<StanzaEvent> event);
-- 
cgit v0.10.2-6-g49f6