Permalink
Browse files

Debug a retain cycle; moved ivars to implementation; cleared all warn…

…ings generated using my larger set of warnings
  • Loading branch information...
1 parent 05aa188 commit 06980a2878342bb988a0c68da08b7fc6c897a67a @dhoerl18 dhoerl18 committed Dec 2, 2011
Showing with 343 additions and 393 deletions.
  1. +0 −6 Core/Source/DTAttributedTextCell.h
  2. +6 −0 Core/Source/DTAttributedTextCell.m
  3. +3 −48 Core/Source/DTAttributedTextContentView.h
  4. +31 −9 Core/Source/DTAttributedTextContentView.m
  5. +0 −4 Core/Source/DTAttributedTextView.h
  6. +4 −0 Core/Source/DTAttributedTextView.m
  7. +0 −8 Core/Source/DTCSSListStyle.h
  8. +10 −2 Core/Source/DTCSSListStyle.m
  9. +0 −4 Core/Source/DTCSSStylesheet.h
  10. +4 −0 Core/Source/DTCSSStylesheet.m
  11. +0 −4 Core/Source/DTCoreTextFontCollection.h
  12. +4 −0 Core/Source/DTCoreTextFontCollection.m
  13. +0 −22 Core/Source/DTCoreTextFontDescriptor.h
  14. +23 −1 Core/Source/DTCoreTextFontDescriptor.m
  15. +0 −26 Core/Source/DTCoreTextGlyphRun.h
  16. +27 −1 Core/Source/DTCoreTextGlyphRun.m
  17. +0 −15 Core/Source/DTCoreTextLayoutFrame.h
  18. +31 −35 Core/Source/DTCoreTextLayoutFrame.m
  19. +0 −18 Core/Source/DTCoreTextLayoutLine.h
  20. +25 −11 Core/Source/DTCoreTextLayoutLine.m
  21. +0 −7 Core/Source/DTCoreTextLayouter.h
  22. +7 −0 Core/Source/DTCoreTextLayouter.m
  23. +0 −16 Core/Source/DTCoreTextParagraphStyle.h
  24. +24 −5 Core/Source/DTCoreTextParagraphStyle.m
  25. +0 −49 Core/Source/DTHTMLElement.h
  26. +52 −8 Core/Source/DTHTMLElement.m
  27. +0 −16 Core/Source/DTLazyImageView.h
  28. +33 −13 Core/Source/DTLazyImageView.m
  29. +0 −6 Core/Source/DTLinkButton.h
  30. +9 −4 Core/Source/DTLinkButton.m
  31. +0 −11 Core/Source/DTTextAttachment.h
  32. +11 −4 Core/Source/DTTextAttachment.m
  33. +0 −9 Core/Source/DTWebVideoView.h
  34. +7 −0 Core/Source/DTWebVideoView.m
  35. +17 −18 Core/Source/NSAttributedString+HTML.m
  36. +3 −1 Core/Source/NSAttributedStringRunDelegates.m
  37. +4 −4 Core/Source/NSData+Base64.m
  38. +5 −5 Core/Source/NSString+HTML.m
  39. +1 −1 Core/Source/NSString+UTF8Cleaner.m
  40. +2 −2 Core/Source/UIColor+HTML.m
