From 975435c14b61b241a8e5890c21c60a5be48c2116 Mon Sep 17 00:00:00 2001
From: Mateusz Piekos <mateuszpiekos@gmail.com>
Date: Mon, 2 Jul 2012 09:50:57 +0200
Subject: Clearing whiteboard window on session initialization


diff --git a/Swift/QtUI/Whiteboard/GView.cpp b/Swift/QtUI/Whiteboard/GView.cpp
index fe0e5f9..27197d0 100644
--- a/Swift/QtUI/Whiteboard/GView.cpp
+++ b/Swift/QtUI/Whiteboard/GView.cpp
@@ -59,6 +59,11 @@ namespace Swift {
 		idPrefix = prefix;
 	}
 
+	void GView::clear() {
+		scene()->clear();
+		items_.clear();
+	}
+
 	QString GView::getNewID() {
 		return idPrefix + P2QSTRING(idGenerator.generateID());
 	}
diff --git a/Swift/QtUI/Whiteboard/GView.h b/Swift/QtUI/Whiteboard/GView.h
index 4830381..0069fb5 100644
--- a/Swift/QtUI/Whiteboard/GView.h
+++ b/Swift/QtUI/Whiteboard/GView.h
@@ -34,6 +34,7 @@ namespace Swift {
 		QGraphicsItem* getItem(const QString id) const;
 		void addItem(QGraphicsItem* item, QString id);
 		void setIDPrefix(QString prefix);
+		void clear();
 
 	public slots:
 		void moveUpSelectedItem();
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
index 9aa6eb0..66db6db 100644
--- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
+++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
@@ -204,6 +204,7 @@ namespace Swift {
 	}
 
 	void QtWhiteboardWindow::setSession(WhiteboardSession::ref session) {
+		graphicsView->clear();
 		whiteboardSession_ = session;
 		graphicsView->setIDPrefix(P2QSTRING(whiteboardSession_->getClientID()));
 		whiteboardSession_->onElementReceived.connect(boost::bind(&QtWhiteboardWindow::handleWhiteboardElementReceive, this, _1));
-- 
cgit v0.10.2-6-g49f6