Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
2 changes: 2 additions & 0 deletions docs/notes/bugfix-15878.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Fix a crash caused by waiting during modal window setup

6 changes: 5 additions & 1 deletion engine/src/mac-core.mm
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,11 @@ bool MCPlatformWaitForEvent(double p_duration, bool p_blocking)
untilDate: [NSDate dateWithTimeIntervalSinceNow: p_duration]
inMode: p_blocking ? NSEventTrackingRunLoopMode : NSDefaultRunLoopMode
dequeue: YES];
if (t_modal)

// Run the modal session, if it has been created yet (it might not if this
// wait was triggered by reacting to an event caused as part of creating
// the modal session, e.g. when losing window focus).
if (t_modal && s_modal_sessions[s_modal_session_count - 1].session != nil)
[NSApp runModalSession: s_modal_sessions[s_modal_session_count - 1] . session];

s_in_blocking_wait = false;
Expand Down
17 changes: 12 additions & 5 deletions engine/src/stackview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,18 @@ void MCStack::view_update_transform(void)

// PM-2015-07-17: [[ Bug 13754 ]] Make sure stack does not disappear off screen when changing the scalefactor
MCRectangle t_bounded_rect, t_screen_rect;

// AL-2015-10-01: [[ Bug 16017 ]] Remember location of stacks on a second monitor
t_screen_rect = MCscreen -> getnearestdisplay(t_view_rect) -> viewport;

t_bounded_rect = MCU_bound_rect(t_view_rect, t_screen_rect . x, t_screen_rect . y, t_screen_rect . width, t_screen_rect . height);

const MCDisplay* t_nearest_display = MCscreen -> getnearestdisplay(t_view_rect);
if (t_nearest_display != NULL)
{
t_screen_rect = t_nearest_display -> viewport;
t_bounded_rect = MCU_bound_rect(t_view_rect, t_screen_rect . x, t_screen_rect . y, t_screen_rect . width, t_screen_rect . height);
}
else
{
// In noUI mode, we don't have a nearest display.
t_bounded_rect = MCU_bound_rect(t_view_rect, 0, 0, MCscreen -> getwidth(), MCscreen -> getheight());
}

// IM-2014-01-16: [[ StackScale ]] Update view rect if needed
view_setrect(t_bounded_rect);
Expand Down
1 change: 1 addition & 0 deletions engine/src/uidc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ const MCDisplay *MCUIDC::getnearestdisplay(const MCRectangle& p_rectangle)

t_max_area = 0;
t_max_distance = MAXUINT4;
t_max_distance_index = 0;
for(uint4 t_display = 0; t_display < t_display_count; ++t_display)
{
MCRectangle t_workarea;
Expand Down