[studio,nostalgia/studio] Make executing UndoCommands report errors
All checks were successful
Build / build (push) Successful in 2m31s

This commit is contained in:
2024-05-23 21:50:27 -05:00
parent a1c89906bd
commit c0479604aa
7 changed files with 31 additions and 36 deletions

View File

@@ -131,16 +131,14 @@ class Editor: public studio::BaseEditor {
[[nodiscard]]
UndoStack *undoStack() noexcept final;
void pushCommand(ox::UPtr<UndoCommand> &&cmd) noexcept;
ox::Error pushCommand(ox::UPtr<UndoCommand> &&cmd) noexcept;
template<typename UC, typename ...Args>
bool pushCommand(Args&&... args) noexcept {
ox::Error pushCommand(Args&&... args) noexcept {
try {
m_undoStack.push(ox::make_unique<UC>(ox::forward<Args>(args)...));
return true;
return m_undoStack.push(ox::make_unique<UC>(ox::forward<Args>(args)...));
} catch (ox::Exception const&ex) {
oxLogError(ex.toError());
return false;
return ex.toError();
}
}

View File

@@ -19,11 +19,11 @@ class UndoStack {
std::size_t m_stackIdx = 0;
public:
void push(ox::UPtr<UndoCommand> &&cmd) noexcept;
ox::Error push(ox::UPtr<UndoCommand> &&cmd) noexcept;
void redo() noexcept;
ox::Error redo() noexcept;
void undo() noexcept;
ox::Error undo() noexcept;
[[nodiscard]]
constexpr bool canRedo() const noexcept {