[gtk/gtk-3-24: 4/5] GdkQuartz: Handle NULL from [NSGraphicsContext currentContext].



commit 7e4cda6c1cecec004fb09a13b42829335166fdba
Author: John Ralls <jralls ceridwen us>
Date:   Sat Oct 20 12:27:46 2018 -0700

    GdkQuartz: Handle NULL from [NSGraphicsContext currentContext].
    
    By returning a default surface. The situation where there's no
    currentContext arises when GtkCSS is trying to determine the
    layout sizes so no actual display is necessary.
    
    Closes: #1411

 gdk/quartz/gdkwindow-quartz.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index c7fe68848a..402e191194 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -141,6 +141,8 @@ gdk_window_impl_quartz_get_context (GdkWindowImplQuartz *window_impl,
        cg_context = [[NSGraphicsContext currentContext] graphicsPort];
   else
        cg_context = [[NSGraphicsContext currentContext] CGContext];
+  if (!cg_context)
+       return NULL;
   CGContextSaveGState (cg_context);
   CGContextSetAllowsAntialiasing (cg_context, antialias);
 
@@ -299,15 +301,15 @@ gdk_quartz_create_cairo_surface (GdkWindowImplQuartz *impl,
 
   cg_context = gdk_quartz_window_get_context (impl, TRUE);
 
-  if (!cg_context)
-    return NULL;
-
   surface_data = g_new (GdkQuartzCairoSurfaceData, 1);
   surface_data->window_impl = impl;
   surface_data->cg_context = cg_context;
 
-  surface = cairo_quartz_surface_create_for_cg_context (cg_context,
-                                                        width, height);
+  if (cg_context)
+       surface = cairo_quartz_surface_create_for_cg_context (cg_context,
+                                                             width, height);
+  else
+       surface = cairo_quartz_surface_create(CAIRO_FORMAT_ARGB32, width, height);
 
   cairo_surface_set_user_data (surface, &gdk_quartz_cairo_key,
                                surface_data,


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