Popup submenu crash

Hi Jules,
hope things are fine!

How to reproduce this crash in the Juce Demo:
[list=1][] page “Widgets”[/]
[]“click for popup menu”[/]
[]hover/“walk” to the last menu item (“File Chooser Dialogs”), [/]
[]walk into the sub menu and one further sub menu[/]
[]walk back with the mouse to the main popup menu[/]
[]hover over another menu item there[/][/list]
You may need to repeat 3-6 a couple of times.

On Windows with today’s git version, I get the following crash stack trace:

JuceDemo.exe!juce::PopupMenu::Window::hide(const juce::PopupMenu::Item * const item=0x00000000, const bool makeInvisible=true) Line 382 + 0xa bytes C++ JuceDemo.exe!juce::PopupMenu::Window::highlightItemUnderMouse(const juce::Point<int> & globalMousePos={...}, const juce::Point<int> & localMousePos={...}) Line 1118 C++ JuceDemo.exe!juce::PopupMenu::Window::timerCallback() Line 561 C++ JuceDemo.exe!juce::PopupMenu::Window::mouseMove(const juce::MouseEvent & __formal={...}) Line 415 + 0x1d bytes C++ JuceDemo.exe!juce::ListenerList<juce::MouseListener,juce::Array<juce::MouseListener *,juce::DummyCriticalSection> >::callChecked<juce::Component::BailOutChecker,juce::MouseEvent const &>(const juce::Component::BailOutChecker & bailOutChecker={...}, void (const juce::MouseEvent &)* callbackFunction=0x00c4e656, const juce::MouseEvent & param1={...}) Line 181 + 0x11 bytes C++ JuceDemo.exe!juce::Desktop::sendMouseMove() Line 394 C++ JuceDemo.exe!juce::Desktop::timerCallback() Line 369 C++ JuceDemo.exe!juce::InternalTimerThread::callTimers() Line 141 C++ JuceDemo.exe!juce::InternalTimerThread::handleMessage(const juce::Message & __formal={...}) Line 157 C++ JuceDemo.exe!juce::MessageManager::deliverMessage(juce::Message * const message=0x03188138) Line 117 C++ JuceDemo.exe!juce::MessageManager::dispatchNextMessageOnSystemQueue(const bool returnIfNoPendingMessages=false) Line 164 C++ JuceDemo.exe!juce::MessageManager::runDispatchLoopUntil(int millisecondsToRunFor=-1) Line 147 + 0x10 bytes C++ JuceDemo.exe!juce::MessageManager::runDispatchLoop() Line 128 C++ JuceDemo.exe!juce::JUCEApplication::main(const juce::String & commandLine={...}) Line 242 C++ JuceDemo.exe!WinMain(int __formal=10158080, int __formal=10158080, int __formal=10158080, int __formal=10158080) Line 156 + 0x54 bytes C++ JuceDemo.exe!__tmainCRTStartup() Line 263 + 0x2c bytes C JuceDemo.exe!WinMainCRTStartup() Line 182 C
Thanks,
Florian

Ok, thanks - I can’t seem to trigger it myself, but I think I can see what might be happening, and some extra safety checks might help…?

[code] void hide (const PopupMenu::Item* const item, const bool makeInvisible)
{
if (isVisible())
{
WeakReference deletionChecker (this);

        activeSubMenu = nullptr;
        currentChild = nullptr;

        if (item != nullptr
             && item->commandManager != nullptr
             && item->itemId != 0)
        {
            *managerOfChosenCommand = item->commandManager;
        }

        exitModalState (item != nullptr ? item->itemId : 0);

        if (makeInvisible && (deletionChecker != nullptr))
            setVisible (false);
    }
}

[/code]

excellent! Now instead of crashing, the entire popup menu vanishes. Which is good enough for me.

Thanks for the quick reply.
Florian