From 5c1d9b4a844c93e74459e38f76db336716306801 Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Fri, 27 Oct 2023 16:19:37 +0200 Subject: [PATCH] Make plug-in scanning faster by preventing to load all kinds of stuff when scanning plug-in --- main/src/infrastructure/plugin/realearn_plugin.rs | 13 +++++++++++++ .../plugin/realearn_plugin_parameters.rs | 6 ------ main/src/infrastructure/ui/main_panel.rs | 6 ------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/main/src/infrastructure/plugin/realearn_plugin.rs b/main/src/infrastructure/plugin/realearn_plugin.rs index d60df5be2..1f0856a95 100644 --- a/main/src/infrastructure/plugin/realearn_plugin.rs +++ b/main/src/infrastructure/plugin/realearn_plugin.rs @@ -218,6 +218,9 @@ impl Plugin for RealearnPlugin { fn init(&mut self) { firewall(|| { + if self.reaper_is_scanning_plugins() { + return; + } self._reaper_guard = Some(self.ensure_reaper_setup()); self.schedule_session_creation(); }); @@ -225,6 +228,9 @@ impl Plugin for RealearnPlugin { fn get_editor(&mut self) -> Option> { firewall(|| { + if self.reaper_is_scanning_plugins() { + return None; + } let boxed: Box = Box::new(RealearnEditor::new(self.main_panel.clone())); Some(boxed) }) @@ -355,6 +361,13 @@ impl Plugin for RealearnPlugin { } impl RealearnPlugin { + fn reaper_is_scanning_plugins(&self) -> bool { + // REAPER uses version "0" to indicate that this is only the plug-in scanning + // process. + let (version, _, _) = self.host.get_info(); + version == 0 + } + /// Should be called in real-time thread only. fn is_now_playing(&self) -> bool { use vst::api::TimeInfoFlags; diff --git a/main/src/infrastructure/plugin/realearn_plugin_parameters.rs b/main/src/infrastructure/plugin/realearn_plugin_parameters.rs index b5ed496b7..60e636117 100644 --- a/main/src/infrastructure/plugin/realearn_plugin_parameters.rs +++ b/main/src/infrastructure/plugin/realearn_plugin_parameters.rs @@ -148,12 +148,6 @@ impl RealearnPluginParameters { } } -impl Drop for RealearnPluginParameters { - fn drop(&mut self) { - debug!(Reaper::get().logger(), "Dropping plug-in parameters..."); - } -} - /// This will be returned if ReaLearn cannot return reasonable bank data yet. const NOT_READY_YET: &str = "not-ready-yet"; diff --git a/main/src/infrastructure/ui/main_panel.rs b/main/src/infrastructure/ui/main_panel.rs index 85afbf1f9..c2b02ea85 100644 --- a/main/src/infrastructure/ui/main_panel.rs +++ b/main/src/infrastructure/ui/main_panel.rs @@ -573,9 +573,3 @@ impl SessionUi for Weak { fn upgrade_panel(panel: &Weak) -> Rc { panel.upgrade().expect("main panel not existing anymore") } - -impl Drop for MainPanel { - fn drop(&mut self) { - debug!(Reaper::get().logger(), "Dropping main panel..."); - } -}