mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-22 09:40:52 +01:00
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.
This commit is contained in:
@@ -36,8 +36,14 @@ void BridgeTerminalsCommand::undo()
|
|||||||
|
|
||||||
void BridgeTerminalsCommand::redo()
|
void BridgeTerminalsCommand::redo()
|
||||||
{
|
{
|
||||||
if (m_strip) {
|
if (m_strip)
|
||||||
m_strip->setBridge(m_real_terminal_vector);
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class BridgeTerminalsCommand : public QUndoCommand
|
|||||||
private:
|
private:
|
||||||
QPointer<TerminalStrip> m_strip;
|
QPointer<TerminalStrip> m_strip;
|
||||||
QVector<QSharedPointer<RealTerminal>> m_real_terminal_vector;
|
QVector<QSharedPointer<RealTerminal>> m_real_terminal_vector;
|
||||||
|
QSharedPointer<TerminalStripBridge> m_bridge;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user