From 78921d4be674d5138f7419f2fbca086179215443 Mon Sep 17 00:00:00 2001 From: sebastien Date: Mon, 5 Oct 2015 12:23:29 +0100 Subject: [PATCH] [[ no-UI Crash ]] bugfix 16017 causes a crash when LiveCode is run in no-UI mode should check whether a display has been returned before accessing its rectangle view --- engine/src/stackview.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/engine/src/stackview.cpp b/engine/src/stackview.cpp index eb4ee2ed346..2672793646b 100644 --- a/engine/src/stackview.cpp +++ b/engine/src/stackview.cpp @@ -448,11 +448,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);