Skip to content
Browse files

Merge pull request #91 from dhoerl/master

Fixed problem with htmlString
  • Loading branch information...
2 parents 73ea610 + 99bc5e3 commit 243e5c09ee7f289e6bf6b037ff86cbf0c626b577 @odrobnik odrobnik committed Dec 6, 2011
View
4 Core/Source/DTAttributedTextContentView.m
@@ -113,9 +113,7 @@ - (void)setup
_isTiling = YES;
}
- if(!selfLock) {
- selfLock = dispatch_semaphore_create(1);
- }
+ [self selfLock];
}
- (id)initWithFrame:(CGRect)frame
View
2 Core/Source/DTAttributedTextView.h
@@ -14,7 +14,7 @@
@property (nonatomic, strong) NSAttributedString *attributedString;
-@property (nonatomic, readonly) DTAttributedTextContentView *contentView;
+@property (nonatomic, strong, readonly) DTAttributedTextContentView *contentView;
@property (nonatomic, strong) IBOutlet UIView *backgroundView;
@property (nonatomic, unsafe_unretained) IBOutlet id <DTAttributedTextContentViewDelegate> textDelegate;
View
6 Core/Source/DTAttributedTextView.m
@@ -39,17 +39,15 @@ - (id)initWithFrame:(CGRect)frame
- (void)dealloc
{
+ contentView.delegate = nil;
[contentView removeObserver:self forKeyPath:@"frame"];
}
- (void)layoutSubviews
{
[super layoutSubviews];
- if (!contentView)
- {
- [self addSubview:self.contentView];
- }
+ [self contentView];
// layout custom subviews for visible area
[contentView layoutSubviewsInRect:self.bounds];
View
4 Core/Source/DTCoreTextFontDescriptor.h
@@ -41,7 +41,7 @@
@property (nonatomic, copy) NSString *fontFamily;
@property (nonatomic, copy) NSString *fontName;
-@property (nonatomic, assign) CGFloat pointSize;
+@property (nonatomic) CGFloat pointSize;
@property (nonatomic) BOOL boldTrait;
@property (nonatomic) BOOL italicTrait;
@@ -51,7 +51,7 @@
@property (nonatomic) BOOL verticalTrait;
@property (nonatomic) BOOL UIoptimizedTrait;
-@property (nonatomic, assign) CTFontSymbolicTraits symbolicTraits;
+@property (nonatomic) CTFontSymbolicTraits symbolicTraits;
@property (nonatomic) CTFontStylisticClass stylisticClass;
View
4 Core/Source/DTCoreTextFontDescriptor.m
@@ -589,8 +589,10 @@ - (void)setFontAttributes:(NSDictionary *)attributes
if (!attributes)
{
self.fontFamily = nil;
+ self.fontName = nil;
self.pointSize = 12;
-
+ self.symbolicTraits = 0;
+
boldTrait = NO;
italicTrait = NO;
expandedTrait = NO;
View
2 Core/Source/DTCoreTextGlyphRun.h
@@ -28,7 +28,7 @@
@property (nonatomic, assign, readonly) CGRect frame;
@property (nonatomic, assign, readonly) NSInteger numberOfGlyphs;
-@property (nonatomic, assign, readonly) NSDictionary *attributes; // subtle simulator bug - use assign not __unsafe_unretained
+@property (nonatomic, unsafe_unretained, readonly) NSDictionary *attributes; // subtle simulator bug - use assign not __unsafe_unretained in 4.2
@property (nonatomic, assign, readonly) CGFloat ascent;
@property (nonatomic, assign, readonly) CGFloat descent;
View
2 Core/Source/DTCoreTextGlyphRun.m
@@ -20,7 +20,7 @@
@interface DTCoreTextGlyphRun ()
@property (nonatomic, assign) CGRect frame;
@property (nonatomic, assign) NSInteger numberOfGlyphs;
-@property (nonatomic, assign) NSDictionary *attributes;
+@property (nonatomic, unsafe_unretained, readwrite) NSDictionary *attributes;
@property (nonatomic, assign) dispatch_semaphore_t runLock;
@end
View
6 Core/Source/DTCoreTextLayouter.m
@@ -13,7 +13,7 @@ @interface DTCoreTextLayouter ()
@property (nonatomic, strong) NSMutableArray *frames;
@property (nonatomic, assign) dispatch_semaphore_t selfLock;
-- (CTFramesetterRef) framesetter;
+- (CTFramesetterRef)framesetter;
- (void)discardFramesetter;
@end
@@ -49,7 +49,9 @@ - (id)initWithAttributedString:(NSAttributedString *)attributedString
- (void)dealloc
{
+ SYNCHRONIZE_START(self) // just to be sure
[self discardFramesetter];
+ SYNCHRONIZE_END(self)
dispatch_release(selfLock);
}
@@ -105,7 +107,7 @@ - (DTCoreTextLayoutFrame *)layoutFrameAtIndex:(NSInteger)index
#pragma mark Properties
- (CTFramesetterRef)framesetter
{
- // if (!framesetter)
+ if (!framesetter) // Race condition, could be null now but set when we get into the SYNCHRONIZE block - so do the test twice
{
SYNCHRONIZE_START(self)
{
View
33 Core/Source/DTCoreTextParagraphStyle.m
@@ -8,7 +8,7 @@
#import "DTCoreTextParagraphStyle.h"
-static NSCache *_paragraphStyleCache = nil;
+static NSCache *_paragraphStyleCache;
#if ALLOW_IPHONE_SPECIAL_CASES
#define SPECIAL_LIST_INDENT 27.0f
@@ -74,10 +74,8 @@ + (DTCoreTextParagraphStyle *)paragraphStyleWithCTParagraphStyle:(CTParagraphSty
}
- (id)init
-{
- self = [super init];
-
- if (self)
+{
+ if ((self = [super init]))
{
// defaults
firstLineIndent = 0.0;
@@ -96,19 +94,18 @@ - (id)init
- (id)initWithCTParagraphStyle:(CTParagraphStyleRef)ctParagraphStyle
-{
- self = [super init];
-
- if (self)
+{
+ if ((self = [super init]))
{
CTParagraphStyleGetValueForSpecifier(ctParagraphStyle, kCTParagraphStyleSpecifierAlignment,sizeof(textAlignment), &textAlignment);
CTParagraphStyleGetValueForSpecifier(ctParagraphStyle, kCTParagraphStyleSpecifierFirstLineHeadIndent, sizeof(firstLineIndent), &firstLineIndent);
CTParagraphStyleGetValueForSpecifier(ctParagraphStyle, kCTParagraphStyleSpecifierDefaultTabInterval, sizeof(defaultTabInterval), &defaultTabInterval);
+
- NSArray *tabStops;
- if (CTParagraphStyleGetValueForSpecifier(ctParagraphStyle, kCTParagraphStyleSpecifierTabStops, sizeof(tabStops), &tabStops))
- {
- self.tabStops = tabStops;
+ __unsafe_unretained NSArray *stops; // Could use a CFArray too, leave as a reminder how to do this in the future
+ if (CTParagraphStyleGetValueForSpecifier(ctParagraphStyle, kCTParagraphStyleSpecifierTabStops, sizeof(stops), &stops))
+ if(stops) {
+ self.tabStops = stops;
}
CTParagraphStyleGetValueForSpecifier(ctParagraphStyle, kCTParagraphStyleSpecifierParagraphSpacing, sizeof(paragraphSpacing), &paragraphSpacing);
CTParagraphStyleGetValueForSpecifier(ctParagraphStyle, kCTParagraphStyleSpecifierParagraphSpacingBefore,sizeof(paragraphSpacingBefore), &paragraphSpacingBefore);
@@ -152,13 +149,16 @@ - (CTParagraphStyleRef)createCTParagraphStyle
tmpParagraphSpacingBefore *= lineHeightMultiple;
}
+ // This just makes it that much easier to track down memory issues with tabstops
+ CFArrayRef stops = _tabStops ? CFArrayCreateCopy (NULL, (__bridge CFArrayRef)_tabStops) : NULL;
+
CTParagraphStyleSetting settings[] =
{
{kCTParagraphStyleSpecifierAlignment, sizeof(textAlignment), &textAlignment},
{kCTParagraphStyleSpecifierFirstLineHeadIndent, sizeof(firstLineIndent), &firstLineIndent},
{kCTParagraphStyleSpecifierDefaultTabInterval, sizeof(defaultTabInterval), &defaultTabInterval},
- {kCTParagraphStyleSpecifierTabStops, sizeof(_tabStops), &_tabStops},
+ {kCTParagraphStyleSpecifierTabStops, sizeof(stops), &stops},
{kCTParagraphStyleSpecifierParagraphSpacing, sizeof(tmpParagraphSpacing), &tmpParagraphSpacing},
{kCTParagraphStyleSpecifierParagraphSpacingBefore, sizeof(tmpParagraphSpacingBefore), &tmpParagraphSpacingBefore},
@@ -171,7 +171,10 @@ - (CTParagraphStyleRef)createCTParagraphStyle
{kCTParagraphStyleSpecifierMaximumLineHeight, sizeof(maximumLineHeight), &maximumLineHeight}
};
- return CTParagraphStyleCreate(settings, 11);
+ CTParagraphStyleRef ret = CTParagraphStyleCreate(settings, 11);
+ if (stops) CFRelease(stops);
+
+ return ret;
}
- (BOOL)addTabStopAtPosition:(CGFloat)position alignment:(CTTextAlignment)alignment
View
2 Core/Source/NSAttributedString+HTML.m
@@ -1301,7 +1301,7 @@ - (NSString *)htmlString
[retString appendFormat:@"</%@>\n", blockElement];
}
- NSLog(@"%@", retString);
+ //NSLog(@"%@", retString);
return retString;
}

0 comments on commit 243e5c0

Please sign in to comment.
Something went wrong with that request. Please try again.