From aeb359c0c915631e97625f20e8aa648d95459131 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Thu, 19 Aug 2010 21:29:28 +0100
Subject: Rolling back accidental commit


diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 6b38309..3324108 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -68,14 +68,6 @@ void QtChatView::handleKeyPressEvent(QKeyEvent* event) {
 }
 
 void QtChatView::addMessage(const ChatSnippet& snippet) {
-	if (viewReady_) {
-		appendToView(snippet);
-	} else {
-		queuedSnippets_.append(snippet);
-	}
-}
-
-void QtChatView::appendToView(const ChatSnippet& snippet) {
 	//bool wasScrolledToBottom = isScrolledToBottom();
 	
 	QString content = snippet.getContent();
@@ -90,7 +82,12 @@ void QtChatView::appendToView(const ChatSnippet& snippet) {
 	else {
 		command = "appendNextMessage(\"" + content + "\");";
 	}
-	webPage_->mainFrame()->evaluateJavaScript(command);
+	if (viewReady_) {
+		webPage_->mainFrame()->evaluateJavaScript(command);
+	}
+	else {
+		queuedMessages_ += command;
+	}
 
 	//qDebug() << webPage_->mainFrame()->toHtml();
 	previousContinuationElementID_ = snippet.getContinuationElementID();
@@ -121,9 +118,7 @@ void QtChatView::handleLinkClicked(const QUrl& url) {
 void QtChatView::handleViewLoadFinished(bool ok) {
 	Q_ASSERT(ok);
 	viewReady_ = true;
-	foreach (const ChatSnippet& snippet, queuedSnippets_) {
-		appendToView(snippet);
-	}
+	webPage_->mainFrame()->evaluateJavaScript(queuedMessages_);
 	queuedMessages_.clear();
 }
 
diff --git a/Swift/QtUI/QtChatView.h b/Swift/QtUI/QtChatView.h
index a5b6b4a..ea64265 100644
--- a/Swift/QtUI/QtChatView.h
+++ b/Swift/QtUI/QtChatView.h
@@ -9,7 +9,6 @@
 
 #include <QString>
 #include <QWidget>
-#include <QList>
 
 #include "ChatSnippet.h"
 
@@ -36,12 +35,11 @@ namespace Swift {
 			void handleViewLoadFinished(bool);
 
 		private:
-			void appendToView(const ChatSnippet& snippet);
 			bool viewReady_;
 			QtWebView* webView_;
 			QWebPage* webPage_;
 			QString previousContinuationElementID_;
-			QList<ChatSnippet> queuedSnippets_;
+			QString queuedMessages_;
 	};
 }
 
-- 
cgit v0.10.2-6-g49f6