Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VST3 wrapper in Ardour #283

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/detail/vst3/plugview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

WrappedView::WrappedView(const clap_plugin_t* plugin, const clap_plugin_gui_t* gui,
std::function<void()> onReleaseAdditionalReferences,
std::function<void()> onDestroy, std::function<void()> onRunLoopAvailable)
std::function<void(bool)> onDestroy, std::function<void()> onRunLoopAvailable)
: IPlugView()
, FObject()
, _plugin(plugin)
, _extgui(gui)
, _onReleaseAdditionalReferences(onReleaseAdditionalReferences)
, _onDestroy(onDestroy)
, _onRunLoopAvailable(onRunLoopAvailable)
, _onDestroy(onDestroy)
{
}

Expand Down Expand Up @@ -49,11 +49,18 @@ void WrappedView::drop_ui()
_attached = false;
if (_onDestroy)
{
_onDestroy();
_onDestroy(true);
}
_extgui->destroy(_plugin);
_created = false;
}
else
{
if (_onDestroy)
{
_onDestroy(false);
}
}
}

void WrappedView::releaseAdditionalReferences()
Expand Down
6 changes: 3 additions & 3 deletions src/detail/vst3/plugview.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class WrappedView : public Steinberg::IPlugView, public Steinberg::FObject
{
public:
WrappedView(const clap_plugin_t* plugin, const clap_plugin_gui_t* gui,
std::function<void()> onReleaseAdditionalReferences, std::function<void()> onDestroy,
std::function<void()> onReleaseAdditionalReferences, std::function<void(bool)> onDestroy,
std::function<void()> onRunLoopAvailable);
~WrappedView();

Expand Down Expand Up @@ -94,8 +94,8 @@ class WrappedView : public Steinberg::IPlugView, public Steinberg::FObject
void releaseAdditionalReferences();
const clap_plugin_t* _plugin = nullptr;
const clap_plugin_gui_t* _extgui = nullptr;
std::function<void()> _onReleaseAdditionalReferences = nullptr, _onDestroy = nullptr,
_onRunLoopAvailable = nullptr;
std::function<void()> _onReleaseAdditionalReferences = nullptr, _onRunLoopAvailable = nullptr;
std::function<void(bool)> _onDestroy = nullptr;
clap_window_t _window = {nullptr, {nullptr}};
IPlugFrame* _plugFrame = nullptr;
ViewRect _rect = {0, 0, 0, 0};
Expand Down
16 changes: 9 additions & 7 deletions src/wrapasvst3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ tresult PLUGIN_API ClapAsVst3::initialize(FUnknown* context)

tresult PLUGIN_API ClapAsVst3::terminate()
{
clearContextMenu();
vst3HostApplication.reset();

if (_plugin)
Expand Down Expand Up @@ -260,16 +259,19 @@ IPlugView* PLUGIN_API ClapAsVst3::createView(FIDString /*name*/)
{
_wrappedview = new WrappedView(
_plugin->_plugin, _plugin->_ext._gui, [this]() { clearContextMenu(); },
[this]()
[this](bool everCreated)
{
if (everCreated)
{
#if LIN
// the host calls the destructor, the wrapper just removes its pointer
detachTimers(_wrappedview->getRunLoop());
detachPosixFD(_wrappedview->getRunLoop());
_iRunLoop = nullptr;
// the host calls the destructor, the wrapper just removes its pointer
detachTimers(_wrappedview->getRunLoop());
detachPosixFD(_wrappedview->getRunLoop());
_iRunLoop = nullptr;
#endif

clearContextMenu();
clearContextMenu();
}
this->_wrappedview = nullptr;
},
[this]()
Expand Down
Loading