[studio] Make UndoCommand::mergeWith take a reference
This commit is contained in:
parent
f5a02ce94f
commit
9e9f317c13
@ -124,11 +124,11 @@ UpdateColorCommand::UpdateColorCommand(
|
|||||||
//setObsolete(m_oldColor == m_newColor);
|
//setObsolete(m_oldColor == m_newColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateColorCommand::mergeWith(const UndoCommand *cmd) noexcept {
|
bool UpdateColorCommand::mergeWith(UndoCommand const&cmd) noexcept {
|
||||||
if (cmd->commandId() != static_cast<int>(PaletteEditorCommandId::UpdateColor)) {
|
if (cmd.commandId() != static_cast<int>(PaletteEditorCommandId::UpdateColor)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto ucCmd = static_cast<const UpdateColorCommand*>(cmd);
|
auto ucCmd = static_cast<UpdateColorCommand const*>(&cmd);
|
||||||
if (m_idx != ucCmd->m_idx) {
|
if (m_idx != ucCmd->m_idx) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ class UpdateColorCommand: public studio::UndoCommand {
|
|||||||
~UpdateColorCommand() noexcept override = default;
|
~UpdateColorCommand() noexcept override = default;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool mergeWith(const UndoCommand *cmd) noexcept final;
|
bool mergeWith(const UndoCommand &cmd) noexcept final;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
int commandId() const noexcept final;
|
int commandId() const noexcept final;
|
||||||
|
@ -20,7 +20,7 @@ class UndoCommand {
|
|||||||
virtual void undo() noexcept = 0;
|
virtual void undo() noexcept = 0;
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
virtual int commandId() const noexcept = 0;
|
virtual int commandId() const noexcept = 0;
|
||||||
virtual bool mergeWith(UndoCommand const*cmd) noexcept;
|
virtual bool mergeWith(UndoCommand const&cmd) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
bool UndoCommand::mergeWith(UndoCommand const*) noexcept {
|
bool UndoCommand::mergeWith(UndoCommand const&) noexcept {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ void UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
|
|||||||
cmd->redo();
|
cmd->redo();
|
||||||
redoTriggered.emit(cmd.get());
|
redoTriggered.emit(cmd.get());
|
||||||
changeTriggered.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_stack.emplace_back(std::move(cmd));
|
||||||
++m_stackIdx;
|
++m_stackIdx;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user