BR: On Windows, creating 2 modal components can blow up the stack

Minimal code to reproduce. Yes, it’s completely nonsensical, but it’s my program reduced the absolute minimum to reproduce the issue.

void MainComponent::mouseDown(const juce::MouseEvent& e)
{
    juce::PopupMenu m;
    m.addItem("Test", []() {});
    m.showMenuAsync({});

    Blocker blocker;
    blocker.enterModalState(false);

    juce::DocumentWindow w ("Test", juce::Colours::white, 0);
    w.setVisible(true);
    w.toFront(false);
}

Call stack is here:

 	ModalCrash.exe!juce::ModalComponentManager::bringModalComponentsToFront(bool topOneShouldGrabFocus) Line 230	C++
 	ModalCrash.exe!juce::Component::internalBroughtToFront() Line 2628	C++
 	ModalCrash.exe!juce::ComponentPeer::handleBroughtToFront() Line 289	C++
 	ModalCrash.exe!juce::HWNDComponentPeer::toFront(bool makeActive) Line 1590	C++
 	ModalCrash.exe!juce::ModalComponentManager::bringModalComponentsToFront(bool topOneShouldGrabFocus) Line 230	C++
 	ModalCrash.exe!juce::Component::internalBroughtToFront() Line 2628	C++
 	ModalCrash.exe!juce::ComponentPeer::handleBroughtToFront() Line 289	C++
 	ModalCrash.exe!juce::HWNDComponentPeer::toFront(bool makeActive) Line 1590	C++
 	ModalCrash.exe!juce::ModalComponentManager::bringModalComponentsToFront(bool topOneShouldGrabFocus) Line 230	C++
 	ModalCrash.exe!juce::Component::internalBroughtToFront() Line 2628	C++
 	ModalCrash.exe!juce::ComponentPeer::handleBroughtToFront() Line 289	C++
 	ModalCrash.exe!juce::HWNDComponentPeer::toFront(bool makeActive) Line 1590	C++
 	ModalCrash.exe!juce::ModalComponentManager::bringModalComponentsToFront(bool topOneShouldGrabFocus) Line 230	C++
 	ModalCrash.exe!juce::Component::internalBroughtToFront() Line 2628	C++
 	ModalCrash.exe!juce::ComponentPeer::handleBroughtToFront() Line 289	C++
 	ModalCrash.exe!juce::HWNDComponentPeer::toFront(bool makeActive) Line 1590	C++
 	ModalCrash.exe!juce::ModalComponentManager::bringModalComponentsToFront(bool topOneShouldGrabFocus) Line 230	C++
 	ModalCrash.exe!juce::Component::internalBroughtToFront() Line 2628	C++
 	ModalCrash.exe!juce::ComponentPeer::handleBroughtToFront() Line 289	C++
 	ModalCrash.exe!juce::HWNDComponentPeer::toFront(bool makeActive) Line 1590	C++
 	ModalCrash.exe!juce::ModalComponentManager::bringModalComponentsToFront(bool topOneShouldGrabFocus) Line 230	C++
 	ModalCrash.exe!juce::Component::internalBroughtToFront() Line 2628	C++
 	ModalCrash.exe!juce::ComponentPeer::handleBroughtToFront() Line 289	C++
 	ModalCrash.exe!juce::HWNDComponentPeer::toFront(bool makeActive) Line 1590	C++

Project is here:

1 Like