mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
VST3 Host: Only call onSize() in resizeView() if the size has changed
This fixes a recursive resizeView()->onSize()->resizeView() loop in Arturia Pigments as it immediately calls resizeView() with the same size.
This commit is contained in:
parent
598748c825
commit
3f699f5b14
1 changed files with 20 additions and 5 deletions
|
|
@ -1527,15 +1527,30 @@ struct VST3PluginWindow : public AudioProcessorEditor,
|
|||
{
|
||||
if (incomingView != nullptr && newSize != nullptr && incomingView == view)
|
||||
{
|
||||
auto scaleToViewRect = [this] (int dimension)
|
||||
{
|
||||
return (Steinberg::int32) roundToInt ((float) dimension * nativeScaleFactor);
|
||||
};
|
||||
|
||||
auto oldWidth = scaleToViewRect (getWidth());
|
||||
auto oldHeight = scaleToViewRect (getHeight());
|
||||
|
||||
resizeWithRect (embeddedComponent, *newSize, nativeScaleFactor);
|
||||
setSize (embeddedComponent.getWidth(), embeddedComponent.getHeight());
|
||||
|
||||
// According to the VST3 Workflow Diagrams, a resizeView from the plugin should
|
||||
// always trigger a response from the host which confirms the new size.
|
||||
ViewRect rect;
|
||||
rect.right = (Steinberg::int32) roundToInt ((float) getWidth() * nativeScaleFactor);
|
||||
rect.bottom = (Steinberg::int32) roundToInt ((float) getHeight() * nativeScaleFactor);
|
||||
view->onSize (&rect);
|
||||
ViewRect rect { 0, 0,
|
||||
scaleToViewRect (getWidth()),
|
||||
scaleToViewRect (getHeight()) };
|
||||
|
||||
if (rect.right != oldWidth || rect.bottom != oldHeight
|
||||
|| ! isInOnSize)
|
||||
{
|
||||
// Guard against plug-ins immediately calling resizeView() with the same size
|
||||
const ScopedValueSetter<bool> inOnSizeSetter (isInOnSize, true);
|
||||
view->onSize (&rect);
|
||||
}
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
|
@ -1642,7 +1657,7 @@ private:
|
|||
#endif
|
||||
|
||||
HandleFormat pluginHandle = {};
|
||||
bool recursiveResize = false, hasDoneInitialResize = false;
|
||||
bool recursiveResize = false, hasDoneInitialResize = false, isInOnSize = false;
|
||||
|
||||
ComponentPeer* currentPeer = nullptr;
|
||||
Steinberg::IPlugViewContentScaleSupport* scaleInterface = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue