From 3bc340992980cd3168be9069d70cf8792de9c19d Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 22 Dec 2020 14:27:56 +0100 Subject: [PATCH] Keep track of the last created plugin view For implementing `IPlugView::resizeView()`. This approach is safe because there's only a single defined view type. --- src/plugin/bridges/vst3-impls/plugin-proxy.cpp | 11 +++++++++-- src/plugin/bridges/vst3-impls/plugin-proxy.h | 12 ++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index 58ded7a1..49593d06 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -363,8 +363,15 @@ Vst3PluginProxyImpl::createView(Steinberg::FIDString name) { if (response.plug_view_args) { // The host should manage this. Returning raw pointers feels scary. - return new Vst3PlugViewProxyImpl(bridge, - std::move(*response.plug_view_args)); + auto plug_view_proxy = new Vst3PlugViewProxyImpl( + bridge, std::move(*response.plug_view_args)); + + // We also need to store an (unmanaged, since we don't want to affect + // the reference counting) pointer to this to be able to handle calls to + // `IPlugFrame::resizeView()` in the future + last_created_plug_view = plug_view_proxy; + + return plug_view_proxy; } else { return nullptr; } diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.h b/src/plugin/bridges/vst3-impls/plugin-proxy.h index 0d6e856f..6d404975 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.h +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.h @@ -123,6 +123,18 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { tresult PLUGIN_API initialize(FUnknown* context) override; tresult PLUGIN_API terminate() override; + /** + * An unmanaged, raw pointer to the `IPlugView` instance returned in our + * implementation of `IEditController::createView()`. We need this to handle + * `IPlugFrame::resizeView()`, since that expects a pointer to the view that + * gets resized. + * + * XXX: This approach of course won't work with multiple views, but the SDK + * currently only defines a single type of view so that shouldn't be an + * issue + */ + Steinberg::IPlugView* last_created_plug_view = nullptr; + /** * The component handler the host passed to us during * `IEditController::setComponentHandler()`. When the plugin makes a