Permalink
Browse files

Fixed a Core Foundation ownership transfer issue

  • Loading branch information...
1 parent 25b1a47 commit b95fda739c872f0e89074ad5bfe3f65f25ec0622 Brian Coyner committed Oct 15, 2011
Showing with 11 additions and 6 deletions.
  1. +4 −0 CoreAnimationFunHouse.xcodeproj/project.pbxproj
  2. +7 −6 CoreAnimationFunHouse/BTSCubicBezierPathView.m
@@ -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;
@@ -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;
};
@@ -44,8 +44,9 @@ @interface BTSCubicBezierPathView() {
NSArray *_hitTestLayers;
}
+CGPathRef BTSPathCreateForCurrentControlPointPositions(CALayer *beginPointLayer, CALayer *endPointLayer, CALayer *beginPointControlPointLayer, CALayer *endPointControlPointLayer);
+
- (void)initLayers;
-- (CGPathRef)createPathForCurrentControlPointPositions;
@end
@@ -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);
}
@@ -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];
@@ -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;
}

0 comments on commit b95fda7

Please sign in to comment.