Safer control of memory allocation of aux_bitmap member of FLView

This commit is contained in:
ManoloFLTK 2019-11-08 21:02:08 +01:00
parent 274d49448e
commit b1bcd1f19f

View File

@ -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