MacOS Menu not coming back when MainWindow is reset

When I initialise my app with MainComponent in MainWindow the MacOS menu bar works fine.

Screenshot 2021-07-30 at 16.57.02

The menu bar is initialised with:

juce::MenuBarModel::setMacMainMenu(this);

On Destruction of MainComponent the menu bar is set to nullptr in the same way.

If I reset unique_ptr holding the MainWindow with another default initialised instance the menu bar does not reappear fully:

Screenshot 2021-07-30 at 17.00.01

After reading other threads I suspect this is to do with focus?

Can anyone shine any light on this?

For anyone who gets stuck on this. The trick is not to set the Mac main menu to nullptr until your app is closing. To change the menu just set the mac main menu to your new one rather than setting it to nullptr then your new one. You still need to set it to nullptr at the destruction of your app however.