diff options
Diffstat (limited to 'tikzit/src/common/Shape.m')
-rw-r--r-- | tikzit/src/common/Shape.m | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tikzit/src/common/Shape.m b/tikzit/src/common/Shape.m index eb466e2..e887688 100644 --- a/tikzit/src/common/Shape.m +++ b/tikzit/src/common/Shape.m @@ -61,8 +61,12 @@ - (NSSet*)paths {return paths;} - (void)setPaths:(NSSet *)p { if (paths != p) { +#if __has_feature(objc_arc) + paths = p; +#else [paths release]; paths = [p retain]; +#endif [self calcBoundingRect]; } } @@ -79,16 +83,19 @@ } - (void)dealloc { +#if ! __has_feature(objc_arc) [paths release]; [styleTikz release]; [super dealloc]; +#endif } NSDictionary *shapeDictionary = nil; + (void)addShapesInDir:(NSString*)shapeDir to:(NSMutableDictionary*)shapeDict { NSFileManager *fileManager = [NSFileManager defaultManager]; - NSArray *files = [fileManager directoryContentsAtPath:shapeDir]; + NSError *err = nil; + NSArray *files = [fileManager contentsOfDirectoryAtPath:shapeDir error:&err]; if (files != nil) { NSString *nm; @@ -100,7 +107,9 @@ NSDictionary *shapeDictionary = nil; [shapeDir stringByAppendingPathComponent:f]]; if (sh != nil) { [shapeDict setObject:sh forKey:nm]; +#if ! __has_feature(objc_arc) [sh release]; +#endif } } } @@ -121,7 +130,9 @@ NSDictionary *shapeDictionary = nil; shapes[3], SHAPE_UP_TRIANGLE, shapes[4], SHAPE_DOWN_TRIANGLE, nil]; +#if ! __has_feature(objc_arc) for (int i = 0; i<5; ++i) [shapes[i] release]; +#endif NSString *systemShapeDir = [[SupportDir systemSupportDir] stringByAppendingPathComponent:@"shapes"]; NSString *userShapeDir = [[SupportDir userSupportDir] stringByAppendingPathComponent:@"shapes"]; @@ -136,7 +147,9 @@ NSDictionary *shapeDictionary = nil; postNotificationName:@"ShapeDictionaryReplaced" object:self]; +#if ! __has_feature(objc_arc) [oldShapeDictionary release]; +#endif } + (NSDictionary*)shapeDictionary { @@ -146,7 +159,11 @@ NSDictionary *shapeDictionary = nil; + (Shape*)shapeForName:(NSString*)shapeName { Shape *s = [[[self shapeDictionary] objectForKey:shapeName] copy]; +#if __has_feature(objc_arc) + return s; +#else return [s autorelease]; +#endif } @end |