From 74da2a1c628de4dbce1be645d4760f0a68aa63d6 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 19 Feb 2008 01:18:02 +0000 Subject: [PATCH] fixed pasting and removed a mem-leak --- editor/syncdocument.cpp | 6 ++++++ editor/syncdocument.h | 11 +++++++++++ editor/synctracker2.cpp | 2 +- editor/trackview.cpp | 4 +++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/editor/syncdocument.cpp b/editor/syncdocument.cpp index 62312e8..2070a5c 100644 --- a/editor/syncdocument.cpp +++ b/editor/syncdocument.cpp @@ -1,5 +1,11 @@ #include "syncdocument.h" +SyncDocument::~SyncDocument() +{ + clearUndoStack(); + clearRedoStack(); +} + #import named_guids bool SyncDocument::load(const std::string &fileName) diff --git a/editor/syncdocument.h b/editor/syncdocument.h index 5e6c901..5efc4fe 100644 --- a/editor/syncdocument.h +++ b/editor/syncdocument.h @@ -13,6 +13,7 @@ class SyncDocument : public sync::Data { public: SyncDocument() : sync::Data(), clientPaused(true) {} + ~SyncDocument(); void sendSetKeyCommand(int track, int row, const sync::Track::KeyFrame &key) { @@ -232,6 +233,16 @@ public: return true; } + void clearUndoStack() + { + while (!undoStack.empty()) + { + Command *cmd = undoStack.top(); + undoStack.pop(); + delete cmd; + } + } + void clearRedoStack() { while (!redoStack.empty()) diff --git a/editor/synctracker2.cpp b/editor/synctracker2.cpp index cdfd1d2..d5fe187 100644 --- a/editor/synctracker2.cpp +++ b/editor/synctracker2.cpp @@ -242,7 +242,7 @@ int _tmain(int argc, _TCHAR* argv[]) _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); -// _CrtSetBreakAlloc(137); +// _CrtSetBreakAlloc(254); #endif HINSTANCE hInstance = GetModuleHandle(NULL); diff --git a/editor/trackview.cpp b/editor/trackview.cpp index ab9c305..9db9322 100644 --- a/editor/trackview.cpp +++ b/editor/trackview.cpp @@ -452,7 +452,9 @@ void TrackView::editPaste() struct CopyEntry ce; memcpy(&ce, src, sizeof(CopyEntry)); - SyncDocument::Command *cmd = document->getSetKeyFrameCommand(editTrack + ce.track, editRow + ce.row, ce.keyFrame); + size_t trackIndex = document->getTrackIndexFromPos(editTrack + ce.track); + + SyncDocument::Command *cmd = document->getSetKeyFrameCommand(int(trackIndex), editRow + ce.row, ce.keyFrame); multiCmd->addCommand(cmd); src += sizeof(CopyEntry); }