From 5c8084c3e6a54faa79e9160a1255db7a788db023 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 4 Apr 2018 16:33:28 +0100 Subject: [PATCH] VST: Workaround for a potential infinite resizing loop due to coordinate rounding when updating the host window size --- .../VST/juce_VST_Wrapper.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index 52c364c41f..95f3d928e5 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -1288,10 +1288,12 @@ public: if (auto* ed = getEditorComp()) { ed->setTopLeftPosition (0, 0); - ed->setBounds (ed->getLocalArea (this, getLocalBounds())); + + if (shouldResizeEditor) + ed->setBounds (ed->getLocalArea (this, getLocalBounds())); if (! getHostType().isBitwigStudio()) - updateWindowSize(); + updateWindowSize (false); } #if JUCE_MAC && ! JUCE_64BIT @@ -1302,7 +1304,7 @@ public: void childBoundsChanged (Component*) override { - updateWindowSize(); + updateWindowSize (false); } juce::Rectangle getSizeToContainChild() @@ -1313,7 +1315,7 @@ public: return {}; } - void updateWindowSize() + void updateWindowSize (bool resizeEditor) { if (! isInSizeWindow) { @@ -1330,7 +1332,12 @@ public: resizeHostWindow (pos.getWidth(), pos.getHeight()); #if ! JUCE_LINUX // setSize() on linux causes renoise and energyxt to fail. + if (! resizeEditor) // this is needed to prevent an infinite resizing loop due to coordinate rounding + shouldResizeEditor = false; + setSize (pos.getWidth(), pos.getHeight()); + + shouldResizeEditor = true; #else XResizeWindow (display.display, (Window) getWindowHandle(), pos.getWidth(), pos.getHeight()); #endif @@ -1449,6 +1456,7 @@ public: JuceVSTWrapper& wrapper; FakeMouseMoveGenerator fakeMouseGenerator; bool isInSizeWindow = false; + bool shouldResizeEditor = true; #if JUCE_MAC void* hostWindow = {}; @@ -2115,7 +2123,7 @@ private: ed->setScaleFactor (editorScaleFactor); if (editorComp != nullptr) - editorComp->updateWindowSize(); + editorComp->updateWindowSize (true); } #endif }