Skip to content

Commit

Permalink
Component: Avoid calling member functions on objects destroyed when e…
Browse files Browse the repository at this point in the history
…xiting modal state
  • Loading branch information
reuk committed Nov 24, 2021
1 parent 062e966 commit ca4bdb6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/juce_gui_basics/components/juce_Component.cpp
Expand Up @@ -1761,6 +1761,8 @@ void Component::enterModalState (bool shouldTakeKeyboardFocus,

void Component::exitModalState (int returnValue)
{
WeakReference<Component> deletionChecker (this);

if (isCurrentlyModal (false))
{
if (MessageManager::getInstance()->isThisTheMessageThread())
Expand All @@ -1772,7 +1774,8 @@ void Component::exitModalState (int returnValue)
// While this component is in modal state it may block other components from receiving
// mouseEnter events. To keep mouseEnter and mouseExit calls balanced on these components,
// we must manually force the mouse to "enter" blocked components.
ComponentHelpers::sendMouseEventToComponentsThatAreBlockedByModal (*this, &Component::internalMouseEnter);
if (deletionChecker != nullptr)
ComponentHelpers::sendMouseEventToComponentsThatAreBlockedByModal (*deletionChecker, &Component::internalMouseEnter);
}
else
{
Expand Down

0 comments on commit ca4bdb6

Please sign in to comment.