Skip to content

Commit 12be7c5

Browse files
committed
pass &ComWrapper<Self> to WrapperView::request_resize
1 parent 0db4d62 commit 12be7c5

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/wrapper/vst3/inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ impl<P: Vst3Plugin> MainThreadExecutor<Task<P>> for WrapperInner<P> {
647647
Task::RequestResize => match &*self.plug_view.read() {
648648
Some(plug_view) => unsafe {
649649
nih_debug_assert!(is_gui_thread);
650-
let success = plug_view.request_resize();
650+
let success = WrapperView::request_resize(plug_view);
651651
nih_debug_assert!(success, "Failed requesting a window resize");
652652
},
653653
None => nih_debug_assert_failure!("Can't resize a closed editor"),

src/wrapper/vst3/view.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use vst3::Steinberg::{
1414
IPlugViewContentScaleSupportTrait, IPlugViewContentScaleSupport_::ScaleFactor, IPlugViewTrait,
1515
ViewRect,
1616
};
17-
use vst3::{Class, ComPtr, ComRef};
17+
use vst3::{Class, ComPtr, ComRef, ComWrapper};
1818

1919
use super::inner::{Task, WrapperInner};
2020
use crate::plugin::vst3::Vst3Plugin;
@@ -125,9 +125,9 @@ impl<P: Vst3Plugin> WrapperView<P> {
125125
///
126126
/// May cause memory corruption in Linux REAPER when called from outside of the `IRunLoop`.
127127
#[must_use]
128-
pub unsafe fn request_resize(&self) -> bool {
128+
pub unsafe fn request_resize(this: &ComWrapper<Self>) -> bool {
129129
// Don't do anything if the editor is not open, because that would be strange
130-
if self
130+
if this
131131
.editor_handle
132132
.try_read()
133133
.map(|e| e.is_none())
@@ -136,31 +136,26 @@ impl<P: Vst3Plugin> WrapperView<P> {
136136
return false;
137137
}
138138

139-
match &*self.plug_frame.read() {
139+
match &*this.plug_frame.read() {
140140
Some(plug_frame) => {
141-
let (unscaled_width, unscaled_height) = self.editor.lock().size();
142-
let scaling_factor = self.scaling_factor.load(Ordering::Relaxed);
141+
let (unscaled_width, unscaled_height) = this.editor.lock().size();
142+
let scaling_factor = this.scaling_factor.load(Ordering::Relaxed);
143143
let mut size = ViewRect {
144144
left: 0,
145145
top: 0,
146146
right: (unscaled_width as f32 * scaling_factor).round() as i32,
147147
bottom: (unscaled_height as f32 * scaling_factor).round() as i32,
148148
};
149149

150-
// // The argument types are a bit wonky here because you can't construct a
151-
// // `SharedVstPtr`. This _should_ work however.
152-
// let plug_view: SharedVstPtr<dyn IPlugView> =
153-
// mem::transmute(&self.__iplugviewvptr as *const *const _);
154-
// let result = plug_frame.resize_view(plug_view, &mut size);
150+
let plug_view = this.to_com_ptr::<IPlugView>().unwrap();
151+
let result = plug_frame.resizeView(plug_view.into_raw(), &mut size);
155152

156-
// debug_assert_eq!(
157-
// result, kResultOk,
158-
// "The host denied the resize, we currently don't handle this for VST3 plugins"
159-
// );
153+
debug_assert_eq!(
154+
result, kResultOk,
155+
"The host denied the resize, we currently don't handle this for VST3 plugins"
156+
);
160157

161-
// result == kResultOk
162-
163-
true
158+
result == kResultOk
164159
}
165160
None => false,
166161
}

0 commit comments

Comments
 (0)