summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2019-11-08 21:02:08 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2019-11-08 21:02:43 +0100
commitb1bcd1f19f5b0edb407a1cf92496fdff5f1b3931 (patch)
treec7ec630a8e31a98f0655f124e392275721c9cadd /src
parent274d49448ed06f4af7f9a0752b74eb023e69d71f (diff)
Safer control of memory allocation of aux_bitmap member of FLView
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 9a66a3479..df7d617bf 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -2202,14 +2202,19 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
- (void)create_aux_bitmap:(CGContextRef)gc retina:(BOOL)r {
+ CGColorSpaceRef cspace = CGBitmapContextGetColorSpace(gc);
+ CFRetain(cspace);
aux_bitmap = CGBitmapContextCreate(NULL, CGBitmapContextGetWidth(gc), CGBitmapContextGetHeight(gc),
CGBitmapContextGetBitsPerComponent(gc), CGBitmapContextGetBytesPerRow(gc),
- CGBitmapContextGetColorSpace(gc), CGBitmapContextGetBitmapInfo(gc));
+ cspace, CGBitmapContextGetBitmapInfo(gc));
if (r) CGContextScaleCTM(aux_bitmap, 2, 2);
}
- (void)reset_aux_bitmap {
- CGContextRelease(aux_bitmap);
- aux_bitmap = NULL;
+ if (aux_bitmap) {
+ CFRelease(CGBitmapContextGetColorSpace(aux_bitmap));
+ CFRelease(aux_bitmap);
+ aux_bitmap = NULL;
+ }
}
#endif
- (BOOL)process_keydown:(NSEvent*)theEvent