From 1a54ac262ae41e17a68c4442c27c48c07f854781 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 4 Jan 2022 17:58:40 +0100 Subject: [PATCH] PixelPaint: Make ImageEditor::m_undo_stack a regular value member --- .../Applications/PixelPaint/ImageEditor.cpp | 18 ++++++++---------- Userland/Applications/PixelPaint/ImageEditor.h | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 6cca19abbe..ee65c38f04 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -23,12 +23,10 @@ namespace PixelPaint { ImageEditor::ImageEditor(NonnullRefPtr image) : m_image(move(image)) - , m_undo_stack(make()) , m_selection(*this) { set_focus_policy(GUI::FocusPolicy::StrongFocus); - m_undo_stack = make(); - m_undo_stack->push(make(*m_image)); + m_undo_stack.push(make(*m_image)); m_image->add_client(*this); m_pixel_grid_threshold = (float)Config::read_i32("PixelPaint", "PixelGrid", "Threshold", 15); @@ -45,12 +43,12 @@ ImageEditor::~ImageEditor() void ImageEditor::did_complete_action() { - m_undo_stack->push(make(*m_image)); + m_undo_stack.push(make(*m_image)); } bool ImageEditor::undo() { - if (!m_undo_stack->can_undo()) + if (!m_undo_stack.can_undo()) return false; /* Without this you need to undo twice to actually start undoing stuff. @@ -63,19 +61,19 @@ bool ImageEditor::undo() * This works because UndoStack::undo first decrements the stack pointer and then restores the snapshot, * while UndoStack::redo first restores the snapshot and then increments the stack pointer. */ - m_undo_stack->undo(); - m_undo_stack->undo(); - m_undo_stack->redo(); + m_undo_stack.undo(); + m_undo_stack.undo(); + m_undo_stack.redo(); layers_did_change(); return true; } bool ImageEditor::redo() { - if (!m_undo_stack->can_redo()) + if (!m_undo_stack.can_redo()) return false; - m_undo_stack->redo(); + m_undo_stack.redo(); layers_did_change(); return true; } diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index 3bbaae35c6..125d2ef1db 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -43,7 +43,7 @@ public: bool undo(); bool redo(); - auto& undo_stack() { return *m_undo_stack; } + auto& undo_stack() { return m_undo_stack; } void add_guide(NonnullRefPtr guide) { m_guides.append(guide); } void remove_guide(Guide const& guide) @@ -153,7 +153,7 @@ private: NonnullRefPtr m_image; RefPtr m_active_layer; - OwnPtr m_undo_stack; + GUI::UndoStack m_undo_stack; NonnullRefPtrVector m_guides; bool m_show_guides { true };