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

Commit fe20614

Browse files
Merge remote-tracking branch 'origin/develop-6.7' into develop-7.0
Clean merge.
2 parents e11412c + ffc0d7f commit fe20614

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

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;

engine/src/stackview.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,18 @@ void MCStack::view_update_transform(void)
451451

452452
// PM-2015-07-17: [[ Bug 13754 ]] Make sure stack does not disappear off screen when changing the scalefactor
453453
MCRectangle t_bounded_rect, t_screen_rect;
454-
455-
// AL-2015-10-01: [[ Bug 16017 ]] Remember location of stacks on a second monitor
456-
t_screen_rect = MCscreen -> getnearestdisplay(t_view_rect) -> viewport;
457-
458-
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);
454+
455+
const MCDisplay* t_nearest_display = MCscreen -> getnearestdisplay(t_view_rect);
456+
if (t_nearest_display != NULL)
457+
{
458+
t_screen_rect = t_nearest_display -> viewport;
459+
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);
460+
}
461+
else
462+
{
463+
// In noUI mode, we don't have a nearest display.
464+
t_bounded_rect = MCU_bound_rect(t_view_rect, 0, 0, MCscreen -> getwidth(), MCscreen -> getheight());
465+
}
459466

460467
// IM-2014-01-16: [[ StackScale ]] Update view rect if needed
461468
view_setrect(t_bounded_rect);

engine/src/uidc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ const MCDisplay *MCUIDC::getnearestdisplay(const MCRectangle& p_rectangle)
517517

518518
t_max_area = 0;
519519
t_max_distance = MAXUINT4;
520+
t_max_distance_index = 0;
520521
for(uint4 t_display = 0; t_display < t_display_count; ++t_display)
521522
{
522523
MCRectangle t_workarea;

0 commit comments

Comments
 (0)