Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 64f47f0

Browse files
Auto-merge pull request #2981 from livecodefraser/bugfix-15878-6.7
[[ Bugfix 15878 ]] Fix a crash caused by waiting during modal session setup Creating a modal window session on Cocoa can trigger event processing (e.g. because another window lost focus). Waiting during these events caused a crash because the wait loop attempted to run the modal session that hadn't actually been created yet.
2 parents 2e20cc2 + e1e60ff commit 64f47f0

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

docs/notes/bugfix-15878.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Fix a crash caused by waiting during modal window setup
2+

engine/src/mac-core.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,11 @@ bool MCPlatformWaitForEvent(double p_duration, bool p_blocking)
736736
untilDate: [NSDate dateWithTimeIntervalSinceNow: p_duration]
737737
inMode: p_blocking ? NSEventTrackingRunLoopMode : NSDefaultRunLoopMode
738738
dequeue: YES];
739-
if (t_modal)
739+
740+
// Run the modal session, if it has been created yet (it might not if this
741+
// wait was triggered by reacting to an event caused as part of creating
742+
// the modal session, e.g. when losing window focus).
743+
if (t_modal && s_modal_sessions[s_modal_session_count - 1].session != nil)
740744
[NSApp runModalSession: s_modal_sessions[s_modal_session_count - 1] . session];
741745

742746
s_in_blocking_wait = false;

0 commit comments

Comments
 (0)