Skip to content

Commit

Permalink
more ARC fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joshaber committed Apr 9, 2012
1 parent 8bd71fb commit 3358884
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 40 deletions.
2 changes: 1 addition & 1 deletion lib/Support/CoreText+Additions.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void AB_CTFrameGetRectsForRangeWithAggregationType(CTFrameRef frame, CFRange ran
CGRect bounds;
CGPathIsRect(CTFrameGetPath(frame), &bounds);

NSArray *lines = (NSArray *)CTFrameGetLines(frame);
NSArray *lines = (__bridge NSArray *)CTFrameGetLines(frame);
CFIndex linesCount = [lines count];
CGPoint *lineOrigins = (CGPoint *) malloc(sizeof(CGPoint) * linesCount);
CTFrameGetLineOrigins(frame, CFRangeMake(0, linesCount), lineOrigins);
Expand Down
2 changes: 1 addition & 1 deletion lib/UIKit/TUIAttributedString.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ - (void)setLineHeight:(CGFloat)f inRange:(NSRange)range
};

CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, sizeof(settings) / sizeof(settings[0]));
[self addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:(id)paragraphStyle, kCTParagraphStyleAttributeName, nil] range:range];
[self addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:(__bridge id)paragraphStyle, kCTParagraphStyleAttributeName, nil] range:range];
CFRelease(paragraphStyle);
}

Expand Down
4 changes: 1 addition & 3 deletions lib/UIKit/TUINSView+NSTextInputClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actu
- (NSUInteger)characterIndexForPoint:(NSPoint)screenPoint
{
// NSLog(@"%@ %@", NSStringFromSelector(_cmd), NSStringFromPoint(screenPoint));
_tempTextRendererForTextInputClient = [[self _textRendererAtScreenPoint:screenPoint] retain];
_tempTextRendererForTextInputClient = [self _textRendererAtScreenPoint:screenPoint];
if(_tempTextRendererForTextInputClient) {
NSPoint locationInWindow = [[self window] convertScreenToBase:screenPoint];
CGPoint vp = [_tempTextRendererForTextInputClient.view localPointForLocationInWindow:locationInWindow];
Expand Down Expand Up @@ -101,8 +101,6 @@ - (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer
screenRect.origin = [_tempTextRendererForTextInputClient.view.nsWindow convertBaseToScreen:windowRelativeRect.origin];

ret = screenRect;

[_tempTextRendererForTextInputClient release];
}

_tempTextRendererForTextInputClient = nil; // reset (this is the last call in the dictionary-lookup sequence
Expand Down
2 changes: 0 additions & 2 deletions lib/UIKit/TUITableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ - (void)reloadData
[self.delegate tableViewWillReloadData:self];
}

[_selectedIndexPath release]; // should already be nil
_selectedIndexPath = nil;

// need to recycle all visible cells, have them be regenerated on layoutSubviews
Expand Down Expand Up @@ -993,7 +992,6 @@ - (void)layoutSubviews

- (void)reloadLayout
{
[_sectionInfo release];
_sectionInfo = nil; // will be regenerated on next layout

[self _preLayoutCells];
Expand Down
3 changes: 1 addition & 2 deletions lib/UIKit/TUITextRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (void)_resetFrame
_ct_path = NULL;
}

[lineRects release], lineRects = nil;
lineRects = nil;
}

- (void)_resetFramesetter
Expand Down Expand Up @@ -356,7 +356,6 @@ - (CGSize)sizeConstrainedToWidth:(CGFloat)width numberOfLines:(NSUInteger)number
NSMutableAttributedString *fake = [self.attributedString mutableCopy];
[fake replaceCharactersInRange:NSMakeRange(0, [fake length]) withString:@"M"];
CGFloat singleLineHeight = [fake ab_sizeConstrainedToWidth:width].height;
[fake release];
CGFloat maxHeight = singleLineHeight * numberOfLines;
CGSize size = [self sizeConstrainedToWidth:width];
return CGSizeMake(size.width, MIN(maxHeight, size.height));
Expand Down
17 changes: 3 additions & 14 deletions lib/UIKit/TUITextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ @implementation TUITextViewAutocorrectedPair
@synthesize correctionResult;
@synthesize originalString;

- (void)dealloc {
[correctionResult release];
[originalString release];
[super dealloc];
}

