fix(view): snapshot-once park guard + correct per-mode undo label
Only capture a track's pre-park snapshot when none exists, so a re-park while already parked no longer overwrites it with hidden-state zeros (leaves vanished after toggling twice). Undo label now names the actual target mode.
This commit is contained in:
+19
-2
@@ -158,7 +158,15 @@ bool applyMode(ViewModeModel& model, const std::string& targetModeId, ReaProject
|
||||
MediaTrack* tr = resolve(handleByGuid, guid);
|
||||
if (!tr) continue; // stale GUID — prune
|
||||
|
||||
model.storeSnapshot(guid, snapshotTrack(tr));
|
||||
// Snapshot ONCE, at the first park. If a snapshot already exists the track is
|
||||
// still parked from a prior apply, and its live flags are the PARKED (hidden)
|
||||
// values — recapturing here would overwrite the true pre-park state with zeros,
|
||||
// so a later restore would restore the track to hidden and it would vanish for
|
||||
// good. Re-applying the park flags to an already-parked track is idempotent and
|
||||
// fine; only the snapshot must not be recaptured. Restore clears the snapshot,
|
||||
// so the next genuine park recaptures fresh state.
|
||||
if (model.snapshot(guid) == nullptr)
|
||||
model.storeSnapshot(guid, snapshotTrack(tr));
|
||||
applyFlags(tr, tp.flags);
|
||||
parkFxOffline(tr);
|
||||
}
|
||||
@@ -191,6 +199,15 @@ bool applyMode(ViewModeModel& model, const std::string& targetModeId, ReaProject
|
||||
SetMediaTrackInfo_Value(tr, "B_SHOWINMIXER", show);
|
||||
}
|
||||
|
||||
// Build the undo label from the ACTUAL target mode's display name, so activating
|
||||
// Arrange doesn't leave an "activate Design view" undo point (and vice versa).
|
||||
// The target is guaranteed registered (checked at entry), so query() is non-null;
|
||||
// fall back to the id defensively if that ever changes.
|
||||
const Mode* targetMode = model.modes().query(targetModeId);
|
||||
const std::string undoLabel =
|
||||
"ReaSampler: activate " +
|
||||
(targetMode ? targetMode->displayName : targetModeId) + " view";
|
||||
|
||||
model.setActiveMode(targetModeId);
|
||||
|
||||
// Force REAPER to rebuild the TCP + MCP so visibility/park changes appear now,
|
||||
@@ -201,7 +218,7 @@ bool applyMode(ViewModeModel& model, const std::string& targetModeId, ReaProject
|
||||
TrackList_AdjustWindows(false);
|
||||
UpdateArrange();
|
||||
|
||||
Undo_EndBlock2(proj, "ReaSampler: apply Design View mode", -1);
|
||||
Undo_EndBlock2(proj, undoLabel.c_str(), -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user