From 6b2d017ead856c244a0b5c5a162254094877bc54 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sat, 1 May 2021 17:50:25 +0100 Subject: [PATCH] Fix infinite loop on GNUstep when toolbar updated * src/nsterm.m ([EmacsView viewDidResize:]): Use Emacs's existing knowledge of the frame size to decide whether to resize or not. --- src/nsterm.m | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index b135e359f5d..f2d03967f90 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7296,7 +7296,7 @@ not_in_argv (NSString *arg) - (void)viewDidResize:(NSNotification *)notification { NSRect frame = [self frame]; - int neww, newh; + int neww, newh, oldw, oldh; if (! FRAME_LIVE_P (emacsframe)) return; @@ -7305,25 +7305,22 @@ not_in_argv (NSString *arg) neww = (int)NSWidth (frame); newh = (int)NSHeight (frame); + oldw = FRAME_PIXEL_WIDTH (emacsframe); + oldh = FRAME_PIXEL_HEIGHT (emacsframe); + NSTRACE_SIZE ("New size", NSMakeSize (neww, newh)); + NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); + + /* Don't want to do anything when the view size hasn't changed. */ + if (oldh == newh && oldw == neww) + { + NSTRACE_MSG ("No change"); + return; + } #ifdef NS_DRAW_TO_BUFFER if ([self wantsUpdateLayer]) { - CGFloat scale = [[self window] backingScaleFactor]; - NSSize size = [surface getSize]; - int oldw = size.width / scale; - int oldh = size.height / scale; - - NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh)); - - /* Don't want to do anything when the view size hasn't changed. */ - if ((oldh == newh && oldw == neww)) - { - NSTRACE_MSG ("No change"); - return; - } - [surface release]; surface = nil; @@ -7331,10 +7328,6 @@ not_in_argv (NSString *arg) } #endif - /* I'm not sure if it's safe to call this every time the view - changes size, as Emacs may already know about the change. - Unfortunately there doesn't seem to be a bullet-proof method of - determining whether we need to call it or not. */ change_frame_size (emacsframe, neww, newh, false, YES, false); SET_FRAME_GARBAGED (emacsframe); -- 2.39.5