diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-07-15 18:01:53 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-08-04 13:35:07 +0000 |
commit | c7c6dc833936751fc8777f76842f5e28ced71ee8 (patch) | |
tree | ef6dc45d8a88c99ec5db7bd3f82e3e8ac31712bb /src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp | |
parent | d4d7bb6394f01eee118e6e37b0826b878f025341 (diff) |
Remove extra layer of indirection from inspector service
We are not loading any secondary inspector plugins anymore, so the
logic to select them is unnecessary now.
Change-Id: Ic44c49e41c6bff4b19ce527df4657c6d73c0c82b
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp | 58 |
1 files changed, 14 insertions, 44 deletions
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp index 16e1c3e2ec..0b085cc960 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp @@ -32,8 +32,7 @@ ****************************************************************************/ #include "qqmlinspectorservice.h" -#include "qqmlinspectorinterface.h" -#include "qtquick2plugin.h" +#include "qquickviewinspector.h" #include <private/qqmlglobal_p.h> @@ -45,7 +44,7 @@ QT_BEGIN_NAMESPACE QQmlInspectorServiceImpl::QQmlInspectorServiceImpl(QObject *parent): - QQmlInspectorService(1, parent), m_currentInspectorPlugin(0) + QQmlInspectorService(1, parent), m_currentInspector(0) { } @@ -68,42 +67,18 @@ void QQmlInspectorServiceImpl::stateChanged(State /*state*/) void QQmlInspectorServiceImpl::updateState() { - if (m_views.isEmpty()) { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - return; - } - - if (state() == Enabled) { - if (m_inspectorPlugins.isEmpty()) - loadInspectorPlugins(); + delete m_currentInspector; + m_currentInspector = 0; - if (m_inspectorPlugins.isEmpty()) { - qWarning() << "QQmlInspector: No plugins found."; - return; - } - - m_currentInspectorPlugin = 0; - foreach (QQmlInspectorInterface *inspector, m_inspectorPlugins) { - if (inspector->canHandleView(m_views.first())) { - m_currentInspectorPlugin = inspector; - break; - } - } + if (m_views.isEmpty() || state() != Enabled) + return; - if (!m_currentInspectorPlugin) { - qWarning() << "QQmlInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'."; - return; - } - m_currentInspectorPlugin->activate(this, m_views.first()); - } else { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - } + QQuickView *qtQuickView = qobject_cast<QQuickView*>(m_views.first()); + if (qtQuickView) + m_currentInspector = new QmlJSDebugger::QQuickViewInspector(this, qtQuickView, this); + else + qWarning() << "QQmlInspector: No inspector available for view '" + << m_views.first()->metaObject()->className() << "'."; } void QQmlInspectorServiceImpl::messageReceived(const QByteArray &message) @@ -113,13 +88,8 @@ void QQmlInspectorServiceImpl::messageReceived(const QByteArray &message) void QQmlInspectorServiceImpl::processMessage(const QByteArray &message) { - if (m_currentInspectorPlugin) - m_currentInspectorPlugin->clientMessage(message); -} - -void QQmlInspectorServiceImpl::loadInspectorPlugins() -{ - m_inspectorPlugins << new QmlJSDebugger::QtQuick2Plugin; + if (m_currentInspector) + m_currentInspector->handleMessage(message); } QQmlDebugService *QQmlInspectorServiceFactory::create(const QString &key) |