Skip to content

Commit

Permalink
Fixed a Core Foundation ownership transfer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Coyner committed Oct 15, 2011
1 parent 25b1a47 commit b95fda7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CoreAnimationFunHouse.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,10 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
};
name = Debug;
Expand All @@ -297,9 +299,11 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
Expand Down
13 changes: 7 additions & 6 deletions CoreAnimationFunHouse/BTSCubicBezierPathView.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ @interface BTSCubicBezierPathView() {
NSArray *_hitTestLayers;
}

CGPathRef BTSPathCreateForCurrentControlPointPositions(CALayer *beginPointLayer, CALayer *endPointLayer, CALayer *beginPointControlPointLayer, CALayer *endPointControlPointLayer);

- (void)initLayers;
- (CGPathRef)createPathForCurrentControlPointPositions;

@end

Expand Down Expand Up @@ -124,7 +125,7 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
[layerToMove setPosition:newPosition];
}

CGPathRef path = [self createPathForCurrentControlPointPositions];
CGPathRef path = BTSPathCreateForCurrentControlPointPositions(_beginPointLayer, _endPointLayer, _beginPointControlPointLayer, _endPointControlPointLayer);
[_shapeLayer setPath:path];
CFRelease(path);
}
Expand Down Expand Up @@ -165,7 +166,7 @@ - (void)initLayers
[_endPointControlPointLayer setPosition:CGPointMake([self bounds].size.width - 40, midY)];

// create the initial path
CGPathRef path = [self createPathForCurrentControlPointPositions];
CGPathRef path = BTSPathCreateForCurrentControlPointPositions(_beginPointLayer, _endPointLayer, _beginPointControlPointLayer, _endPointControlPointLayer);

_shapeLayer = [CAShapeLayer layer];
[_shapeLayer setPath:path];
Expand All @@ -185,11 +186,11 @@ - (void)initLayers
}

// ownership is transferred to the caller
- (CGPathRef)createPathForCurrentControlPointPositions
CGPathRef BTSPathCreateForCurrentControlPointPositions(CALayer *beginPointLayer, CALayer *endPointLayer, CALayer *beginPointControlPointLayer, CALayer *endPointControlPointLayer)
{
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, [_beginPointLayer position].x, [_beginPointLayer position].y);
CGPathAddCurveToPoint(path, NULL, [_beginPointControlPointLayer position].x, [_beginPointControlPointLayer position].y, [_endPointControlPointLayer position].x, [_endPointControlPointLayer position].y, [_endPointLayer position].x, [_endPointLayer position].y);
CGPathMoveToPoint(path, NULL, [beginPointLayer position].x, [beginPointLayer position].y);
CGPathAddCurveToPoint(path, NULL, [beginPointControlPointLayer position].x, [beginPointControlPointLayer position].y, [endPointControlPointLayer position].x, [endPointControlPointLayer position].y, [endPointLayer position].x, [endPointLayer position].y);
return path;

}
Expand Down

0 comments on commit b95fda7

Please sign in to comment.