Re: Thousands of leaked CGContext ?
Re: Thousands of leaked CGContext ?
- Subject: Re: Thousands of leaked CGContext ?
- From: David Duncan <email@hidden>
- Date: Fri, 17 Apr 2015 10:09:53 -0700
> On Apr 17, 2015, at 2:38 AM, Eric Matecki <email@hidden> wrote:
>
> Hi,
>
> (I know this is not 100% Cocoa, but it isn't 100% CoreGraphics either...)
>
> I'm drawing to an NSWindow with CoreGraphics, and each time there is a leaked CGContext, CGContextDelegate, CGColorTransform, NSBitmapGraphicsContext, and NSFocusStack (one of each).
>
>
> Here is how I do it :
>
> CGDataProviderDirectCallbacks callbacks = {
> 0,
> &MyProviderGetBytePointer,
> &MyProviderReleaseBytePointer,
> &MyProviderGetBytesAtPosition,
> &MyProviderReleaseInfo
> };
>
> MyProviderStruct mps = { mBlock, mDirtyRect.X(), mDirtyRect.Y() };
>
> CGDataProviderRef provider = CGDataProviderCreateDirect( &mps, sizeof(mps), &callbacks );
>
> NSWindow* window = (NSWindow*)Window();
What does this line do?
> CGImageRef image = CGImageCreate( size_t(mDirtyRect.W()), size_t(mDirtyRect.H()), 8, 32, size_t(mBlock->Width()*4),
> [[window colorSpace] CGColorSpace], kCGBitmapByteOrder32Big | kCGImageAlphaNoneSkipFirst,
> provider, NULL, false, kCGRenderingIntentRelativeColorimetric );
>
> CGContextRef myContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
>
> CGContextDrawImage( myContext, CGRectMake( mDirtyRect.X(), geom.H() - mDirtyRect.Y() - mDirtyRect.H(),
> mDirtyRect.W(), mDirtyRect.H() ), image );
>
> CGContextFlush( myContext );
> CGImageRelease( image );
> CGDataProviderRelease( provider );
>
>
> I don't release the CGContextRef because I don't 'create' it.
> If I release it, the app doesn't crash but doesn't draw anything anymore after the first one.
>
> My data provider just copy bytes from a legacy data structure.
>
> What am I doing wrong ?
> Or maybe there is a better way of doing this ?
>
> Thanks for any help !
>
> --
> Keep intel OUTSIDE my Mac !
> Hiii !!! I can see Intel chips creeping around my G5 !
>
> Eric M.
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden