From 3e4d20f13ced528f5366b0f485c4cbe636cb4756 Mon Sep 17 00:00:00 2001 From: Simjees Abraham Date: Mon, 16 Apr 2012 11:33:41 +0200 Subject: [PATCH] QPointer used instead of QWeakPointer Correctly used QPointer instead of QWeakPointer in QuickViewInspector and Highlight classes. Change-Id: I579bd148e71803b029d7a036cdcb7255740dbd91 Reviewed-by: Aurindam Jana --- src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp | 11 +++++------ src/plugins/qmltooling/qmldbg_qtquick2/highlight.h | 6 +++--- .../qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp | 12 ++++++------ src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h | 4 ++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp index f82a520..d014dd4 100644 --- a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp +++ b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.cpp @@ -56,7 +56,7 @@ Highlight::Highlight(QQuickItem *item, QQuickItem *parent) void Highlight::setItem(QQuickItem *item) { if (m_item) - m_item.data()->disconnect(this); + m_item->disconnect(this); if (item) { connect(item, SIGNAL(xChanged()), SLOT(adjust())); @@ -84,19 +84,18 @@ void Highlight::setItem(QQuickItem *item) void Highlight::adjust() { - const QQuickItem *item = m_item.data(); - if (!item) + if (!m_item) return; bool success = false; - m_transform = item->itemTransform(0, &success); + m_transform = m_item->itemTransform(0, &success); if (!success) m_transform = QTransform(); - setSize(QSizeF(item->width(), item->height())); + setSize(QSizeF(m_item->width(), m_item->height())); qreal scaleFactor = 1; QPointF originOffset = QPointF(0,0); - QQuickCanvas *view = item->canvas(); + QQuickCanvas *view = m_item->canvas(); if (view->rootItem()) { scaleFactor = view->rootItem()->scale(); originOffset -= view->rootItem()->pos(); diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h index 1eb9757..3dbd109 100644 --- a/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h +++ b/src/plugins/qmltooling/qmldbg_qtquick2/highlight.h @@ -42,7 +42,7 @@ #ifndef HIGHLIGHT_H #define HIGHLIGHT_H -#include +#include #include #include @@ -59,7 +59,7 @@ public: Highlight(QQuickItem *item, QQuickItem *parent); void setItem(QQuickItem *item); - QQuickItem *item() {return m_item.data();} + QQuickItem *item() {return m_item;} protected: QTransform transform() {return m_transform;} @@ -68,7 +68,7 @@ private slots: void adjust(); private: - QWeakPointer m_item; + QPointer m_item; QTransform m_transform; }; diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp index 9fd5954..f92fbb9 100644 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.cpp @@ -225,9 +225,9 @@ QList QQuickViewInspector::itemsAt(const QPointF &pos) const QList QQuickViewInspector::selectedItems() const { QList selection; - foreach (const QWeakPointer &selectedItem, m_selectedItems) { + foreach (const QPointer &selectedItem, m_selectedItems) { if (selectedItem) - selection << selectedItem.data(); + selection << selectedItem; } return selection; } @@ -249,16 +249,16 @@ bool QQuickViewInspector::syncSelectedItems(const QList &items) bool selectionChanged = false; // Disconnect and remove items that are no longer selected - foreach (const QWeakPointer &item, m_selectedItems) { + foreach (const QPointer &item, m_selectedItems) { if (!item) // Don't see how this can happen due to handling of destroyed() continue; - if (items.contains(item.data())) + if (items.contains(item)) continue; selectionChanged = true; - item.data()->disconnect(this); + item->disconnect(this); m_selectedItems.removeOne(item); - delete m_highlightItems.take(item.data()); + delete m_highlightItems.take(item); } // Connect and add newly selected items diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h index 0fd2948..bcc008c 100644 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h +++ b/src/plugins/qmltooling/qmldbg_qtquick2/qquickviewinspector.h @@ -44,7 +44,7 @@ #include "abstractviewinspector.h" -#include +#include #include QT_BEGIN_NAMESPACE @@ -100,7 +100,7 @@ private: InspectTool *m_inspectTool; - QList > m_selectedItems; + QList > m_selectedItems; QHash m_highlightItems; bool m_designMode; -- 2.7.4