Reconcile orphaned Design View snapshots on track delete

Add ViewModeModel::reconcile(liveGuids) to prune snapshots of deleted
tracks; wire it into applyMode before planning. Keep membership so
undo-delete (same GUID) preserves the Design tag.
This commit is contained in:
2026-07-23 13:27:42 -04:00
parent dcbe5d7bdc
commit f9af111c7a
4 changed files with 141 additions and 0 deletions
+10
View File
@@ -144,6 +144,16 @@ bool applyMode(ViewModeModel& model, const std::string& targetModeId, ReaProject
std::vector<TrackFolderEntry> entries = readFolderEntries(proj, handleByGuid);
FolderTree tree = buildFolderTree(entries);
// Reconcile orphaned model state BEFORE planning: prune snapshots whose track was
// deleted from the project (its GUID no longer appears in the live enumeration).
// handleByGuid holds every currently-enumerated track GUID, so its keys are the
// authoritative live set. Membership is intentionally NOT pruned (undo-delete
// restores the same GUID — see ViewModeModel::reconcile). Because reapply-on-load
// routes through applyMode, this also reconciles on project open.
std::set<std::string> liveGuids;
for (const auto& kv : handleByGuid) liveGuids.insert(kv.first);
model.reconcile(liveGuids);
TogglePlan plan = model.planToggle(tree, targetModeId);
Undo_BeginBlock2(proj);