From 7a1bf412fbc3d5c73f32ec5ad58242e6700cb1b5 Mon Sep 17 00:00:00 2001
From: Aurindam Jana <aurindam.jana@nokai.com>
Date: Mon, 17 Oct 2011 17:45:15 +0200
Subject: [PATCH] QmlCppEngine: StackWindow Behaviour

Enable/Disable the stack window based on engine state.
Update the markers in the stack window correctly.

Change-Id: Idbc694aa2a4be9497e2e3b2c9e9a1f463e1c7692
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
---
 src/plugins/debugger/qml/qmlcppengine.cpp | 9 +++++++--
 src/plugins/debugger/stackhandler.cpp     | 1 +
 src/plugins/debugger/stackhandler.h       | 3 +++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp
index ba2f7aaa0c8..c1c26576d2f 100644
--- a/src/plugins/debugger/qml/qmlcppengine.cpp
+++ b/src/plugins/debugger/qml/qmlcppengine.cpp
@@ -149,9 +149,9 @@ QmlCppEngine::QmlCppEngine(const DebuggerStartParameters &sp,
     }
     d->m_activeEngine = d->m_cppEngine;
 
-    connect(d->m_cppEngine->stackHandler()->model(), SIGNAL(modelReset()),
+    connect(d->m_cppEngine->stackHandler(), SIGNAL(stackChanged()),
             d, SLOT(cppStackChanged()), Qt::QueuedConnection);
-    connect(d->m_qmlEngine->stackHandler()->model(), SIGNAL(modelReset()),
+    connect(d->m_qmlEngine->stackHandler(), SIGNAL(stackChanged()),
             d, SLOT(qmlStackChanged()), Qt::QueuedConnection);
     connect(d->m_cppEngine, SIGNAL(stackFrameCompleted()), this, SIGNAL(stackFrameCompleted()));
     connect(d->m_cppEngine, SIGNAL(requestRemoteSetup()), this, SIGNAL(requestRemoteSetup()));
@@ -195,6 +195,9 @@ void QmlCppEngine::fetchDisassembler(DisassemblerAgent *da)
 
 void QmlCppEngine::activateFrame(int index)
 {
+    if (state() != InferiorStopOk && state() != InferiorUnrunnable)
+        return;
+
     if (index >= d->m_stackBoundary)
         d->m_qmlEngine->activateFrame(index - d->m_stackBoundary);
     else
@@ -681,6 +684,8 @@ void QmlCppEngine::resetLocation()
         d->m_qmlEngine->resetLocation();
     if (d->m_cppEngine)
         d->m_cppEngine->resetLocation();
+
+    DebuggerEngine::resetLocation();
 }
 
 DebuggerEngine *QmlCppEngine::cppEngine() const
diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp
index 3c35489269e..433e377ebe5 100644
--- a/src/plugins/debugger/stackhandler.cpp
+++ b/src/plugins/debugger/stackhandler.cpp
@@ -197,6 +197,7 @@ void StackHandler::setFrames(const StackFrames &frames, bool canExpand)
     if (m_currentIndex >= m_stackFrames.size())
         m_currentIndex = m_stackFrames.size() - 1;
     reset();
+    emit stackChanged();
 }
 
 const StackFrames &StackHandler::frames() const
diff --git a/src/plugins/debugger/stackhandler.h b/src/plugins/debugger/stackhandler.h
index 89b6c3db86e..548a74ccce3 100644
--- a/src/plugins/debugger/stackhandler.h
+++ b/src/plugins/debugger/stackhandler.h
@@ -85,6 +85,9 @@ public:
     void scheduleResetLocation();
     void resetLocation();
 
+signals:
+    void stackChanged();
+
 private:
     // QAbstractTableModel
     int rowCount(const QModelIndex &parent) const;
-- 
GitLab