Remove null pointer support in setComponentHandler

This should be an implementation fault.
This commit is contained in:
Robbert van der Helm
2020-12-22 13:54:55 +01:00
parent 37897da2b7
commit 51876a024c
4 changed files with 28 additions and 47 deletions
+2 -7
View File
@@ -209,13 +209,8 @@ 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 = "
if (request.component_handler_proxy_args) { "<IComponentHandler*>)";
message << "<IComponentHandler*>";
} else {
message << "<nullptr>";
}
message << ")";
}); });
} }
@@ -345,18 +345,12 @@ class YaEditController : public Steinberg::Vst::IEditController {
native_size_t instance_id; native_size_t instance_id;
/** Vst3ComponentHandlerProxy::ConstructArgs component_handler_proxy_args;
* Arguments for instantiating the proxy object. Even though it should
* never happen, if the host passed a null pointer to this function
* we'll mimic that as well.
*/
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.ext(component_handler_proxy_args, bitsery::ext::StdOptional{}); s.object(component_handler_proxy_args);
} }
}; };
+9 -11
View File
@@ -337,6 +337,7 @@ Vst3PluginProxyImpl::setParamNormalized(Steinberg::Vst::ParamID id,
tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler( tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler(
Steinberg::Vst::IComponentHandler* handler) { Steinberg::Vst::IComponentHandler* 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
component_handler = handler; component_handler = handler;
@@ -345,20 +346,17 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler(
// callback later // callback later
host_application = host_context; host_application = host_context;
std::optional<Vst3ComponentHandlerProxy::ConstructArgs>
component_handler_proxy_args = std::nullopt;
if (handler) {
component_handler_proxy_args = Vst3ComponentHandlerProxy::ConstructArgs(
component_handler, instance_id());
} else {
bridge.logger.log(
"Null pointer passed to 'IEditController::setComponentHandler()'");
}
return bridge.send_message(YaEditController::SetComponentHandler{ return bridge.send_message(YaEditController::SetComponentHandler{
.instance_id = instance_id(), .instance_id = instance_id(),
.component_handler_proxy_args = .component_handler_proxy_args =
std::move(component_handler_proxy_args)}); Vst3ComponentHandlerProxy::ConstructArgs(component_handler,
instance_id())});
} else {
bridge.logger.log(
"WARNING: Null pointer passed to "
"'IEditController::setComponentHandler()'");
return Steinberg::kInvalidArgument;
}
} }
Steinberg::IPlugView* PLUGIN_API Steinberg::IPlugView* PLUGIN_API
+6 -12
View File
@@ -255,22 +255,16 @@ void Vst3Bridge::run() {
}, },
[&](YaEditController::SetComponentHandler& request) [&](YaEditController::SetComponentHandler& request)
-> YaEditController::SetComponentHandler::Response { -> YaEditController::SetComponentHandler::Response {
// If we got passed a component handler, we'll create a proxy // We'll create a proxy object for the component handler and
// object and pass that to the initialize function. The lifetime // pass that to the initialize function. The lifetime of this
// of this object is tied to that of the actual plugin object // object is tied to that of the actual plugin object we're
// we're proxying for. // proxying for.
// TODO: Does this have to be run from the UI thread? Figure out // TODO: Does this have to be run from the UI thread? Figure out
// if it does // if it does
if (request.component_handler_proxy_args) { object_instances[request.instance_id].component_handler_proxy =
object_instances[request.instance_id]
.component_handler_proxy =
Steinberg::owned(new Vst3ComponentHandlerProxyImpl( Steinberg::owned(new Vst3ComponentHandlerProxyImpl(
*this, *this,
std::move(*request.component_handler_proxy_args))); std::move(request.component_handler_proxy_args)));
} else {
object_instances[request.instance_id]
.component_handler_proxy = nullptr;
}
return object_instances[request.instance_id] return object_instances[request.instance_id]
.edit_controller->setComponentHandler( .edit_controller->setComponentHandler(