From 3ff52013d810f94b6095e93f550f58133e2df239 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Thu, 10 Mar 2011 09:03:24 +0000
Subject: (Really this time) fix unread messages.

I hope, anyway.

Resolves: #775

diff --git a/Swift/Controllers/EventWindowController.cpp b/Swift/Controllers/EventWindowController.cpp
index a6ff061..fbe9a8a 100644
--- a/Swift/Controllers/EventWindowController.cpp
+++ b/Swift/Controllers/EventWindowController.cpp
@@ -24,8 +24,12 @@ EventWindowController::~EventWindowController() {
 }
 
 void EventWindowController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> event) {
-	event->onConclusion.connect(boost::bind(&EventWindowController::handleEventConcluded, this, event));
-	window_->addEvent(event, event->getConcluded());
+	if (event->getConcluded()) {
+		handleEventConcluded(event);
+	} else {
+		event->onConclusion.connect(boost::bind(&EventWindowController::handleEventConcluded, this, event));
+		window_->addEvent(event, true);
+	}
 }
 
 void EventWindowController::handleEventConcluded(boost::shared_ptr<StanzaEvent> event) {
diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp
index 157be86..7f8f216 100644
--- a/Swift/Controllers/XMPPEvents/EventController.cpp
+++ b/Swift/Controllers/XMPPEvents/EventController.cpp
@@ -30,12 +30,12 @@ void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceE
 	boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(sourceEvent);
 	if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent) {
 		events_.push_back(sourceEvent);
-		if (sourceEvent->getConcluded()) {
-			handleEventConcluded(sourceEvent);
-		}
 		sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent));
 		onEventQueueLengthChange(events_.size());
 		onEventQueueEventAdded(sourceEvent);
+		if (sourceEvent->getConcluded()) {
+			handleEventConcluded(sourceEvent);
+		}
 	}
 }
 
-- 
cgit v0.10.2-6-g49f6