Cocoa with error: <Error>: doClip: empty path

Cocoa gives an error:

Thu Jun 10 19:13:56 myComputer.local myApp[####] <Error>: doClip: empty path.

But I don’t have this function anywhere in my code (cannot be found by searching in frameworks / project) ... It seems that many people complain about it because they go to console logs but cannot find any reason regarding of what causes her at the progmatic level.

Any thoughts on what the problem is?

+3
source share
4 answers

Drinking with the help of the dump class and nm, I found that this is a function in CoreGraphics (Quartz 2D). It is not declared in the headers, so this is a private function.

doClip , , - . , , , . , , .

( ), , , , Apple. Apple.

+3

, , : CGContextIsPathEmpty (CGContextRef ctx)

:

if(!CGContextIsPathEmpty(c))
    CGContextClip(c);
+4

, . - ?

CGContextClip(ctx);
CGContextTranslateCTM(ctx, 0, image.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextDrawImage(ctx, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), image.CGImage);
+1

I had the same problem when I applied the following methods to adjust the override of the image of the navigation bar specific to landscape orientation. To get rid of the clip error, I commented on a part of the CGContextClip code, as shown below:

@implementation UINavigationBar(CustomBackground)

+ (UIImage *) bgImagePortrait
{
    static UIImage *image = nil;
    if (image == nil) {
        image = [[UIImage imageNamed:@"iPhoneHeader_portrait"] retain];
}
    return image;
}

+ (UIImage *) bgImageLandscape
{
    static UIImage *image = nil;
    if (image == nil) {
    image = [[UIImage imageNamed:@"iPhoneHeader_landscape"] retain];
    }
    return image;
}

- (void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
    if ([self isMemberOfClass:[UINavigationBar class]] == NO) {
    return;
}
    UIImage *image = (self.frame.size.width > 320) ?
    [UINavigationBar bgImageLandscape] : [UINavigationBar bgImagePortrait];
    //CGContextClip(ctx); // Causes '<Error>: doClip: empty path.' error when changing views.
    CGContextTranslateCTM(ctx, 0, image.size.height);
    CGContextScaleCTM(ctx, 1.0, -1.0);
    CGContextDrawImage(ctx, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), image.CGImage);
}

@end
+1
source

Source: https://habr.com/ru/post/1749509/


All Articles