From 9f00df4e57e917035d2f939ce70ccf2ee83a9725 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Mon, 21 May 2018 15:20:08 +1000 Subject: Backport: Remove CGContextRef field in QuartzTextLayout as it is only used in draw method where it can easily be provided. Retaining a CGContextRef in QuartzTextLayout could lead to it being used after being invalidated. Backport of changeset 6963:a8774d6100a6. --- cocoa/PlatCocoa.mm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'cocoa/PlatCocoa.mm') diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index fe1873ffa..b517a7e6a 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -134,7 +134,7 @@ SurfaceImpl::SurfaceImpl() y = 0; gc = NULL; - textLayout.reset(new QuartzTextLayout(nullptr)); + textLayout.reset(new QuartzTextLayout()); codePage = 0; verticalDeviceResolution = 0; @@ -156,7 +156,6 @@ SurfaceImpl::~SurfaceImpl() void SurfaceImpl::Clear() { - textLayout->setContext(nullptr); if (bitmapData) { bitmapData.reset(); @@ -206,7 +205,6 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID) Release(); gc = static_cast(sid); CGContextSetLineWidth(gc, 1.0); - textLayout->setContext(gc); } //-------------------------------------------------------------------------------------------------- @@ -244,7 +242,6 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface* surface_, WindowID // and we have no use for the bitmap without the context bitmapData.reset(); } - textLayout->setContext (gc); // the context retains the color space, so we can release it CGColorSpaceRelease(colorSpace); @@ -920,7 +917,7 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION yba CGColorRelease(color); textLayout->setText(s, len, encoding, *style); - textLayout->draw(rc.left, ybase); + textLayout->draw(gc, rc.left, ybase); } //-------------------------------------------------------------------------------------------------- -- cgit v1.2.3