Use mutual recursion for IEditController::setState

With this we should be able to handle `setState()`s that try to resize
the currently open editor. This could pop up when using the preset
browser in REAPER with plugins that recall their old size when loading a
preset.
This commit is contained in:
Robbert van der Helm
2021-04-30 01:15:18 +02:00
parent 0536256217
commit 949ddaf673
5 changed files with 50 additions and 15 deletions
@@ -106,6 +106,7 @@ class RunLoopTasks : public Steinberg::Linux::IEventHandler {
class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy {
public:
Vst3PlugViewProxyImpl(Vst3PluginBridge& bridge,
std::atomic_bool& is_active,
Vst3PlugViewProxy::ConstructArgs&& args);
/**
@@ -201,14 +202,6 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy {
// From `IPlugViewContentScaleSupport`
tresult PLUGIN_API setContentScaleFactor(ScaleFactor factor) override;
/**
* The `IPlugFrame` object passed by the host passed to us in
* `IPlugView::setFrame()`. When the plugin makes a callback on the
* `IPlugFrame` proxy object, we'll pass the call through to this object.
*/
Steinberg::IPtr<Steinberg::IPlugFrame> plug_frame;
private:
/**
* Send a message from this `IPlugView` instance. This function will be
* called by the host on its GUI thread, so until this function returns
@@ -268,8 +261,25 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy {
return response_promise.get_future().get();
}
/**
* The `IPlugFrame` object passed by the host passed to us in
* `IPlugView::setFrame()`. When the plugin makes a callback on the
* `IPlugFrame` proxy object, we'll pass the call through to this object.
*/
Steinberg::IPtr<Steinberg::IPlugFrame> plug_frame;
private:
Vst3PluginBridge& bridge;
/**
* We'll use this to signal to the `Vst3PluginProxyImpl` that this object
* has been destroyed. We use this to handle mutual recursion when
* `IEditController::setState()` calls end up calling
* `IPlugFrame::resizeView()`, which should also be handled from the GUI
* thread.
*/
std::atomic_bool& is_active;
/**
* The IO contexts used in `send_mutually_recursive_message()` to be able to
* execute functions from that same calling thread while we're waiting for a