From 9e6435ff145ed7c99312e0d51d9dd23a1a8c3997 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 25 Feb 2020 21:25:10 +0100 Subject: Fix mem-leak, Playlist/Region SessionHandleRef When a playlist is deleted and drops_references(), any undo/redo StatefulDiffCommand referncing playlist invoke Destructible::drop_references() of the Command. This leads to command_death(). As opposed to UndoTransaction::clear() the StatefulDiffCommand was not destroyed. In case of playlists StatefulDiffCommand::_changes contains PBD::SequenceProperty > > and shared pointer reference of the playlist regions were kept indefinitely. This fixes the following scenario: New session, import an file, delete the created track, clean up unused sources (delete unused playlists)[, quit]. A reference to the imported region was kept, because of the playlist's undo command (insert region). Yet the source file was deleted. PS. Most playlist changes are accompanied by GUI zoom/selection MementoCommands. Those are currently never directly dropped. command_death() leaves those in place. --- libs/pbd/undo.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libs/pbd') diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc index 0c1528aedb..da35bc50ec 100644 --- a/libs/pbd/undo.cc +++ b/libs/pbd/undo.cc @@ -93,7 +93,12 @@ UndoTransaction::add_command (Command* const cmd) void UndoTransaction::remove_command (Command* const action) { - actions.remove (action); + list::iterator i =std::find (actions.begin (), actions.end (), action); + if (i == actions.end ()) { + return; + } + actions.erase (i); + delete action; } bool -- cgit v1.2.3