Remove support for null pointers in setHostContext

Like the other functions, null pointers are never valid here so we
shouldn't bother passing them as it only increases complexity.
This commit is contained in:
Robbert van der Helm
2020-12-22 14:03:56 +01:00
parent 3b96ffa349
commit 9288cdcb59
5 changed files with 24 additions and 38 deletions
@@ -100,25 +100,24 @@ YaPluginFactoryImpl::createInstance(Steinberg::FIDString cid,
tresult PLUGIN_API
YaPluginFactoryImpl::setHostContext(Steinberg::FUnknown* context) {
// We will create a proxy object that that supports all the same interfaces
// as `context`, and then we'll store `context` in this object. We can then
// use it to handle callbacks made by the Windows VST3 plugin to this
// context.
host_context = context;
if (context) {
// We will create a proxy object that that supports all the same
// interfaces as `context`, and then we'll store `context` in this
// object. We can then use it to handle callbacks made by the Windows
// VST3 plugin to this context.
host_context = context;
// Automatically converted smart pointers for when the plugin performs a
// callback later
host_application = host_context;
// Automatically converted smart pointers for when the plugin performs a
// callback later
host_application = host_context;
std::optional<Vst3HostContextProxy::ConstructArgs> host_context_args{};
if (host_context) {
host_context_args =
Vst3HostContextProxy::ConstructArgs(host_context, std::nullopt);
return bridge.send_message(YaPluginFactory::SetHostContext{
.host_context_args = Vst3HostContextProxy::ConstructArgs(
host_context, std::nullopt)});
} else {
bridge.logger.log(
"Null pointer passed to 'IPluginFactory3::setHostContext()'");
"WARNING: Null pointer passed to "
"'IPluginFactory3::setHostContext()'");
return Steinberg::kInvalidArgument;
}
return bridge.send_message(YaPluginFactory::SetHostContext{
.host_context_args = std::move(host_context_args)});
}
@@ -406,7 +406,8 @@ tresult PLUGIN_API Vst3PluginProxyImpl::initialize(FUnknown* context) {
.host_context_args = Vst3HostContextProxy::ConstructArgs(
host_context, instance_id())});
} else {
bridge.logger.log("Null pointer passed to 'IPluginBase::initialize()'");
bridge.logger.log(
"WARNING: Null pointer passed to 'IPluginBase::initialize()'");
return Steinberg::kInvalidArgument;
}
}