Also drop Sync requirement for editor handles
This commit is contained in:
parent
a2a52e0ff1
commit
375262aaa3
|
@ -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
|
||||
|
|
|
@ -132,7 +132,7 @@ where
|
|||
&self,
|
||||
parent: ParentWindowHandle,
|
||||
context: Arc<dyn GuiContext>,
|
||||
) -> Box<dyn std::any::Any + Send + Sync> {
|
||||
) -> Box<dyn std::any::Any + Send> {
|
||||
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) {
|
||||
|
|
|
@ -299,7 +299,7 @@ impl<E: IcedEditor> Editor for IcedEditorWrapper<E> {
|
|||
&self,
|
||||
parent: ParentWindowHandle,
|
||||
context: Arc<dyn GuiContext>,
|
||||
) -> Box<dyn std::any::Any + Send + Sync> {
|
||||
) -> Box<dyn std::any::Any + Send> {
|
||||
let (unscaled_width, unscaled_height) = self.iced_state.size();
|
||||
let scaling_factor = self.scaling_factor.load();
|
||||
|
||||
|
@ -389,7 +389,6 @@ struct IcedEditorHandle<Message: 'static + Send> {
|
|||
/// The window handle enum stored within 'WindowHandle' contains raw pointers. Is there a way around
|
||||
/// having this requirement?
|
||||
unsafe impl<Message: Send> Send for IcedEditorHandle<Message> {}
|
||||
unsafe impl<Message: Send> Sync for IcedEditorHandle<Message> {}
|
||||
|
||||
impl<Message: Send> Drop for IcedEditorHandle<Message> {
|
||||
fn drop(&mut self) {
|
||||
|
|
|
@ -174,7 +174,7 @@ impl Editor for ViziaEditor {
|
|||
&self,
|
||||
parent: ParentWindowHandle,
|
||||
context: Arc<dyn GuiContext>,
|
||||
) -> Box<dyn std::any::Any + Send + Sync> {
|
||||
) -> Box<dyn std::any::Any + Send> {
|
||||
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) {
|
||||
|
|
|
@ -282,7 +282,7 @@ pub trait Editor: Send {
|
|||
&self,
|
||||
parent: ParentWindowHandle,
|
||||
context: Arc<dyn GuiContext>,
|
||||
) -> Box<dyn Any + Send + Sync>;
|
||||
) -> Box<dyn Any + Send>;
|
||||
|
||||
/// 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
|
||||
|
|
|
@ -115,7 +115,7 @@ pub struct Wrapper<P: ClapPlugin> {
|
|||
editor: Option<Mutex<Box<dyn Editor>>>,
|
||||
/// A handle for the currently active editor instance. The plugin should implement `Drop` on
|
||||
/// this handle for its closing behavior.
|
||||
editor_handle: RwLock<Option<Box<dyn Any + Send + Sync>>>,
|
||||
editor_handle: Mutex<Option<Box<dyn Any + Send>>>,
|
||||
/// 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<P: ClapPlugin> Wrapper<P> {
|
|||
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<P: ClapPlugin> Wrapper<P> {
|
|||
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<P: ClapPlugin> Wrapper<P> {
|
|||
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<P: ClapPlugin> Wrapper<P> {
|
|||
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 {
|
||||
|
|
Loading…
Reference in a new issue