mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-24 06:07:29 +01:00
tiny but massively important bug fix that actually deletes commands when they are removed from the unod history
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4240 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b6948a1bfa
commit
bee3c7a419
4 changed files with 47 additions and 11 deletions
|
|
@ -20,7 +20,6 @@
|
|||
#include <pbd/command.h>
|
||||
#include <pbd/xml++.h>
|
||||
|
||||
|
||||
XMLNode &Command::get_state()
|
||||
{
|
||||
XMLNode *node = new XMLNode ("Command");
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
class Command : public PBD::StatefulDestructible
|
||||
{
|
||||
public:
|
||||
virtual ~Command() {}
|
||||
virtual ~Command() { /* NOTE: derived classes must call drop_references() */ }
|
||||
virtual void operator() () = 0;
|
||||
virtual void undo() = 0;
|
||||
virtual void redo() { (*this)(); }
|
||||
|
|
|
|||
|
|
@ -93,17 +93,24 @@ class UndoHistory : public sigc::trackable
|
|||
void clear_undo ();
|
||||
void clear_redo ();
|
||||
|
||||
/* returns all or part of the history.
|
||||
If depth==0 it returns just the top
|
||||
node. If depth<0, it returns everything.
|
||||
If depth>0, it returns state for that
|
||||
many elements of the history, or
|
||||
the full history, whichever is smaller.
|
||||
*/
|
||||
|
||||
XMLNode &get_state(int32_t depth = 0);
|
||||
void save_state();
|
||||
|
||||
void set_depth (int32_t);
|
||||
int32_t get_depth() const { return _depth; }
|
||||
void set_depth (uint32_t);
|
||||
|
||||
sigc::signal<void> Changed;
|
||||
|
||||
private:
|
||||
bool _clearing;
|
||||
int32_t _depth;
|
||||
uint32_t _depth;
|
||||
std::list<UndoTransaction*> UndoList;
|
||||
std::list<UndoTransaction*> RedoList;
|
||||
|
||||
|
|
|
|||
|
|
@ -153,27 +153,57 @@ UndoHistory::UndoHistory ()
|
|||
}
|
||||
|
||||
void
|
||||
UndoHistory::set_depth (int32_t d)
|
||||
UndoHistory::set_depth (uint32_t d)
|
||||
{
|
||||
UndoTransaction* ut;
|
||||
uint32_t current_depth = UndoList.size();
|
||||
|
||||
_depth = d;
|
||||
|
||||
while (_depth > 0 && UndoList.size() > (uint32_t) _depth) {
|
||||
UndoList.pop_front ();
|
||||
if (d > current_depth) {
|
||||
/* not even transactions to meet request */
|
||||
return;
|
||||
}
|
||||
|
||||
if (_depth > 0) {
|
||||
|
||||
uint32_t cnt = current_depth - d;
|
||||
|
||||
while (cnt--) {
|
||||
ut = UndoList.front();
|
||||
UndoList.pop_front ();
|
||||
delete ut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UndoHistory::add (UndoTransaction* const ut)
|
||||
{
|
||||
uint32_t current_depth = UndoList.size();
|
||||
|
||||
ut->GoingAway.connect (bind (mem_fun (*this, &UndoHistory::remove), ut));
|
||||
|
||||
while (_depth > 0 && UndoList.size() > (uint32_t) _depth) {
|
||||
UndoList.pop_front ();
|
||||
/* if the current undo history is larger than or equal to the currently
|
||||
requested depth, then pop off at least 1 element to make space
|
||||
at the back for new one.
|
||||
*/
|
||||
|
||||
if ((_depth > 0) && current_depth && (current_depth >= _depth)) {
|
||||
|
||||
uint32_t cnt = 1 + (current_depth - _depth);
|
||||
|
||||
while (cnt--) {
|
||||
UndoTransaction* ut;
|
||||
ut = UndoList.front ();
|
||||
UndoList.pop_front ();
|
||||
delete ut;
|
||||
}
|
||||
}
|
||||
|
||||
UndoList.push_back (ut);
|
||||
|
||||
/* we are now owners of the transaction */
|
||||
/* we are now owners of the transaction and must delete it when finished with it */
|
||||
|
||||
Changed (); /* EMIT SIGNAL */
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue