1
0
Fork 0

Add debug assertions for Arc strong counts

To make issues like the event loop thing more visible.
This commit is contained in:
Robbert van der Helm 2023-02-23 21:49:09 +01:00
parent 42a7bb37b4
commit 5d497f2de4
2 changed files with 10 additions and 1 deletions

View file

@ -1772,7 +1772,10 @@ impl<P: ClapPlugin> Wrapper<P> {
unsafe extern "C" fn destroy(plugin: *const clap_plugin) { unsafe extern "C" fn destroy(plugin: *const clap_plugin) {
assert!(!plugin.is_null() && !(*plugin).plugin_data.is_null()); assert!(!plugin.is_null() && !(*plugin).plugin_data.is_null());
drop(Arc::from_raw((*plugin).plugin_data as *mut Self)); let this = Arc::from_raw((*plugin).plugin_data as *mut Self);
nih_debug_assert_eq!(Arc::strong_count(&this), 1);
drop(this);
} }
unsafe extern "C" fn activate( unsafe extern "C" fn activate(

View file

@ -60,6 +60,12 @@ impl<P: Vst3Plugin> Wrapper<P> {
} }
} }
impl<P: Vst3Plugin> Drop for Wrapper<P> {
fn drop(&mut self) {
nih_debug_assert_eq!(Arc::strong_count(&self.inner), 1);
}
}
impl<P: Vst3Plugin> IPluginBase for Wrapper<P> { impl<P: Vst3Plugin> IPluginBase for Wrapper<P> {
unsafe fn initialize(&self, _context: *mut c_void) -> tresult { unsafe fn initialize(&self, _context: *mut c_void) -> tresult {
// We currently don't need or allow any initialization logic // We currently don't need or allow any initialization logic