summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2015-02-07 23:33:09 +1100
committernick_m <mainsbridge@gmail.com>2015-02-07 23:33:09 +1100
commitb1dafe9a3173e1c0dd437e7b895e09993f37ba9e (patch)
tree1801c3d728650cf311378fcf1c8ba946e93a11c7 /gtk2_ardour
parentae09d7132de0af856492f3ae69515ecebb6117e6 (diff)
Properly deallocate memory when clearing selection_op_history and
before XMLNode*s. Improve some comments.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc27
1 files changed, 22 insertions, 5 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index c8b3437662..a66972a7e9 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -3326,7 +3326,12 @@ Editor::begin_selection_op_history ()
{
selection_op_cmd_depth = 0;
selection_op_history_it = 0;
- selection_op_history.clear();
+
+ while(!selection_op_history.empty()) {
+ delete selection_op_history.front();
+ selection_op_history.pop_front();
+ }
+
selection_undo_action->set_sensitive (false);
selection_redo_action->set_sensitive (false);
selection_op_history.push_front (&_selection_memento->get_state ());
@@ -3349,10 +3354,19 @@ Editor::commit_reversible_selection_op ()
if (selection_op_cmd_depth == 1) {
if (selection_op_history_it > 0 && selection_op_history_it < selection_op_history.size()) {
- /* the user has undone some selection ops and then made a new one */
+ /**
+ The user has undone some selection ops and then made a new one,
+ making anything earlier in the list invalid.
+ */
+
list<XMLNode *>::iterator it = selection_op_history.begin();
- advance (it, selection_op_history_it);
- selection_op_history.erase (selection_op_history.begin(), it);
+ list<XMLNode *>::iterator e_it = it;
+ advance (e_it, selection_op_history_it);
+
+ for ( ; it != e_it; ++it) {
+ delete *it;
+ }
+ selection_op_history.erase (selection_op_history.begin(), e_it);
}
selection_op_history.push_front (&_selection_memento->get_state ());
@@ -3432,7 +3446,10 @@ void
Editor::abort_reversible_command ()
{
if (_session) {
- before.clear();
+ while(!before.empty()) {
+ delete before.front();
+ before.pop_front();
+ }
_session->abort_reversible_command ();
}
}