From bbbfadb8328626dec97dd149804848c6c24c36a5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 6 Oct 2021 21:35:08 +0200 Subject: [PATCH] VST3: initialize controller even if it is-a component --- libs/ardour/vst3_plugin.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index 6f66839ad4..ed2f3ce5b3 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -1056,23 +1056,29 @@ VST3PI::VST3PI (boost::shared_ptr m, std::string uniqu throw failed_constructor (); } - if (_component->initialize (HostApplication::getHostContext ()) != kResultOk) { + if (!_component || _component->initialize (HostApplication::getHostContext ()) != kResultOk) { throw failed_constructor (); } _controller = FUnknownPtr (_component); + if (!_controller) { TUID controllerCID; if (_component->getControllerClassId (controllerCID) == kResultTrue) { if (factory->createInstance (controllerCID, Vst::IEditController::iid, (void**)&_controller) != kResultTrue) { - throw failed_constructor (); - } - if (_controller && (_controller->initialize (HostApplication::getHostContext ()) != kResultOk)) { + _component->terminate (); + _component->release (); throw failed_constructor (); } } } + if (_controller && (_controller->initialize (HostApplication::getHostContext ()) != kResultOk)) { + _component->terminate (); + _component->release (); + throw failed_constructor (); + } + if (!_controller) { _component->terminate (); _component->release ();