Add undo history related debug output for debugging Undo/Redo issues

This commit is contained in:
Tim Mayberry 2015-08-19 13:45:01 +10:00
parent 463cf1cf9c
commit b4e13cbbb7
2 changed files with 39 additions and 4 deletions

View File

@ -813,10 +813,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
void abort_reversible_command ();
void commit_reversible_command (Command* cmd = 0);
void add_command (Command *const cmd) {
assert (_current_trans);
_current_trans->add_command (cmd);
}
void add_command (Command *const cmd);
/** @return The list of operations that are currently in progress */
std::list<GQuark> const & current_operations () {

View File

@ -66,6 +66,7 @@
#include "pbd/boost_debug.h"
#include "pbd/basename.h"
#include "pbd/controllable_descriptor.h"
#include "pbd/debug.h"
#include "pbd/enumwriter.h"
#include "pbd/error.h"
#include "pbd/file_utils.h"
@ -129,6 +130,8 @@ using namespace std;
using namespace ARDOUR;
using namespace PBD;
#define DEBUG_UNDO_HISTORY(msg) DEBUG_TRACE (PBD::DEBUG::UndoHistory, string_compose ("%1: %2\n", __LINE__, msg));
void
Session::pre_engine_init (string fullpath)
{
@ -2526,6 +2529,16 @@ Session::add_commands (vector<Command*> const & cmds)
}
}
void
Session::add_command (Command* const cmd)
{
assert (_current_trans);
DEBUG_UNDO_HISTORY (
string_compose ("Current Undo Transaction %1, adding command: %2",
_current_trans->name (),
cmd->name ()));
_current_trans->add_command (cmd);
}
void
Session::begin_reversible_command (const string& name)
{
@ -2545,10 +2558,17 @@ Session::begin_reversible_command (GQuark q)
*/
if (_current_trans == 0) {
DEBUG_UNDO_HISTORY (string_compose (
"Begin Reversible Command, new transaction: %1", g_quark_to_string (q)));
/* start a new transaction */
assert (_current_trans_quarks.empty ());
_current_trans = new UndoTransaction();
_current_trans->set_name (g_quark_to_string (q));
} else {
DEBUG_UNDO_HISTORY (
string_compose ("Begin Reversible Command, current transaction: %1",
_current_trans->name ()));
}
_current_trans_quarks.push_front (q);
@ -2558,6 +2578,8 @@ void
Session::abort_reversible_command ()
{
if (_current_trans != 0) {
DEBUG_UNDO_HISTORY (
string_compose ("Abort Reversible Command: %1", _current_trans->name ()));
_current_trans->clear();
delete _current_trans;
_current_trans = 0;
@ -2574,18 +2596,34 @@ Session::commit_reversible_command (Command *cmd)
struct timeval now;
if (cmd) {
DEBUG_UNDO_HISTORY (
string_compose ("Current Undo Transaction %1, adding command: %2",
_current_trans->name (),
cmd->name ()));
_current_trans->add_command (cmd);
}
DEBUG_UNDO_HISTORY (
string_compose ("Commit Reversible Command, current transaction: %1",
_current_trans->name ()));
_current_trans_quarks.pop_front ();
if (!_current_trans_quarks.empty ()) {
DEBUG_UNDO_HISTORY (
string_compose ("Commit Reversible Command, transaction is not "
"top-level, current transaction: %1",
_current_trans->name ()));
/* the transaction we're committing is not the top-level one */
return;
}
if (_current_trans->empty()) {
/* no commands were added to the transaction, so just get rid of it */
DEBUG_UNDO_HISTORY (
string_compose ("Commit Reversible Command, No commands were "
"added to current transaction: %1",
_current_trans->name ()));
delete _current_trans;
_current_trans = 0;
return;