DeclarativeObserver: Fixed duplicates in item selection
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Wed, 25 May 2011 11:42:48 +0000 (13:42 +0200)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Fri, 27 May 2011 13:40:37 +0000 (15:40 +0200)
Only add items to the current selection that aren't already part of it.

Also removed checking item for null, since it doesn't make sense to
include null pointers in the list of items to select.

Task-number: QTCREATORBUG-3426
Change-Id: I5a365570f87f72665b3382d05ca9937f56e8956b
Reviewed-by: Christiaan Janssen
(cherry picked from commit f75fda0365a4e4bf1f26dedc40d96d37a2599174)

src/plugins/qmltooling/declarativeobserver/qdeclarativeviewobserver.cpp

index a49a758..bb23831 100644 (file)
@@ -494,8 +494,8 @@ void QDeclarativeViewObserverPrivate::setSelectedItemsForTools(const QList<QGrap
     }
 
     foreach (QGraphicsItem *item, items) {
-        if (item) {
-            if (QGraphicsObject *obj = item->toGraphicsObject()) {
+        if (QGraphicsObject *obj = item->toGraphicsObject()) {
+            if (!currentSelection.contains(obj)) {
                 QObject::connect(obj, SIGNAL(destroyed(QObject*)),
                                  this, SLOT(_q_removeFromSelection(QObject*)));
                 currentSelection.append(obj);