From 71ff3a0a86c0f7a5c439e8cdc1609a4dc723a8a6 Mon Sep 17 00:00:00 2001
From: Orgad Shaneh <orgad.shaneh@audiocodes.com>
Date: Wed, 31 Jul 2013 20:46:37 +0300
Subject: [PATCH] Debugger: Clear undo/redo stacks when debugging session is
 finished

Task-number: QTCREATORBUG-7645
Change-Id: I17df03c5765129c21f38df19ea90c04e937a7217
Reviewed-by: hjk <hjk121@nokiamail.com>
---
 src/plugins/debugger/debuggerplugin.cpp |  1 +
 src/plugins/debugger/logwindow.cpp      | 13 +++++++++++++
 src/plugins/debugger/logwindow.h        |  2 ++
 3 files changed, 16 insertions(+)

diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 2495bfca2bf..5460c350333 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -2660,6 +2660,7 @@ void DebuggerPluginPrivate::runControlFinished(DebuggerEngine *engine)
         m_snapshotHandler->activateSnapshot(0);
     }
     action(OperateByInstruction)->setValue(QVariant(false));
+    m_logWindow->clearUndoRedoStacks();
 }
 
 void DebuggerPluginPrivate::remoteCommand(const QStringList &options,
diff --git a/src/plugins/debugger/logwindow.cpp b/src/plugins/debugger/logwindow.cpp
index f54f1c5611d..32e702bc415 100644
--- a/src/plugins/debugger/logwindow.cpp
+++ b/src/plugins/debugger/logwindow.cpp
@@ -198,6 +198,13 @@ public:
         appendPlainText(text);
     }
 
+    void clearUndoRedoStacks()
+    {
+        if (!isUndoRedoEnabled())
+            return;
+        setUndoRedoEnabled(false);
+        setUndoRedoEnabled(true);
+    }
 
 private slots:
     void saveContents();
@@ -527,6 +534,12 @@ QString LogWindow::inputContents() const
     return m_inputText->toPlainText();
 }
 
+void LogWindow::clearUndoRedoStacks()
+{
+    m_inputText->clearUndoRedoStacks();
+    m_combinedText->clearUndoRedoStacks();
+}
+
 QString LogWindow::logTimeStamp()
 {
     // Cache the last log time entry by ms. If time progresses,
diff --git a/src/plugins/debugger/logwindow.h b/src/plugins/debugger/logwindow.h
index cabc729c8c3..f01ac447199 100644
--- a/src/plugins/debugger/logwindow.h
+++ b/src/plugins/debugger/logwindow.h
@@ -61,6 +61,8 @@ public:
     QString combinedContents() const;
     QString inputContents() const;
 
+    void clearUndoRedoStacks();
+
     static QString logTimeStamp();
 
     static bool writeLogContents(const QPlainTextEdit *editor, QWidget *parent = 0);
-- 
GitLab