]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix infinite loop on GNUstep when toolbar updated
authorAlan Third <alan@idiocy.org>
Sat, 1 May 2021 16:50:25 +0000 (17:50 +0100)
committerAlan Third <alan@idiocy.org>
Sat, 1 May 2021 18:13:07 +0000 (19:13 +0100)
* src/nsterm.m ([EmacsView viewDidResize:]): Use Emacs's existing
knowledge of the frame size to decide whether to resize or not.

src/nsterm.m

index b135e359f5d1d373338d7d16e53a8b2f9e881764..f2d03967f9078790dfaf432db58cca5004c19318 100644 (file)
@@ -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);