[studio] Make UndoCommand::mergeWith take a reference

This commit is contained in:
2024-05-22 02:11:58 -05:00
parent f5a02ce94f
commit 9e9f317c13
5 changed files with 7 additions and 7 deletions

View File

@ -20,7 +20,7 @@ class UndoCommand {
virtual void undo() noexcept = 0;
[[nodiscard]]
virtual int commandId() const noexcept = 0;
virtual bool mergeWith(UndoCommand const*cmd) noexcept;
virtual bool mergeWith(UndoCommand const&cmd) noexcept;
};
}

View File

@ -3,7 +3,7 @@
namespace studio {
bool UndoCommand::mergeWith(UndoCommand const*) noexcept {
bool UndoCommand::mergeWith(UndoCommand const&) noexcept {
return false;
}

View File

@ -13,7 +13,7 @@ void UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
cmd->redo();
redoTriggered.emit(cmd.get());
changeTriggered.emit(cmd.get());
if (m_stack.empty() || !(*m_stack.back().value)->mergeWith(cmd.get())) {
if (m_stack.empty() || !(*m_stack.back().value)->mergeWith(*cmd)) {
m_stack.emplace_back(std::move(cmd));
++m_stackIdx;
}