From a31bd6eb0da59d946c011d5bad1abb783d36825a Mon Sep 17 00:00:00 2001 From: joshua Date: Thu, 27 Jan 2022 20:00:46 +0100 Subject: [PATCH] Minor improvement about undo/redo for bridge creation When a new bridge is created, an undo command is created for that. When undo the action and redo it, all terminals are bridged to a new bridge instead of the first one, who continue to exist but is now empty and 'lost' because he will never be reused. In addition of that, if a more recent undo command (we call it undo2) use this bridge, there is a unknown behavior, because the status of the bridge is not the same as when the undo2 was created. --- .../UndoCommand/bridgeterminalscommand.cpp | 10 ++++++++-- .../TerminalStrip/UndoCommand/bridgeterminalscommand.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.cpp b/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.cpp index 425adc29c..1a1eec5ba 100644 --- a/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.cpp +++ b/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.cpp @@ -36,8 +36,14 @@ void BridgeTerminalsCommand::undo() void BridgeTerminalsCommand::redo() { - if (m_strip) { - m_strip->setBridge(m_real_terminal_vector); + if (m_strip) + { + if (m_bridge) { + m_strip->setBridge(m_bridge, m_real_terminal_vector); + } else { + m_strip->setBridge(m_real_terminal_vector); + m_bridge = m_strip->isBridged(m_real_terminal_vector.first()); + } } } diff --git a/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.h b/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.h index ec1fcfef4..a642a869e 100644 --- a/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.h +++ b/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.h @@ -42,6 +42,7 @@ class BridgeTerminalsCommand : public QUndoCommand private: QPointer m_strip; QVector> m_real_terminal_vector; + QSharedPointer m_bridge; };