OSDN Git Service

debugger: remove a bit of stackview flicker by using the 80 ms timer
authorhjk <qtc-committer@nokia.com>
Fri, 17 Dec 2010 10:30:32 +0000 (11:30 +0100)
committerhjk <qtc-committer@nokia.com>
Fri, 17 Dec 2010 10:59:01 +0000 (11:59 +0100)
src/plugins/debugger/debuggerengine.cpp
src/plugins/debugger/stackhandler.cpp
src/plugins/debugger/stackhandler.h

index ffec231..9d01a63 100644 (file)
@@ -216,7 +216,7 @@ public:
         m_disassemblerAgent(engine),
         m_memoryAgent(engine)
     {
-        connect(&m_locationTimer, SIGNAL(timeout()), SLOT(doRemoveLocationMark()));
+        connect(&m_locationTimer, SIGNAL(timeout()), SLOT(resetLocation()));
     }
 
     ~DebuggerEnginePrivate() {}
@@ -265,16 +265,19 @@ public slots:
         m_runControl->bringApplicationToForeground(m_inferiorPid);
     }
 
-    void removeLocationMark()
+    void scheduleResetLocation()
     {
+        m_stackHandler.scheduleResetLocation();
         m_locationTimer.setSingleShot(true);
         m_locationTimer.start(80);
     }
 
-    void doRemoveLocationMark()
+    void resetLocation()
     {
         m_locationTimer.stop();
         m_locationMark.reset();
+        m_stackHandler.resetLocation();
+        m_disassemblerAgent.resetLocation();
     }
 
 public:
@@ -508,8 +511,8 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
 
 void DebuggerEngine::resetLocation()
 {
-    d->m_disassemblerAgent.resetLocation();
-    d->removeLocationMark();
+    // Do it after some delay to avoid flicker.
+    d->scheduleResetLocation();
 }
 
 void DebuggerEngine::gotoLocation(const Location &loc)
@@ -523,7 +526,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
     //if (m_shuttingDown)
     //    return;
 
-    d->doRemoveLocationMark();
+    d->resetLocation();
 
     const QString file = loc.fileName();
     const int line = loc.lineNumber();
@@ -865,7 +868,7 @@ void DebuggerEnginePrivate::doInterruptInferior()
 void DebuggerEnginePrivate::doShutdownInferior()
 {
     QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
-    m_engine->resetLocation();
+    resetLocation();
     m_targetState = DebuggerFinished;
     m_engine->showMessage(_("CALL: SHUTDOWN INFERIOR"));
     m_engine->shutdownInferior();
@@ -933,7 +936,7 @@ void DebuggerEnginePrivate::doFinishDebugger()
 {
     m_engine->showMessage(_("NOTE: FINISH DEBUGGER"));
     QTC_ASSERT(state() == DebuggerFinished, qDebug() << state());
-    m_engine->resetLocation();
+    resetLocation();
     if (!m_engine->isSlaveEngine()) {
         QTC_ASSERT(m_runControl, return);
         m_runControl->debuggingFinished();
@@ -977,7 +980,7 @@ void DebuggerEngine::notifyEngineSpontaneousShutdown()
 void DebuggerEngine::notifyInferiorExited()
 {
     showMessage(_("NOTE: INFERIOR EXITED"));
-    resetLocation();
+    d->resetLocation();
 
     // This can be issued in almost any state. We assume, though,
     // that at this point of time the inferior is not running anymore,
index b83f499..6a53262 100644 (file)
@@ -52,6 +52,8 @@ StackHandler::StackHandler()
   : m_positionIcon(QIcon(QLatin1String(":/debugger/images/location_16.png"))),
     m_emptyIcon(QIcon(QLatin1String(":/debugger/images/debugger_empty_14.png")))
 {
+    m_resetLocationScheduled = false;
+    m_contentsValid = false;
     m_currentIndex = 0;
     m_canExpand = false;
     connect(debuggerCore()->action(OperateByInstruction), SIGNAL(triggered()),
@@ -110,7 +112,8 @@ QVariant StackHandler::data(const QModelIndex &index, int role) const
 
     if (role == Qt::DecorationRole && index.column() == 0) {
         // Return icon that indicates whether this is the active stack frame
-        return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon;
+        return (m_contentsValid && index.row() == m_currentIndex)
+            ? m_positionIcon : m_emptyIcon;
     }
 
     if (role == Qt::ToolTipRole)
@@ -143,7 +146,8 @@ Qt::ItemFlags StackHandler::flags(const QModelIndex &index) const
     const StackFrame &frame = m_stackFrames.at(index.row());
     const bool isValid = (frame.isUsable() && !frame.function.isEmpty())
         || debuggerCore()->boolSetting(OperateByInstruction);
-    return isValid ? QAbstractTableModel::flags(index) : Qt::ItemFlags(0);
+    return isValid && m_contentsValid
+        ? QAbstractTableModel::flags(index) : Qt::ItemFlags(0);
 }
 
 StackFrame StackHandler::currentFrame() const
@@ -178,6 +182,8 @@ void StackHandler::removeAll()
 
 void StackHandler::setFrames(const StackFrames &frames, bool canExpand)
 {
+    m_resetLocationScheduled = false;
+    m_contentsValid = true;
     m_canExpand = canExpand;
     m_stackFrames = frames;
     if (m_currentIndex >= m_stackFrames.size())
@@ -190,12 +196,18 @@ const StackFrames &StackHandler::frames() const
     return m_stackFrames;
 }
 
-bool StackHandler::isDebuggingDebuggingHelpers() const
+void StackHandler::scheduleResetLocation()
 {
-    for (int i = m_stackFrames.size(); --i >= 0; )
-        if (m_stackFrames.at(i).function.startsWith(QLatin1String("qDumpObjectData")))
-            return true;
-    return false;
+    m_resetLocationScheduled = true;
+    m_contentsValid = false;
+}
+
+void StackHandler::resetLocation()
+{
+    if (m_resetLocationScheduled) {
+        m_resetLocationScheduled = false;
+        reset();
+    }
 }
 
 } // namespace Internal
index b23d0b0..1ecb4ee 100644 (file)
@@ -79,7 +79,9 @@ public:
     // Called from StackHandler after a new stack list has been received
     void removeAll();
     QAbstractItemModel *model() { return this; }
-    bool isDebuggingDebuggingHelpers() const;
+    bool isContentsValid() const { return m_contentsValid; }
+    void scheduleResetLocation();
+    void resetLocation();
 
 private:
     // QAbstractTableModel
@@ -95,6 +97,8 @@ private:
     const QVariant m_positionIcon;
     const QVariant m_emptyIcon;
     bool m_canExpand;
+    bool m_resetLocationScheduled;
+    bool m_contentsValid;
 };
 
 } // namespace Internal