mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Component: Add an assertion to check that the component remains alive when entering modal state
This commit is contained in:
parent
3061876e0d
commit
697643c0b6
1 changed files with 9 additions and 0 deletions
|
|
@ -1769,6 +1769,8 @@ void Component::enterModalState (bool shouldTakeKeyboardFocus,
|
|||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
|
||||
JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED
|
||||
|
||||
SafePointer safeReference { this };
|
||||
|
||||
if (! isCurrentlyModal (false))
|
||||
{
|
||||
// While this component is in modal state it may block other components from receiving
|
||||
|
|
@ -1776,6 +1778,13 @@ void Component::enterModalState (bool shouldTakeKeyboardFocus,
|
|||
// we must manually force the mouse to "leave" blocked components.
|
||||
ComponentHelpers::sendMouseEventToComponentsThatAreBlockedByModal (*this, &Component::internalMouseExit);
|
||||
|
||||
if (safeReference == nullptr)
|
||||
{
|
||||
// If you hit this assertion, the mouse-exit event above has caused the modal component to be deleted.
|
||||
jassertfalse;
|
||||
return;
|
||||
}
|
||||
|
||||
auto& mcm = *ModalComponentManager::getInstance();
|
||||
mcm.startModal (this, deleteWhenDismissed);
|
||||
mcm.attachCallback (this, callback);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue