From d4d7bb6394f01eee118e6e37b0826b878f025341 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 15 Jul 2015 17:36:28 +0200 Subject: [PATCH] Pass QQmlDebugService to AbstractViewInspector This way we don't have to look up the implementation in order to send messages. Change-Id: I70cb122785875cf8b4ba6f7f2afd62cca77c8abb Reviewed-by: Simon Hausmann --- .../qmltooling/qmldbg_inspector/abstractviewinspector.cpp | 5 ++--- .../qmltooling/qmldbg_inspector/abstractviewinspector.h | 2 +- .../qmltooling/qmldbg_inspector/qqmlinspectorinterface.h | 3 ++- .../qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp | 2 +- .../qmltooling/qmldbg_inspector/qqmlinspectorservice.h | 2 -- .../qmltooling/qmldbg_inspector/qquickviewinspector.cpp | 5 +++-- .../qmltooling/qmldbg_inspector/qquickviewinspector.h | 2 +- src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp | 4 ++-- src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h | 3 ++- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp index ecbe31f2f..fa6dca7ac 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp @@ -33,7 +33,6 @@ #include "abstractviewinspector.h" #include "abstracttool.h" -#include "qqmlinspectorservice.h" #include #include @@ -80,10 +79,10 @@ const char CLEAR_CACHE[] = "clearCache"; namespace QmlJSDebugger { -AbstractViewInspector::AbstractViewInspector(QObject *parent) : +AbstractViewInspector::AbstractViewInspector(QQmlDebugService *service, QObject *parent) : QObject(parent), m_enabled(false), - m_debugService(QQmlDebugConnector::service()), + m_debugService(service), m_eventId(0), m_reloadEventId(-1) { diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h index 342e6359d..8f7ad4ac5 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h @@ -58,7 +58,7 @@ class AbstractViewInspector : public QObject Q_OBJECT public: - explicit AbstractViewInspector(QObject *parent = 0); + explicit AbstractViewInspector(QQmlDebugService *service, QObject *parent = 0); void handleMessage(const QByteArray &message); diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorinterface.h b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorinterface.h index cd9acaba2..a31ccaee2 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorinterface.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorinterface.h @@ -47,6 +47,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -58,7 +59,7 @@ public: virtual bool canHandleView(QObject *view) = 0; - virtual void activate(QObject *view) = 0; + virtual void activate(QQmlDebugService *service, QObject *view) = 0; virtual void deactivate() = 0; virtual void clientMessage(const QByteArray &message) = 0; diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp index 848e6357b..16e1c3e2e 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp @@ -97,7 +97,7 @@ void QQmlInspectorServiceImpl::updateState() qWarning() << "QQmlInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'."; return; } - m_currentInspectorPlugin->activate(m_views.first()); + m_currentInspectorPlugin->activate(this, m_views.first()); } else { if (m_currentInspectorPlugin) { m_currentInspectorPlugin->deactivate(); diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h index 72243cb6b..409a3fe2a 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.h @@ -53,7 +53,6 @@ QT_BEGIN_NAMESPACE -namespace QmlJSDebugger { class AbstractViewInspector; } class QQmlInspectorInterface; @@ -76,7 +75,6 @@ private Q_SLOTS: void updateState(); private: - friend class QmlJSDebugger::AbstractViewInspector; friend class QQmlInspectorServiceFactory; void loadInspectorPlugins(); diff --git a/src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.cpp index 003349ef5..de9d5617b 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.cpp @@ -109,8 +109,9 @@ static QQuickItem *itemAt(QQuickItem *item, const QPointF &pos, } -QQuickViewInspector::QQuickViewInspector(QQuickView *view, QObject *parent) : - AbstractViewInspector(parent), +QQuickViewInspector::QQuickViewInspector(QQmlDebugService *service, QQuickView *view, + QObject *parent) : + AbstractViewInspector(service, parent), m_view(view), m_overlay(new QQuickItem), m_inspectTool(new InspectTool(this, view)), diff --git a/src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.h index 9a2ac4f37..e823e5a03 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qquickviewinspector.h @@ -53,7 +53,7 @@ class QQuickViewInspector : public AbstractViewInspector { Q_OBJECT public: - explicit QQuickViewInspector(QQuickView *view, QObject *parent = 0); + explicit QQuickViewInspector(QQmlDebugService *service, QQuickView *view, QObject *parent = 0); // AbstractViewInspector void changeCurrentObjects(const QList &objects); diff --git a/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp b/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp index 197e618d7..b755c352f 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.cpp @@ -57,11 +57,11 @@ bool QtQuick2Plugin::canHandleView(QObject *view) return qobject_cast(view); } -void QtQuick2Plugin::activate(QObject *view) +void QtQuick2Plugin::activate(QQmlDebugService *service, QObject *view) { QQuickView *qtQuickView = qobject_cast(view); Q_ASSERT(qtQuickView); - m_inspector = new QQuickViewInspector(qtQuickView, qtQuickView); + m_inspector = new QQuickViewInspector(service, qtQuickView, qtQuickView); } void QtQuick2Plugin::deactivate() diff --git a/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h b/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h index 7334cc03d..3e0704f19 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qtquick2plugin.h @@ -36,6 +36,7 @@ #include #include "qqmlinspectorinterface.h" +#include QT_BEGIN_NAMESPACE @@ -54,7 +55,7 @@ public: // QQmlInspectorInterface bool canHandleView(QObject *view); - void activate(QObject *view); + void activate(QQmlDebugService *service, QObject *view); void deactivate(); void clientMessage(const QByteArray &message); -- 2.34.1