Fix QDeclarativeInspector when starting with ,block
authorKai Koehne <kai.koehne@nokia.com>
Sat, 15 Oct 2011 14:56:40 +0000 (16:56 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 17 Oct 2011 12:56:09 +0000 (14:56 +0200)
Change-Id: I3797567f22f61abf59ec5332ebc74b3fa37ede93
(cherrypicked from commit 6cb43a9b72c67b71409a59fdeb419f390441f0c7)
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>

src/declarative/debugger/qdeclarativeinspectorservice.cpp
src/declarative/debugger/qdeclarativeinspectorservice_p.h

index d19cae7..e618c69 100644 (file)
@@ -65,11 +65,13 @@ QDeclarativeInspectorService *QDeclarativeInspectorService::instance()
 void QDeclarativeInspectorService::addView(QObject *view)
 {
     m_views.append(view);
+    updateStatus();
 }
 
 void QDeclarativeInspectorService::removeView(QObject *view)
 {
     m_views.removeAll(view);
+    updateStatus();
 }
 
 void QDeclarativeInspectorService::sendMessage(const QByteArray &message)
@@ -82,10 +84,18 @@ void QDeclarativeInspectorService::sendMessage(const QByteArray &message)
 
 void QDeclarativeInspectorService::statusChanged(Status status)
 {
-    if (m_views.isEmpty())
+    updateStatus();
+}
+
+void QDeclarativeInspectorService::updateStatus()
+{
+    if (m_views.isEmpty()) {
+        if (m_inspectorPlugin)
+            m_inspectorPlugin->deactivate();
         return;
+    }
 
-    if (status == Enabled) {
+    if (status() == Enabled) {
         if (!m_inspectorPlugin)
             m_inspectorPlugin = loadInspectorPlugin();
 
index c660fb4..df51ab8 100644 (file)
@@ -88,6 +88,7 @@ protected:
     virtual void messageReceived(const QByteArray &);
 
 private:
+    void updateStatus();
     static QDeclarativeInspectorInterface *loadInspectorPlugin();
 
     QList<QObject*> m_views;