Permalink
Browse files

preserve mutability to prevent crash

  • Loading branch information...
1 parent d00c9f2 commit 3cbf7be2e146a4ae98f8c1a41ee15950e8beb505 @odrobnik odrobnik committed May 4, 2011
Showing with 16 additions and 7 deletions.
  1. +1 −1 Classes/DTCoreTextParagraphStyle.h
  2. +15 −6 Classes/DTCoreTextParagraphStyle.m
@@ -21,7 +21,7 @@
CTTextAlignment textAlignment;
CTWritingDirection writingDirection;
- NSMutableArray *tabStops;
+ NSMutableArray *_tabStops;
}
@property (nonatomic, assign) CGFloat firstLineIndent;
@@ -36,7 +36,7 @@ - (id)init
- (void)dealloc
{
- [tabStops release];
+ [_tabStops release];
[super dealloc];
}
@@ -49,7 +49,7 @@ - (CTParagraphStyleRef)createCTParagraphStyle
{kCTParagraphStyleSpecifierAlignment, sizeof(textAlignment), &textAlignment},
{kCTParagraphStyleSpecifierFirstLineHeadIndent, sizeof(firstLineIndent), &firstLineIndent},
{kCTParagraphStyleSpecifierDefaultTabInterval, sizeof(defaultTabInterval), &defaultTabInterval},
- {kCTParagraphStyleSpecifierTabStops, sizeof(tabStops), &tabStops},
+ {kCTParagraphStyleSpecifierTabStops, sizeof(_tabStops), &_tabStops},
{kCTParagraphStyleSpecifierParagraphSpacing, sizeof(paragraphSpacing), &paragraphSpacing},
{kCTParagraphStyleSpecifierParagraphSpacingBefore, sizeof(paragraphSpacingBefore), &paragraphSpacingBefore},
{kCTParagraphStyleSpecifierHeadIndent, sizeof(headIndent), &headIndent},
@@ -64,13 +64,13 @@ - (CTParagraphStyleRef)createCTParagraphStyle
- (void)addTabStopAtPosition:(CGFloat)position alignment:(CTTextAlignment)alignment
{
- if (!tabStops)
+ if (!_tabStops)
{
- tabStops = [[NSMutableArray alloc] init];
+ _tabStops = [[NSMutableArray alloc] init];
}
CTTextTabRef tab = CTTextTabCreate(alignment, position, NULL);
- [tabStops addObject:(id)tab];
+ [_tabStops addObject:(id)tab];
CFRelease(tab);
}
@@ -95,6 +95,15 @@ - (id)copyWithZone:(NSZone *)zone
#pragma mark Properties
+- (void)setTabStops:(NSMutableArray *)tabStops
+{
+ if (tabStops != _tabStops)
+ {
+ [_tabStops release];
+ _tabStops = [tabStops mutableCopy]; // keep mutability
+ }
+}
+
@synthesize firstLineIndent;
@synthesize defaultTabInterval;
@synthesize paragraphSpacingBefore;
@@ -104,6 +113,6 @@ - (id)copyWithZone:(NSZone *)zone
@synthesize headIndent;
@synthesize textAlignment;
@synthesize writingDirection;
-@synthesize tabStops;
+@synthesize tabStops = _tabStops;
@end

0 comments on commit 3cbf7be

Please sign in to comment.