1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

VST3 Client: Fix parameter context menu in FL Studio

The change to the VST3 wrapper in
335f6e9591 broke context menu items in FL
Studio, so that clicking on a menu item had no effect. This could be
seen in the DSPModulePluginDemo example.

I'm not sure exactly what caused the breakage. Before the breaking
change, the menu remained alive until the point where the menu item was
triggered as it was leaked. After the breaking change, the IContextMenu
could be freed before a particular IContextMenuTarget was executed. My
guess is that FL Studio requires the menu to be alive when triggering a
particular menu item.

This change captures the IContextMenu inside the popup menu callback to
ensure that it remains alive until the PopupMenu is destroyed.
This commit is contained in:
reuk 2024-07-29 14:28:18 +01:00
parent 281c56f2f9
commit 66aa42c9c0
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -1735,12 +1735,19 @@ private:
}
else
{
const auto ownedTarget = addVSTComSmartPtrOwner (target);
const auto tag = item.tag;
const auto callback = [menu = contextMenu, i]
{
MenuItem localItem{};
MenuTarget* localTarget = nullptr;
if (menu->getItem (i, localItem, &localTarget) == kResultOk && localTarget != nullptr)
localTarget->executeMenuItem (localItem.tag);
};
menuStack.back().menu.addItem (toString (item.name),
(item.flags & MenuItem::kIsDisabled) == 0,
(item.flags & MenuItem::kIsChecked) != 0,
[ownedTarget, tag] { ownedTarget->executeMenuItem (tag); });
callback);
}
}