From f58f5bef55a5aa19abf2db765bdca21b414f8872 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 31 May 2023 15:39:00 +0200 Subject: [PATCH] Remove region from playlist when the source is destroyed This fixes the following issue: 1. Import a file to a new track 2. Delete the track 3. Editor Source list: select imported file, -> Remove the selected source -> Yes, remove the Regions and Sources The Track and Region no longer exist in the Editor, only the playlist still exists! The sources to be deleted are found when iterating over whole-file regions in `EditorSources::remove_selected_sources`. Also RegionFactory::get_regions_using_source correctly returns regions, _editor->remove_regions does nothing since there is no RegionView for the given region(s). This then cashes in ``` libs/ardour/playlist.cc:2400: virtual XMLNode& ARDOUR::Playlist::state(bool) const: Assertion `r->sources ().size () > 0 && r->master_sources ().size () > 0' failed. ``` --- libs/ardour/playlist.cc | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 4897ab5640..b273719c5e 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -665,24 +665,14 @@ Playlist::clear_pending () void Playlist::region_going_away (std::weak_ptr region) { + printf ("Playlist::region_going_away..\n"); if (_session.deletion_in_progress ()) { return; } - /* Before a region can be destroyed it must already - * be removed from all playlists. - */ -#ifndef NDEBUG std::shared_ptr r = region.lock(); - if (!r) { - return; + if (r) { + remove_region (r); } - assert (find_region (r->id ())); - { - RegionReadLock rlock (this); - assert (all_regions.find (r) != all_regions.end()); - } -#endif - //remove_region (r); } /*************************************************************