Hi all,
We were seeing intermittent crashes on Mac when closing popup menus. Turns out the issue was a member variable being accessed after the object had been destroyed. See original JUCE code and my temporary fix below:
void hide (const PopupMenu::Item* item, bool makeInvisible)
{
if (isVisible())
{
WeakReference<Component> deletionChecker (this);
activeSubMenu.reset();
currentChild = nullptr;
if (item != nullptr
&& item->commandManager != nullptr
&& item->itemID != 0)
{
*managerOfChosenCommand = item->commandManager;
}
auto resultID = options.hasWatchedComponentBeenDeleted() ? 0 : getResultItemID (item);
exitModalState (resultID);
#if 1 // ⚠ TEMP JUCE BUG FIX ⚠
// Closing popup menus would occasionally cause an unhandled exception/crash on Mac.
// Xcode Address Sanitizer flagged a "Use of deallocated memory" bug here.
if (deletionChecker != nullptr)
exitingModalState = true;
#else
// Original JUCE code.
exitingModalState = true;
#endif
if (makeInvisible && deletionChecker != nullptr)
setVisible (false);
if (resultID != 0
&& item != nullptr
&& item->action != nullptr)
MessageManager::callAsync (item->action);
}
}
Would like to see that fixed in the next release please.
Many thanks,
Ben