- (BOOL)isEqual:(id)object {
if(![object isKindOfClass:[TUITextViewAutocorrectedPair class]]) return NO;

Expand Down Expand Up @@ -395,7 +389,7 @@ - (void)_checkSpelling

if(result.resultType == NSTextCheckingTypeCorrection || result.resultType == NSTextCheckingTypeReplacement) {
NSString *oldString = [[[renderer backingStore] string] substringWithRange:result.range];
TUITextViewAutocorrectedPair *correctionPair = [[[TUITextViewAutocorrectedPair alloc] init] autorelease];
TUITextViewAutocorrectedPair *correctionPair = [[TUITextViewAutocorrectedPair alloc] init];
correctionPair.correctionResult = result;
correctionPair.originalString = oldString;

Expand Down Expand Up @@ -458,7 +452,6 @@ - (NSMenu *)menuForEvent:(NSEvent *)event
[menuItem setTarget:self];
[menuItem setRepresentedObject:matchingAutocorrectPair.originalString];
[menu addItem:menuItem];
[menuItem release];

[menu addItem:[NSMenuItem separatorItem]];
}
Expand Down Expand Up @@ -491,7 +484,6 @@ - (NSMenu *)menuForEvent:(NSEvent *)event
[spellingAndGrammarMenu addItemWithTitle:NSLocalizedString(@"Check Grammar With Spelling", @"") action:@selector(toggleGrammarChecking:) keyEquivalent:@""];
[spellingAndGrammarMenu addItemWithTitle:NSLocalizedString(@"Correct Spelling Automatically", @"") action:@selector(toggleAutomaticSpellingCorrection:) keyEquivalent:@""];
[spellingAndGrammarItem setSubmenu:spellingAndGrammarMenu];
[spellingAndGrammarMenu release];

NSMenuItem *substitutionsItem = [menu addItemWithTitle:NSLocalizedString(@"Substitutions", @"") action:NULL keyEquivalent:@""];
NSMenu *substitutionsMenu = [[NSMenu alloc] initWithTitle:@""];
Expand All @@ -503,24 +495,21 @@ - (NSMenu *)menuForEvent:(NSEvent *)event
[substitutionsMenu addItemWithTitle:NSLocalizedString(@"Smart Links", @"") action:@selector(toggleAutomaticLinkDetection:) keyEquivalent:@""];
[substitutionsMenu addItemWithTitle:NSLocalizedString(@"Text Replacement", @"") action:@selector(toggleAutomaticTextReplacement:) keyEquivalent:@""];
[substitutionsItem setSubmenu:substitutionsMenu];
[substitutionsMenu release];

NSMenuItem *transformationsItem = [menu addItemWithTitle:NSLocalizedString(@"Transformations", @"") action:NULL keyEquivalent:@""];
NSMenu *transformationsMenu = [[NSMenu alloc] initWithTitle:@""];
[transformationsMenu addItemWithTitle:NSLocalizedString(@"Make Upper Case", @"") action:@selector(uppercaseWord:) keyEquivalent:@""];
[transformationsMenu addItemWithTitle:NSLocalizedString(@"Make Lower Case", @"") action:@selector(lowercaseWord:) keyEquivalent:@""];
[transformationsMenu addItemWithTitle:NSLocalizedString(@"Capitalize", @"") action:@selector(capitalizeWord:) keyEquivalent:@""];
[transformationsItem setSubmenu:transformationsMenu];
[transformationsMenu release];

NSMenuItem *speechItem = [menu addItemWithTitle:NSLocalizedString(@"Speech", @"") action:NULL keyEquivalent:@""];
NSMenu *speechMenu = [[NSMenu alloc] initWithTitle:@""];
[speechMenu addItemWithTitle:NSLocalizedString(@"Start Speaking", @"") action:@selector(startSpeaking:) keyEquivalent:@""];
[speechMenu addItemWithTitle:NSLocalizedString(@"Stop Speaking", @"") action:@selector(stopSpeaking:) keyEquivalent:@""];
[speechItem setSubmenu:speechMenu];
[speechMenu release];

return [self.nsView menuWithPatchedItems:[menu autorelease]];
return [self.nsView menuWithPatchedItems:menu];
}

- (void)_replaceMisspelledWord:(NSMenuItem *)menuItem
Expand Down Expand Up @@ -640,7 +629,7 @@ - (BOOL)doCommandBySelector:(SEL)selector

- (TUITextRenderer *)placeholderRenderer {
if(placeholderRenderer == nil) {
self.placeholderRenderer = [[[TUITextRenderer alloc] init] autorelease];
self.placeholderRenderer = [[TUITextRenderer alloc] init];
}

return placeholderRenderer;
Expand Down
1 change: 1 addition & 0 deletions lib/UIKit/TUIView+Private.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#import "TUIView+Private.h"
#import "TUITextRenderer.h"
#import "TUINSWindow.h"

@implementation TUIView (Private)

Expand Down
26 changes: 9 additions & 17 deletions lib/UIKit/TUIView.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,21 @@ @interface TUIView ()

@implementation TUIView

@dynamic subviews;
@synthesize layout;
@synthesize toolTip;
@synthesize toolTipDelay;
@synthesize drawQueue;
// use the accessor from the main implementation block
@synthesize subviews = _subviews;

- (void)setSubviews:(NSArray *)s
{
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
NSMutableArray *toRemove = [NSMutableArray array];
for(CALayer *sublayer in self.layer.sublayers) {
TUIView *associatedView = [sublayer associatedView];
if(associatedView != nil) [toRemove addObject:associatedView];
}
[toRemove makeObjectsPerformSelector:@selector(removeFromSuperview)];

for(TUIView *subview in s) {
[self addSubview:subview];
Expand Down Expand Up @@ -580,7 +586,7 @@ - (void)sizeToFit
@end

@implementation TUIView (TUIViewHierarchy)
// use the accessor from the main implementation block

@dynamic subviews;

- (TUIView *)superview
Expand All @@ -596,20 +602,6 @@ - (NSInteger)deepNumberOfSubviews
return n;
}

- (void)setSubviews:(NSArray *)s
{
NSMutableArray *toRemove = [NSMutableArray array];
for(CALayer *sublayer in self.layer.sublayers) {
TUIView *associatedView = [sublayer associatedView];
if(associatedView != nil) [toRemove addObject:associatedView];
}
[toRemove makeObjectsPerformSelector:@selector(removeFromSuperview)];

for(TUIView *subview in s) {
[self addSubview:subview];
}
}

- (void)_cleanupResponderChain // called when a view is about to be removed from the heirarchy
{
[self.subviews makeObjectsPerformSelector:@selector(_cleanupResponderChain)]; // call this first because subviews may pass first responder responsibility up to the superview
Expand Down

0 comments on commit 3358884

Please sign in to comment.