MenuBarComponent crash in Xcode debugger

On macOS, if i quit the Application by closing the main window, while a menu is still on screen, it crashes. Notice that it happens only if a custom LookAndFeel is set and only while running from Xcode debugger! :thinking:

JUCE Assertion failure in juce_LookAndFeel.cpp:73

It is a rather unusual case since i use menubar on that platform briefly only during development (to customize it for linux from my mac). I don’t know if it worth the cost to investigate more. Below a project to illustrate this weird stuff.

JUCE 6.0.8 / macOS 11.2.3 / Xcode 12.4 (5.3 KB)

A workaround is to call PopupMenu::dismissAllActiveMenus before, for instance:

void closeButtonPressed() override