diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp
index 6a28e4fdc582d7a479cc7e5d7378363d7c86de50..04efb34b3ce666159cdd60b5eddf96d4fd9e8122 100644
--- a/src/plugins/debugger/stackhandler.cpp
+++ b/src/plugins/debugger/stackhandler.cpp
@@ -197,8 +197,10 @@ void StackHandler::setFrames(const StackFrames &frames, bool canExpand)
     m_contentsValid = true;
     m_canExpand = canExpand;
     m_stackFrames = frames;
-    if (m_currentIndex >= m_stackFrames.size())
-        setCurrentIndex(m_stackFrames.size() - 1);
+    if (m_stackFrames.size() >= 0)
+        setCurrentIndex(0);
+    else
+        m_currentIndex = -1;
     reset();
     emit stackChanged();
 }