Protect CGContext calls from null CGContextRefs.
To prevent invalid CGContext warnings.
This commit is contained in:
@@ -884,6 +884,9 @@ void
|
||||
gdk_quartz_drawable_release_context (GdkDrawable *drawable,
|
||||
CGContextRef cg_context)
|
||||
{
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
|
||||
{
|
||||
GdkWindowImplQuartz *window_impl = GDK_WINDOW_IMPL_QUARTZ (drawable);
|
||||
|
||||
@@ -112,13 +112,16 @@ create_clip_mask (GdkPixmap *source_pixmap)
|
||||
CGImageGetColorSpace (source),
|
||||
CGImageGetBitmapInfo (source));
|
||||
|
||||
CGContextTranslateCTM (cg_context, 0, height);
|
||||
CGContextScaleCTM (cg_context, 1.0, -1.0);
|
||||
if (cg_context)
|
||||
{
|
||||
CGContextTranslateCTM (cg_context, 0, height);
|
||||
CGContextScaleCTM (cg_context, 1.0, -1.0);
|
||||
|
||||
CGContextDrawImage (cg_context,
|
||||
CGRectMake (0, 0, width, height), source);
|
||||
CGContextDrawImage (cg_context,
|
||||
CGRectMake (0, 0, width, height), source);
|
||||
|
||||
CGContextRelease (cg_context);
|
||||
CGContextRelease (cg_context);
|
||||
}
|
||||
|
||||
return clip_mask;
|
||||
}
|
||||
@@ -366,6 +369,9 @@ gdk_quartz_draw_tiled_pattern (void *info,
|
||||
CGImageRef pattern_image;
|
||||
size_t width, height;
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
pattern_image = _gdk_pixmap_get_cgimage (GDK_PIXMAP (_gdk_gc_get_tile (gc)));
|
||||
|
||||
width = CGImageGetWidth (pattern_image);
|
||||
@@ -387,6 +393,9 @@ gdk_quartz_draw_stippled_pattern (void *info,
|
||||
CGRect rect;
|
||||
CGColorRef color;
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
pattern_image = _gdk_pixmap_get_cgimage (GDK_PIXMAP (_gdk_gc_get_stipple (gc)));
|
||||
rect = CGRectMake (0, 0,
|
||||
CGImageGetWidth (pattern_image),
|
||||
@@ -413,6 +422,9 @@ gdk_quartz_draw_opaque_stippled_pattern (void *info,
|
||||
CGRect rect;
|
||||
CGColorRef color;
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
pattern_image = _gdk_pixmap_get_cgimage (GDK_PIXMAP (_gdk_gc_get_stipple (gc)));
|
||||
rect = CGRectMake (0, 0,
|
||||
CGImageGetWidth (pattern_image),
|
||||
@@ -448,7 +460,7 @@ _gdk_quartz_gc_update_cg_context (GdkGC *gc,
|
||||
|
||||
g_return_val_if_fail (gc == NULL || GDK_IS_GC (gc), FALSE);
|
||||
|
||||
if (!gc)
|
||||
if (!gc || !context)
|
||||
return FALSE;
|
||||
|
||||
private = GDK_GC_QUARTZ (gc);
|
||||
|
||||
@@ -134,14 +134,17 @@ gdk_pixmap_impl_quartz_get_context (GdkDrawable *drawable,
|
||||
bytes_per_row,
|
||||
colorspace,
|
||||
alpha_info);
|
||||
CGContextSetAllowsAntialiasing (cg_context, antialias);
|
||||
|
||||
CGColorSpaceRelease (colorspace);
|
||||
if (cg_context)
|
||||
{
|
||||
CGContextSetAllowsAntialiasing (cg_context, antialias);
|
||||
|
||||
/* convert coordinates from core graphics to gtk+ */
|
||||
CGContextTranslateCTM (cg_context, 0, impl->height);
|
||||
CGContextScaleCTM (cg_context, 1.0, -1.0);
|
||||
CGColorSpaceRelease (colorspace);
|
||||
|
||||
/* convert coordinates from core graphics to gtk+ */
|
||||
CGContextTranslateCTM (cg_context, 0, impl->height);
|
||||
CGContextScaleCTM (cg_context, 1.0, -1.0);
|
||||
}
|
||||
return cg_context;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@ gdk_window_impl_quartz_get_context (GdkDrawable *drawable,
|
||||
cg_context = [[NSGraphicsContext currentContext] graphicsPort];
|
||||
else
|
||||
cg_context = [[NSGraphicsContext currentContext] CGContext];
|
||||
if (!cg_context)
|
||||
return;
|
||||
CGContextSaveGState (cg_context);
|
||||
CGContextSetAllowsAntialiasing (cg_context, antialias);
|
||||
|
||||
@@ -272,6 +274,10 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable *paintable,
|
||||
gint i;
|
||||
|
||||
cg_context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE);
|
||||
|
||||
if (!cg_context)
|
||||
goto done;
|
||||
|
||||
color = _gdk_quartz_colormap_get_cgcolor_from_pixel (window,
|
||||
private->bg_color.pixel);
|
||||
CGContextSetFillColorWithColor (cg_context, color);
|
||||
|
||||
Reference in New Issue
Block a user