From 485c5748595b2e614656b2057e51c76aa1d012cf Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Thu, 30 Nov 2023 10:30:10 +0100 Subject: [PATCH] reafluent: Outline unwanted lifetime scenario --- extension/src/lib.rs | 10 ++++++++++ reafluent/src/fx_chain.rs | 2 +- reafluent/src/project.rs | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/extension/src/lib.rs b/extension/src/lib.rs index 6ea351782..d387e85fe 100644 --- a/extension/src/lib.rs +++ b/extension/src/lib.rs @@ -83,6 +83,16 @@ impl HookCommand for HelgoboxExtension { } fn add_and_show_playtime() -> Result<()> { + // Unwanted scenario + let current_project = Reaper::get().current_project(); + let mut project = current_project.resolve().context("project doesn't exist")?; + let track = project + .tracks() + .next() + .context("project doesn't have tracks")?; + project.delete_track(track); + track.guid(); + let instance_id = Reaper::get() .insert_track_at(0, TrackDefaultsBehavior::OmitDefaultEnvAndFx) .normal_fx_chain() diff --git a/reafluent/src/fx_chain.rs b/reafluent/src/fx_chain.rs index f82d33a82..a5c09a379 100644 --- a/reafluent/src/fx_chain.rs +++ b/reafluent/src/fx_chain.rs @@ -31,7 +31,7 @@ impl FxChainDesc { impl<'a> FxChain<'a> { pub fn add_fx_by_name<'b>( - &self, + &mut self, name: impl Into>, behavior: AddFxBehavior, ) -> Result { diff --git a/reafluent/src/project.rs b/reafluent/src/project.rs index d78c3aec1..6166597ae 100644 --- a/reafluent/src/project.rs +++ b/reafluent/src/project.rs @@ -46,6 +46,12 @@ impl<'a> Project<'a> { self.raw } + pub fn delete_track(&mut self, track: Track) { + unsafe { + Reaper::get().medium_reaper().delete_track(track.raw()); + } + } + pub fn tracks( &self, ) -> impl Iterator> + ExactSizeIterator + FusedIterator + DoubleEndedIterator + '_