OSDN Git Service

Avoid use of dynamic_cast in qmljsdebugger library
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Mon, 14 Mar 2011 13:21:21 +0000 (14:21 +0100)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Mon, 14 Mar 2011 14:40:40 +0000 (15:40 +0100)
Remove usages of 'dynamic_cast' in qmljsdebugger library. Otherwise
compilation will fail for a Qt compiled with -no-rtti.

Task-number: QTCREATORBUG-4043
Reviewed-by: Kai Koehne
share/qtcreator/qml/qmljsdebugger/editor/abstractliveedittool.cpp
share/qtcreator/qml/qmljsdebugger/qdeclarativeviewobserver.cpp

index 433e182..a4b491a 100644 (file)
@@ -88,11 +88,7 @@ bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemLi
     QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList);
     if (firstSelectableItem == 0)
         return false;
-
-    QDeclarativeItem *declarativeItem
-            = dynamic_cast<QDeclarativeItem*>(firstSelectableItem->toGraphicsObject());
-
-    if (declarativeItem != 0)
+    if (toQDeclarativeItem(firstSelectableItem) != 0)
         return true;
 
     return false;
@@ -122,7 +118,7 @@ bool AbstractLiveEditTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &/*
 
 QDeclarativeItem *AbstractLiveEditTool::toQDeclarativeItem(QGraphicsItem *item)
 {
-    return dynamic_cast<QDeclarativeItem*>(item->toGraphicsObject());
+    return qobject_cast<QDeclarativeItem*>(item->toGraphicsObject());
 }
 
 QGraphicsItem *AbstractLiveEditTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList)
index 22ae3d6..f591c03 100644 (file)
@@ -416,7 +416,7 @@ void QDeclarativeViewObserverPrivate::_q_clearComponentCache()
 void QDeclarativeViewObserverPrivate::_q_removeFromSelection(QObject *obj)
 {
     QList<QGraphicsItem*> items = selectedItems();
-    if (QGraphicsItem *item = dynamic_cast<QGraphicsItem*>(obj))
+    if (QGraphicsItem *item = qobject_cast<QGraphicsObject*>(obj))
         items.removeOne(item);
     setSelectedItems(items);
 }