From bbc54873aebeecf10571540963a6fdebebc36ab6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 14 Dec 2020 19:29:53 +0100 Subject: [PATCH] VST3: GUI d'tor re-order We have to call close_view(), which calls IPlugView::removed() before destroying the parent widget. Previously ~VST3PluginUI() was called after the derived class destroyed the owned private `_gui_widget`, `_ns_view` or x11 parent. On windows that may lead to the hwnd of the window becoming invalid before the call to ::removed(). --- gtk2_ardour/vst3_hwnd_plugin_ui.cc | 2 ++ gtk2_ardour/vst3_nsview_plugin_ui.mm | 2 ++ gtk2_ardour/vst3_plugin_ui.cc | 2 -- gtk2_ardour/vst3_x11_plugin_ui.cc | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/vst3_hwnd_plugin_ui.cc b/gtk2_ardour/vst3_hwnd_plugin_ui.cc index 2dd2674239..a9841ab5ab 100644 --- a/gtk2_ardour/vst3_hwnd_plugin_ui.cc +++ b/gtk2_ardour/vst3_hwnd_plugin_ui.cc @@ -54,6 +54,8 @@ VST3HWNDPluginUI::VST3HWNDPluginUI (boost::shared_ptr pi, boost::s VST3HWNDPluginUI::~VST3HWNDPluginUI () { + assert (_view_realized); + _vst3->close_view (); } void diff --git a/gtk2_ardour/vst3_nsview_plugin_ui.mm b/gtk2_ardour/vst3_nsview_plugin_ui.mm index 652bc99f20..4c685e8005 100644 --- a/gtk2_ardour/vst3_nsview_plugin_ui.mm +++ b/gtk2_ardour/vst3_nsview_plugin_ui.mm @@ -91,6 +91,8 @@ VST3NSViewPluginUI::VST3NSViewPluginUI (boost::shared_ptr pi, boos VST3NSViewPluginUI::~VST3NSViewPluginUI () { + assert (_view_realized); + _vst3->close_view (); [_ns_view removeFromSuperview]; [_ns_view release]; } diff --git a/gtk2_ardour/vst3_plugin_ui.cc b/gtk2_ardour/vst3_plugin_ui.cc index e4610c7890..121e25c48f 100644 --- a/gtk2_ardour/vst3_plugin_ui.cc +++ b/gtk2_ardour/vst3_plugin_ui.cc @@ -56,8 +56,6 @@ VST3PluginUI::VST3PluginUI (boost::shared_ptr pi, boost::shared_pt VST3PluginUI::~VST3PluginUI () { - assert (_view_realized); - _vst3->close_view (); } gint diff --git a/gtk2_ardour/vst3_x11_plugin_ui.cc b/gtk2_ardour/vst3_x11_plugin_ui.cc index 0c4e7a7aba..88fc7399cc 100644 --- a/gtk2_ardour/vst3_x11_plugin_ui.cc +++ b/gtk2_ardour/vst3_x11_plugin_ui.cc @@ -190,6 +190,8 @@ VST3X11PluginUI::VST3X11PluginUI (boost::shared_ptr pi, boost::sha VST3X11PluginUI::~VST3X11PluginUI () { + assert (_view_realized); + _vst3->close_view (); } void