From 5318b90d7aff6c974ae9d8966716cf3bbba1272e Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Sat, 13 Nov 2010 14:05:19 +0100 Subject: [PATCH] editor: delete remote keys when creating new document --- editor/editor.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/editor/editor.cpp b/editor/editor.cpp index 19a92c4..c35da56 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -195,16 +195,17 @@ std::wstring fileName; void fileNew() { // document.purgeUnusedTracks(); - for (size_t i = 0; i < document.num_tracks; ++i) - { + SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand(); + for (size_t i = 0; i < document.num_tracks; ++i) { sync_track *t = document.tracks[i]; - free(t->keys); - t->keys = NULL; - t->num_keys = 0; + for (size_t j = 0; j < t->num_keys; ++j) + multiCmd->addCommand(new SyncDocument::DeleteCommand(i, t->keys[j].row)); } + document.exec(multiCmd); + setWindowFileName(L"Untitled"); fileName.clear(); - + document.clearUndoStack(); document.clearRedoStack(); }