Add TX_TRACE() in app/transaction.cpp for debugging purposes

This commit is contained in:
David Capello 2018-07-04 13:38:20 -03:00
parent 6b1c884eb5
commit 68bf959b80

View File

@ -16,6 +16,8 @@
#include "app/document_undo.h" #include "app/document_undo.h"
#include "doc/sprite.h" #include "doc/sprite.h"
#define TX_TRACE(...)
namespace app { namespace app {
using namespace doc; using namespace doc;
@ -24,6 +26,11 @@ Transaction::Transaction(Context* ctx, const std::string& label, Modification mo
: m_ctx(ctx) : m_ctx(ctx)
, m_cmds(NULL) , m_cmds(NULL)
{ {
TX_TRACE("TX: Start <%s> (%s)\n",
label.c_str(),
modification == ModifyDocument ? "modifies document":
"doesn't modify document");
m_undo = m_ctx->activeDocument()->undoHistory(); m_undo = m_ctx->activeDocument()->undoHistory();
m_cmds = new CmdTransaction(label, m_cmds = new CmdTransaction(label,
modification == Modification::ModifyDocument, modification == Modification::ModifyDocument,
@ -62,6 +69,7 @@ void Transaction::setNewDocumentRange(const DocumentRange& range)
void Transaction::commit() void Transaction::commit()
{ {
ASSERT(m_cmds); ASSERT(m_cmds);
TX_TRACE("TX: Commit <%s>\n", m_cmds->label().c_str());
m_cmds->commit(); m_cmds->commit();
m_undo->add(m_cmds); m_undo->add(m_cmds);
@ -71,6 +79,7 @@ void Transaction::commit()
void Transaction::rollback() void Transaction::rollback()
{ {
ASSERT(m_cmds); ASSERT(m_cmds);
TX_TRACE("TX: Rollback <%s>\n", m_cmds->label().c_str());
m_cmds->undo(); m_cmds->undo();