From 2cf5ea11fdbc247d2233d99d16934b9ba1c6fe5a Mon Sep 17 00:00:00 2001 From: joshua Date: Mon, 5 Apr 2021 19:59:06 +0200 Subject: [PATCH] Fix : undo code is executed in redo function and vice versa Need to sleep ? --- .../UndoCommand/addterminalstripcommand.cpp | 12 ++++++------ .../UndoCommand/addterminalstripcommand.h | 2 +- sources/qetproject.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sources/TerminalStrip/UndoCommand/addterminalstripcommand.cpp b/sources/TerminalStrip/UndoCommand/addterminalstripcommand.cpp index fc88b41c6..df0ae0875 100644 --- a/sources/TerminalStrip/UndoCommand/addterminalstripcommand.cpp +++ b/sources/TerminalStrip/UndoCommand/addterminalstripcommand.cpp @@ -38,13 +38,13 @@ AddTerminalStripCommand::~AddTerminalStripCommand() {} void AddTerminalStripCommand::undo() { - if (m_project && m_strip) { - m_project->addTerminalStrip(m_strip); - } + if (m_project && m_strip) { + m_project->removeTerminalStrip(m_strip); + } } void AddTerminalStripCommand::redo() { - if (m_project && m_strip) { - m_project->removeTerminalStrip(m_strip); - } + if (m_project && m_strip) { + m_project->addTerminalStrip(m_strip); + } } diff --git a/sources/TerminalStrip/UndoCommand/addterminalstripcommand.h b/sources/TerminalStrip/UndoCommand/addterminalstripcommand.h index 218e45599..495f92c3d 100644 --- a/sources/TerminalStrip/UndoCommand/addterminalstripcommand.h +++ b/sources/TerminalStrip/UndoCommand/addterminalstripcommand.h @@ -27,7 +27,7 @@ class QETProject; class AddTerminalStripCommand : public QUndoCommand { public: - AddTerminalStripCommand(TerminalStrip *strip, QETProject *project, QUndoCommand *parent); + AddTerminalStripCommand(TerminalStrip *strip, QETProject *project, QUndoCommand *parent = nullptr); ~AddTerminalStripCommand() override; void undo() override; diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index 8b9ab3cb2..a32414e6e 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -1857,7 +1857,7 @@ bool QETProject::addTerminalStrip(TerminalStrip *strip) if (strip->parent() != this) return false; - if (!m_terminal_strip_vector.contains(strip)) + if (m_terminal_strip_vector.contains(strip)) return true; m_terminal_strip_vector.append(strip);