mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Delete UndoCommands when the UndoHistory is destroyed
This commit is contained in:
parent
c04f4976fb
commit
e730b90958
@ -17,6 +17,12 @@ CmdSequence::CmdSequence()
|
||||
{
|
||||
}
|
||||
|
||||
CmdSequence::~CmdSequence()
|
||||
{
|
||||
for (Cmd* cmd : m_cmds)
|
||||
delete cmd;
|
||||
}
|
||||
|
||||
void CmdSequence::add(Cmd* cmd)
|
||||
{
|
||||
m_cmds.push_back(cmd);
|
||||
|
@ -18,6 +18,7 @@ namespace app {
|
||||
class CmdSequence : public Cmd {
|
||||
public:
|
||||
CmdSequence();
|
||||
~CmdSequence();
|
||||
|
||||
void add(Cmd* cmd);
|
||||
|
||||
|
@ -82,11 +82,10 @@ void UndoHistory::clearRedo()
|
||||
|
||||
void UndoHistory::add(UndoCommand* cmd)
|
||||
{
|
||||
UndoState* state = new UndoState;
|
||||
UndoState* state = new UndoState(cmd);
|
||||
state->m_prev = m_last;
|
||||
state->m_next = nullptr;
|
||||
state->m_parent = m_cur;
|
||||
state->m_cmd = cmd;
|
||||
|
||||
if (!m_first)
|
||||
m_first = state;
|
||||
|
@ -8,6 +8,8 @@
|
||||
#define UNDO_UNDO_STATE_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "undo/undo_command.h"
|
||||
|
||||
namespace undo {
|
||||
|
||||
class UndoCommand;
|
||||
@ -18,6 +20,15 @@ namespace undo {
|
||||
class UndoState {
|
||||
friend class UndoHistory;
|
||||
public:
|
||||
UndoState(UndoCommand* cmd)
|
||||
: m_prev(nullptr)
|
||||
, m_next(nullptr)
|
||||
, m_parent(nullptr)
|
||||
, m_cmd(cmd) {
|
||||
}
|
||||
~UndoState() {
|
||||
delete m_cmd;
|
||||
}
|
||||
UndoState* prev() const { return m_prev; }
|
||||
UndoState* next() const { return m_next; }
|
||||
UndoCommand* cmd() const { return m_cmd; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user