@@ -9,12 +9,6 @@
@class DTAttributedTextContentView;
@interface DTAttributedTextCell : UITableViewCell
-{
- NSAttributedString *_attributedString;
- DTAttributedTextContentView *_attributedTextContextView;
-
- NSUInteger _htmlHash; // preserved hash to avoid relayouting for same HTML
-}
@property (nonatomic, strong) NSAttributedString *attributedString;
@property (nonatomic, readonly) DTAttributedTextContentView *attributedTextContextView;
@@ -10,6 +10,12 @@
#import "DTAttributedTextContentView.h"
@implementation DTAttributedTextCell
+{
+ NSAttributedString *_attributedString;
+ DTAttributedTextContentView *_attributedTextContextView;
+
+ NSUInteger _htmlHash; // preserved hash to avoid relayouting for same HTML
+}
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier accessoryType:(UITableViewCellAccessoryType)accessoryType
{
@@ -13,28 +13,13 @@
#import "DTCoreTextLayouter.h"
#import "DTTextAttachment.h"
-#ifndef __IPHONE_4_3
-#define __IPHONE_4_3 40300
-#endif
-
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_3
#define SELF selfLock
// Useful to find deadlocks
#define SYNCHRONIZE_START(lock) /* NSLog(@"LOCK: FUNC=%s Line=%d", __func__, __LINE__), */dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER);
#define SYNCHRONIZE_END(lock) dispatch_semaphore_signal(lock) /*, NSLog(@"UN-LOCK")*/;
-#else
-
-#define SELF self
-
-#define SYNCHRONIZE_START(obj) @synchronized(obj)
-#define SYNCHRONIZE_END(obj)
-
-#endif
-
-
@class DTAttributedTextContentView;
@class DTCoreTextLayoutFrame;
@@ -59,37 +44,6 @@
@interface DTAttributedTextContentView : UIView
-{
- NSAttributedString *_attributedString;
- UIEdgeInsets edgeInsets;
- BOOL drawDebugFrames;
- BOOL shouldDrawImages;
- BOOL shouldLayoutCustomSubviews;
-
- NSMutableSet *customViews;
- NSMutableDictionary *customViewsForLinksIndex;
- NSMutableDictionary *customViewsForAttachmentsIndex;
-
- BOOL _isTiling;
-
- DTCoreTextLayouter *_layouter;
- DTCoreTextLayoutFrame *_layoutFrame;
-
- CGPoint _layoutOffset;
- CGSize _backgroundOffset;
-
- // lookup bitmask what delegate methods are implemented
- struct
- {
- unsigned int delegateSupportsCustomViewsForAttachments:1;
- unsigned int delegateSupportsCustomViewsForLinks:1;
- unsigned int delegateSupportsGenericCustomViews:1;
- unsigned int delegateSupportsNotificationAfterDrawing:1;
- } _delegateFlags;
-
- __unsafe_unretained id <DTAttributedTextContentViewDelegate> _delegate;
-}
-
- (id)initWithAttributedString:(NSAttributedString *)attributedString width:(CGFloat)width;
- (void)layoutSubviewsInRect:(CGRect)rect;
@@ -99,8 +53,9 @@
- (CGSize)attributedStringSizeThatFits:(CGFloat)width;
-@property (strong) DTCoreTextLayouter *layouter;
-@property (strong) DTCoreTextLayoutFrame *layoutFrame;
+#warning Do you really want atomic here???
+@property (atomic, strong) DTCoreTextLayouter *layouter;
+@property (atomic, strong) DTCoreTextLayoutFrame *layoutFrame;
@property (nonatomic, strong) NSMutableSet *customViews;
@@ -19,6 +19,36 @@
#import <QuartzCore/QuartzCore.h>
@interface DTAttributedTextContentView ()
+{
+ NSAttributedString *_attributedString;
+ UIEdgeInsets edgeInsets;
+ BOOL drawDebugFrames;
+ BOOL shouldDrawImages;
+ BOOL shouldLayoutCustomSubviews;
+
+ NSMutableSet *customViews;
+ NSMutableDictionary *customViewsForLinksIndex;
+ NSMutableDictionary *customViewsForAttachmentsIndex;
+
+ BOOL _isTiling;
+
+ DTCoreTextLayouter *_layouter;
+ DTCoreTextLayoutFrame *_layoutFrame;
+
+ CGPoint _layoutOffset;
+ CGSize _backgroundOffset;
+
+ // lookup bitmask what delegate methods are implemented
+ struct
+ {
+ unsigned int delegateSupportsCustomViewsForAttachments:1;
+ unsigned int delegateSupportsCustomViewsForLinks:1;
+ unsigned int delegateSupportsGenericCustomViews:1;
+ unsigned int delegateSupportsNotificationAfterDrawing:1;
+ } _delegateFlags;
+
+ __unsafe_unretained id <DTAttributedTextContentViewDelegate> _delegate;
+}
@property (nonatomic, strong) NSMutableDictionary *customViewsForLinksIndex;
@property (nonatomic, strong) NSMutableDictionary *customViewsForAttachmentsIndex;
@@ -50,7 +80,6 @@ + (Class)layerClass
@end
-static int cv;
@implementation DTAttributedTextContentView
@synthesize selfLock;
@@ -90,8 +119,6 @@ - (id)initWithFrame:(CGRect)frame
if ((self = [super initWithFrame:frame]))
{
[self setup];
-++cv;
-NSLog(@"cv alloc (%d)", cv);
}
return self;
}
@@ -120,9 +147,6 @@ - (void)dealloc
[self removeAllCustomViews];
dispatch_release(selfLock);
-
-NSLog(@"cv DEALLOC (%d)", --cv);
-
}
- (void)layoutSubviewsInRect:(CGRect)rect
@@ -161,7 +185,7 @@ - (void)layoutSubviewsInRect:(CGRect)rect
{
NSRange lineRange = [oneLine stringRange];
- NSInteger skipRunsBeforeLocation = 0;
+ NSUInteger skipRunsBeforeLocation = 0;
for (DTCoreTextGlyphRun *oneRun in oneLine.glyphRuns)
{
@@ -318,8 +342,6 @@ - (void)layoutSubviewsInRect:(CGRect)rect
[CATransaction commit];
}
SYNCHRONIZE_END(SELF)
-
- [theLayoutFrame dump:@"layoutSubviewsInRect"];
}
- (void)layoutSubviews
@@ -11,10 +11,6 @@
@class DTAttributedTextView;
@interface DTAttributedTextView : UIScrollView
-{
- DTAttributedTextContentView *contentView;
- UIView *backgroundView;
-}
@property (nonatomic, strong) NSAttributedString *attributedString;
@@ -20,6 +20,10 @@ - (void)setup;
@implementation DTAttributedTextView
+{
+ DTAttributedTextContentView *contentView;
+ UIView *backgroundView;
+}
- (id)initWithFrame:(CGRect)frame
{
@@ -31,14 +31,6 @@ typedef enum
} DTCSSListStylePosition;
@interface DTCSSListStyle : NSObject
-{
- BOOL _inherit;
-
- DTCSSListStyleType _type;
- DTCSSListStylePosition _position;
-
- NSString *_imageName;
-}
@property (nonatomic, assign) BOOL inherit;
@property (nonatomic, assign) DTCSSListStyleType type;
@@ -22,6 +22,14 @@ - (void)updateFromStyleDictionary:(NSDictionary *)styles;
@implementation DTCSSListStyle
+{
+ BOOL _inherit;
+
+ DTCSSListStyleType _type;
+ DTCSSListStylePosition _position;
+
+ NSString *_imageName;
+}
+ (DTCSSListStyle *)listStyleWithStyles:(NSDictionary *)styles
{
@@ -317,14 +325,14 @@ - (NSString *)prefixWithCounter:(NSInteger)counter
case DTCSSListStyleTypeUpperAlpha:
case DTCSSListStyleTypeUpperLatin:
{
- char letter = 'A' + counter - 1;
+ char letter = 'A' + (char)(counter - 1);
token = [NSString stringWithFormat:@"%c.", letter];
break;
}
case DTCSSListStyleTypeLowerAlpha:
case DTCSSListStyleTypeLowerLatin:
{
- char letter = 'a' + counter - 1;
+ char letter = 'a' + (char)(counter - 1);
token = [NSString stringWithFormat:@"%c.", letter];
break;
}
@@ -11,10 +11,6 @@
@class DTHTMLElement;
@interface DTCSSStylesheet : NSObject
-{
- NSMutableDictionary *_styles;
-
-}
- (id)initWithStyleBlock:(NSString *)css;
@@ -22,6 +22,10 @@ @interface DTCSSStylesheet ()
@implementation DTCSSStylesheet
+{
+ NSMutableDictionary *_styles;
+
+}
- (id)initWithStyleBlock:(NSString *)css
{
@@ -12,10 +12,6 @@
@interface DTCoreTextFontCollection : NSObject
-{
- NSArray *_fontDescriptors;
- NSCache *fontMatchCache;
-}
+ (DTCoreTextFontCollection *)availableFontsCollection;
@@ -22,6 +22,10 @@ @interface DTCoreTextFontCollection ()
@implementation DTCoreTextFontCollection
+{
+ NSArray *_fontDescriptors;
+ NSCache *fontMatchCache;
+}
+ (DTCoreTextFontCollection *)availableFontsCollection
{
@@ -11,28 +11,6 @@
@interface DTCoreTextFontDescriptor : NSObject <NSCopying, NSCoding>
-{
- NSString *fontFamily;
- NSString *fontName;
-
- CGFloat pointSize;
-
- // symbolic traits
- BOOL boldTrait;
- BOOL italicTrait;
- BOOL expandedTrait;
- BOOL condensedTrait;
- BOOL monospaceTrait;
- BOOL verticalTrait;
- BOOL UIoptimizedTrait;
-
- CTFontStylisticClass stylisticClass;
-
- BOOL smallCapsFeature;
-
- BOOL _hashSet;
- NSUInteger _hash;
-}
// sets the font face name to use for a specific font family
+ (void)setSmallCapsFontName:(NSString *)fontName forFontFamily:(NSString *)fontFamily bold:(BOOL)bold italic:(BOOL)italic;
@@ -21,6 +21,28 @@ + (NSCache *)fontCache;
@end
@implementation DTCoreTextFontDescriptor
+{
+ NSString *fontFamily;
+ NSString *fontName;
+
+ CGFloat pointSize;
+
+ // symbolic traits
+ BOOL boldTrait;
+ BOOL italicTrait;
+ BOOL expandedTrait;
+ BOOL condensedTrait;
+ BOOL monospaceTrait;
+ BOOL verticalTrait;
+ BOOL UIoptimizedTrait;
+
+ CTFontStylisticClass stylisticClass;
+
+ BOOL smallCapsFeature;
+
+ BOOL _hashSet;
+ NSUInteger _hash;
+}
+ (void)initialize
{
@@ -478,7 +500,7 @@ - (CTFontRef)newMatchingFont
}
else
{
- NSLog(@"No matches for %@", (__bridge id)fontDesc);
+ //NSLog(@"No matches for %@", (__bridge id)fontDesc);
matchingFont = nil;
}
}
@@ -14,32 +14,6 @@
@class DTTextAttachment;
@interface DTCoreTextGlyphRun : NSObject
-{
- CTRunRef _run;
-
- CGRect _frame;
-
- CGFloat _offset; // x distance from line origin
- CGFloat ascent;
- CGFloat descent;
- CGFloat leading;
- CGFloat width;
-
- NSInteger numberOfGlyphs;
-
- const CGPoint *glyphPositionPoints;
- BOOL needToFreeGlyphPositionPoints;
-
- __unsafe_unretained DTCoreTextLayoutLine *_line; // retain cycle, since these objects are retained by the _line
- __unsafe_unretained NSDictionary *attributes;
- NSArray *stringIndices;
-
- DTTextAttachment *_attachment;
- BOOL _didCheckForAttachmentInAttributes;
- BOOL _didCalculateMetrics;
-
- NSRange _stringRange;
-}
- (id)initWithRun:(CTRunRef)run layoutLine:(DTCoreTextLayoutLine *)layoutLine offset:(CGFloat)offset;
Oops, something went wrong.

0 comments on commit 06980a2

Please sign in to comment.