mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Allow null pointers in IEditController::setComponentHandler
This commit is contained in:
@@ -306,8 +306,13 @@ bool Vst3Logger::log_request(
|
|||||||
const YaEditController::SetComponentHandler& request) {
|
const YaEditController::SetComponentHandler& request) {
|
||||||
return log_request_base(is_host_vst, [&](auto& message) {
|
return log_request_base(is_host_vst, [&](auto& message) {
|
||||||
message << request.instance_id
|
message << request.instance_id
|
||||||
<< ": IEditController::setComponentHandler(handler = "
|
<< ": IEditController::setComponentHandler(handler = ";
|
||||||
"<IComponentHandler*>)";
|
if (request.component_handler_proxy_args) {
|
||||||
|
message << "<IComponentHandler*>";
|
||||||
|
} else {
|
||||||
|
message << "<nullptr>";
|
||||||
|
}
|
||||||
|
message << ")";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -344,12 +344,19 @@ class YaEditController : public Steinberg::Vst::IEditController {
|
|||||||
|
|
||||||
native_size_t instance_id;
|
native_size_t instance_id;
|
||||||
|
|
||||||
Vst3ComponentHandlerProxy::ConstructArgs component_handler_proxy_args;
|
/**
|
||||||
|
* Some hosts will pass a null pointer to explicitly free the component
|
||||||
|
* handler passed before releasing the object instance. This also
|
||||||
|
* happens in the SDK, so this seems like valid behaviour we should
|
||||||
|
* support.
|
||||||
|
*/
|
||||||
|
std::optional<Vst3ComponentHandlerProxy::ConstructArgs>
|
||||||
|
component_handler_proxy_args;
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s) {
|
void serialize(S& s) {
|
||||||
s.value8b(instance_id);
|
s.value8b(instance_id);
|
||||||
s.object(component_handler_proxy_args);
|
s.ext(component_handler_proxy_args, bitsery::ext::StdOptional{});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -452,7 +452,8 @@ Vst3PluginProxyImpl::setParamNormalized(Steinberg::Vst::ParamID id,
|
|||||||
|
|
||||||
tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler(
|
tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler(
|
||||||
Steinberg::Vst::IComponentHandler* handler) {
|
Steinberg::Vst::IComponentHandler* handler) {
|
||||||
// TODO: Null pointers are valid here, should we pass them through?
|
// Null pointers are valid here going from the reference implementations in
|
||||||
|
// the SDK
|
||||||
if (handler) {
|
if (handler) {
|
||||||
// We'll store the pointer for when the plugin later makes a callback to
|
// We'll store the pointer for when the plugin later makes a callback to
|
||||||
// this component handler
|
// this component handler
|
||||||
@@ -473,10 +474,18 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler(
|
|||||||
Vst3ComponentHandlerProxy::ConstructArgs(component_handler,
|
Vst3ComponentHandlerProxy::ConstructArgs(component_handler,
|
||||||
instance_id())});
|
instance_id())});
|
||||||
} else {
|
} else {
|
||||||
bridge.logger.log(
|
component_handler = nullptr;
|
||||||
"WARNING: Null pointer passed to "
|
|
||||||
"'IEditController::setComponentHandler()'");
|
component_handler_2 = nullptr;
|
||||||
return Steinberg::kInvalidArgument;
|
component_handler_3 = nullptr;
|
||||||
|
component_handler_bus_activation = nullptr;
|
||||||
|
progress = nullptr;
|
||||||
|
unit_handler = nullptr;
|
||||||
|
unit_handler_2 = nullptr;
|
||||||
|
|
||||||
|
return bridge.send_message(YaEditController::SetComponentHandler{
|
||||||
|
.instance_id = instance_id(),
|
||||||
|
.component_handler_proxy_args = std::nullopt});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -364,14 +364,18 @@ void Vst3Bridge::run() {
|
|||||||
},
|
},
|
||||||
[&](YaEditController::SetComponentHandler& request)
|
[&](YaEditController::SetComponentHandler& request)
|
||||||
-> YaEditController::SetComponentHandler::Response {
|
-> YaEditController::SetComponentHandler::Response {
|
||||||
// We'll create a proxy object for the component handler and
|
// If the host passed a valid component handler, then we'll
|
||||||
// pass that to the initialize function. The lifetime of this
|
// create a proxy object for the component handler and pass that
|
||||||
// object is tied to that of the actual plugin object we're
|
// to the initialize function. The lifetime of this object is
|
||||||
// proxying for.
|
// tied to that of the actual plugin object we're proxying for.
|
||||||
|
// Otherwise we'll also pass a null pointer. This often happens
|
||||||
|
// just before the host terminates the plugin.
|
||||||
object_instances[request.instance_id].component_handler_proxy =
|
object_instances[request.instance_id].component_handler_proxy =
|
||||||
Steinberg::owned(new Vst3ComponentHandlerProxyImpl(
|
request.component_handler_proxy_args
|
||||||
*this,
|
? Steinberg::owned(new Vst3ComponentHandlerProxyImpl(
|
||||||
std::move(request.component_handler_proxy_args)));
|
*this,
|
||||||
|
std::move(*request.component_handler_proxy_args)))
|
||||||
|
: nullptr;
|
||||||
|
|
||||||
return object_instances[request.instance_id]
|
return object_instances[request.instance_id]
|
||||||
.edit_controller->setComponentHandler(
|
.edit_controller->setComponentHandler(
|
||||||
|
|||||||
Reference in New Issue
Block a user