diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 569030c9..c0331f25 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -8,8 +8,9 @@ code then it will not be listed here. ## [2022-10-20] -- `Editor` now only requires `Send` and no longer needs `Sync`. This is not a - breaking change, but it might be worth being aware of. +- `Editor` and the editor handle returned by `Editor::spawn` now only require + `Send` and no longer need `Sync`. This is not a breaking change, but it might + be worth being aware of. - The `create_egui_editor()` function from `nih_plug_egui` now also takes a build closure to apply initialization logic to the egui context. - The `nih_plug::param` module has been renamed to `nih_plug::params`. Code that diff --git a/nih_plug_egui/src/lib.rs b/nih_plug_egui/src/lib.rs index 300ca1aa..b84b9607 100644 --- a/nih_plug_egui/src/lib.rs +++ b/nih_plug_egui/src/lib.rs @@ -132,7 +132,7 @@ where &self, parent: ParentWindowHandle, context: Arc, - ) -> Box { + ) -> Box { let build = self.build.clone(); let update = self.update.clone(); let state = self.user_state.clone(); @@ -213,7 +213,6 @@ struct EguiEditorHandle { /// The window handle enum stored within 'WindowHandle' contains raw pointers. Is there a way around /// having this requirement? unsafe impl Send for EguiEditorHandle {} -unsafe impl Sync for EguiEditorHandle {} impl Drop for EguiEditorHandle { fn drop(&mut self) { diff --git a/nih_plug_iced/src/lib.rs b/nih_plug_iced/src/lib.rs index 202faaff..8de875fc 100644 --- a/nih_plug_iced/src/lib.rs +++ b/nih_plug_iced/src/lib.rs @@ -299,7 +299,7 @@ impl Editor for IcedEditorWrapper { &self, parent: ParentWindowHandle, context: Arc, - ) -> Box { + ) -> Box { let (unscaled_width, unscaled_height) = self.iced_state.size(); let scaling_factor = self.scaling_factor.load(); @@ -389,7 +389,6 @@ struct IcedEditorHandle { /// The window handle enum stored within 'WindowHandle' contains raw pointers. Is there a way around /// having this requirement? unsafe impl Send for IcedEditorHandle {} -unsafe impl Sync for IcedEditorHandle {} impl Drop for IcedEditorHandle { fn drop(&mut self) { diff --git a/nih_plug_vizia/src/lib.rs b/nih_plug_vizia/src/lib.rs index 6638c9e1..a1b48a49 100644 --- a/nih_plug_vizia/src/lib.rs +++ b/nih_plug_vizia/src/lib.rs @@ -174,7 +174,7 @@ impl Editor for ViziaEditor { &self, parent: ParentWindowHandle, context: Arc, - ) -> Box { + ) -> Box { let app = self.app.clone(); let vizia_state = self.vizia_state.clone(); let apply_theming = self.apply_theming; @@ -258,7 +258,6 @@ struct ViziaEditorHandle { /// The window handle enum stored within 'WindowHandle' contains raw pointers. Is there a way around /// having this requirement? unsafe impl Send for ViziaEditorHandle {} -unsafe impl Sync for ViziaEditorHandle {} impl Drop for ViziaEditorHandle { fn drop(&mut self) { diff --git a/src/plugin.rs b/src/plugin.rs index d3b2b294..eba6c1ce 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -282,7 +282,7 @@ pub trait Editor: Send { &self, parent: ParentWindowHandle, context: Arc, - ) -> Box; + ) -> Box; /// Returns the (current) size of the editor in pixels as a `(width, height)` pair. This size /// must be reported in _logical pixels_, i.e. the size before being multiplied by the DPI diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index 10709435..33c0fc8c 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -115,7 +115,7 @@ pub struct Wrapper { editor: Option>>, /// A handle for the currently active editor instance. The plugin should implement `Drop` on /// this handle for its closing behavior. - editor_handle: RwLock>>, + editor_handle: Mutex>>, /// The DPI scaling factor as passed to the [IPlugViewContentScaleSupport::set_scale_factor()] /// function. Defaults to 1.0, and will be kept there on macOS. When reporting and handling size /// the sizes communicated to and from the DAW should be scaled by this factor since NIH-plug's @@ -544,7 +544,7 @@ impl Wrapper

{ plugin: RwLock::new(plugin), params, editor, - editor_handle: RwLock::new(None), + editor_handle: Mutex::new(None), editor_scaling_factor: AtomicF32::new(1.0), is_processing: AtomicBool::new(false), @@ -2645,7 +2645,7 @@ impl Wrapper

{ check_null_ptr!(false, plugin); let wrapper = &*(plugin as *const Self); - let editor_handle = wrapper.editor_handle.read(); + let editor_handle = wrapper.editor_handle.lock(); if editor_handle.is_none() { true } else { @@ -2658,7 +2658,7 @@ impl Wrapper

{ check_null_ptr!((), plugin); let wrapper = &*(plugin as *const Self); - let mut editor_handle = wrapper.editor_handle.write(); + let mut editor_handle = wrapper.editor_handle.lock(); if editor_handle.is_some() { *editor_handle = None; } else { @@ -2764,7 +2764,7 @@ impl Wrapper

{ let window = &*window; let result = { - let mut editor_handle = wrapper.editor_handle.write(); + let mut editor_handle = wrapper.editor_handle.lock(); if editor_handle.is_none() { let api = CStr::from_ptr(window.api); let handle = if api == CLAP_WINDOW_API_X11 {