emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 2837e25 2/2: Fix display bug on macOS (bug#50112)


From: Alan Third
Subject: master 2837e25 2/2: Fix display bug on macOS (bug#50112)
Date: Sat, 21 Aug 2021 08:13:45 -0400 (EDT)

branch: master
commit 2837e25cafefea84d39a613b0d809194e0f75af0
Author: Alan Third <alan@idiocy.org>
Commit: Alan Third <alan@idiocy.org>

    Fix display bug on macOS (bug#50112)
    
    * src/nsterm.m ([EmacsLayer initWithColorSpace:]): Use the colorspace
    setter.
    ([EmacsLayer setColorSpace:]): Sometimes we seem to get null
    colorspaces, so set a default in this case.
    ([EmacsLayer getContext]): Check whether there's been a surface or
    graphics context allocation failure and log it.
---
 src/nsterm.m | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index ba5d81f..1c1f0c8 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -9394,7 +9394,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
   if (self)
     {
       cache = [[NSMutableArray arrayWithCapacity:CACHE_MAX_SIZE] retain];
-      colorSpace = cs;
+      [self setColorSpace:cs];
     }
   else
     {
@@ -9409,7 +9409,10 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
 {
   /* We don't need to clear the cache because the new colorspace will
      be used next time we create a new context.  */
-  colorSpace = cs;
+  if (cs)
+    colorSpace = cs;
+  else
+    colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
 }
 
 
@@ -9505,6 +9508,12 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
                 (id)kIOSurfacePixelFormat:[NSNumber 
numberWithUnsignedInt:'BGRA']});
         }
 
+      if (!surface)
+        {
+          NSLog (@"Failed to create IOSurface for frame %@", [self delegate]);
+          return nil;
+        }
+
       IOReturn lockStatus = IOSurfaceLock (surface, 0, nil);
       if (lockStatus != kIOReturnSuccess)
         NSLog (@"Failed to lock surface: %x", lockStatus);
@@ -9522,6 +9531,15 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
                                        (kCGImageAlphaPremultipliedFirst
                                         | kCGBitmapByteOrder32Host));
 
+      if (!context)
+        {
+          NSLog (@"Failed to create context for frame %@", [self delegate]);
+          IOSurfaceUnlock (currentSurface, 0, nil);
+          CFRelease (currentSurface);
+          currentSurface = nil;
+          return nil;
+        }
+
       CGContextTranslateCTM(context, 0, IOSurfaceGetHeight (currentSurface));
       CGContextScaleCTM(context, scale, -scale);
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]