Skip to content

Commit

Permalink
Fix some leaks in UIKit (#1759)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehren authored and jaredhms committed Jan 24, 2017
1 parent 955b1c8 commit 75effb9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Frameworks/UIKit/UIButton.mm
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ - (void)_initUIButton {
WXCTextBlock* templateText = rt_dynamic_cast([WXCTextBlock class], [_xamlButton getTemplateChild:@"buttonText"]);

if (templateText) {
_proxyLabel = [[_UILabel_Proxy alloc] initWithXamlElement:templateText font:[UIFont buttonFont]];
_proxyLabel.attach([[_UILabel_Proxy alloc] initWithXamlElement:templateText font:[UIFont buttonFont]]);
}

if (templateImage) {
_proxyImageView = [[_UIImageView_Proxy alloc] initWithXamlElement:templateImage];
_proxyImageView.attach([[_UIImageView_Proxy alloc] initWithXamlElement:templateImage]);
}

_contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
Expand Down Expand Up @@ -971,4 +971,4 @@ - (void)setAttributedTitle:(NSAttributedString*)title forState:(UIControlState)s
UNIMPLEMENTED();
}

@end
@end
12 changes: 6 additions & 6 deletions Frameworks/UIKit/UITableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,11 @@ static void initInternal(UITableView* self) {
priv->_defaultRowHeight = 50.0f;
priv->_defaultSectionHeaderHeight = 22.0f;
priv->_footerYPos = 0.f;
priv->_reusableCellNibs = [NSMutableDictionary new];
priv->_reusableHeaderClasses = [NSMutableDictionary new];
priv->_reusableCellClasses = [NSMutableDictionary new];
self->_indexPathsForSelectedItems = [NSMutableSet new];
self->_indexPathsForHighlightedItems = [NSMutableSet new];
priv->_reusableCellNibs.attach([NSMutableDictionary new]);
priv->_reusableHeaderClasses.attach([NSMutableDictionary new]);
priv->_reusableCellClasses.attach([NSMutableDictionary new]);
self->_indexPathsForSelectedItems.attach([NSMutableSet new]);
self->_indexPathsForHighlightedItems.attach([NSMutableSet new]);
priv->_separatorStyle = 0;
self.showsHorizontalScrollIndicator = FALSE;
}
Expand Down Expand Up @@ -1464,7 +1464,7 @@ - (id)dequeueReusableCellWithIdentifier:(NSString*)identifier forIndexPath:(NSIn
return [ret autorelease];
}

return [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
return [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Frameworks/UIKit/UITableViewCell.mm
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ - (instancetype)initWithCoder:(NSCoder*)coder {
_cellBackgroundColor = [UIColor clearColor];
}

_swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(_didSwipe:)];
_swipeGestureRecognizer.attach([[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(_didSwipe:)]);
[_swipeGestureRecognizer setDelegate:self];
[self addGestureRecognizer:_swipeGestureRecognizer];
return ret;
Expand Down
4 changes: 2 additions & 2 deletions Frameworks/UIKit/UIViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2422,7 +2422,7 @@ - (void)removeFromParentViewController {
}
}

_UILayoutGuide* tlg = [[_UILayoutGuide alloc] initWithIdentifier:@"_UIViewControllerTop"];
_UILayoutGuide* tlg = [[[_UILayoutGuide alloc] initWithIdentifier:@"_UIViewControllerTop"] autorelease];
[view addSubview:tlg];
[view addConstraint:[NSLayoutConstraint constraintWithItem:view
attribute:NSLayoutAttributeTop
Expand Down Expand Up @@ -2462,7 +2462,7 @@ - (void)removeFromParentViewController {
}
}

_UILayoutGuide* blg = [[_UILayoutGuide alloc] initWithIdentifier:@"_UIViewControllerBottom"];
_UILayoutGuide* blg = [[[_UILayoutGuide alloc] initWithIdentifier:@"_UIViewControllerBottom"] autorelease];
[view addSubview:blg];
[view addConstraint:[NSLayoutConstraint constraintWithItem:view
attribute:NSLayoutAttributeBottom
Expand Down
4 changes: 2 additions & 2 deletions Frameworks/UIKit/UIWebView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ @implementation UIWebView {
id _delegate;
idretaintype(NSURLRequest) _request;
bool _isLoading;
UIScrollView* _scrollView;
StrongId<UIScrollView> _scrollView;
StrongId<WXCWebView> _xamlWebControl;
EventRegistrationToken _xamlLoadCompletedEventCookie;
EventRegistrationToken _xamlLoadStartedEventCookie;
Expand Down Expand Up @@ -168,7 +168,7 @@ static void _initUIWebView(UIWebView* self) {
bounds = [self bounds];

// For compatibility only
self->_scrollView = [[UIScrollView alloc] initWithFrame:bounds];
self->_scrollView.attach([[UIScrollView alloc] initWithFrame:bounds]);

[self setNeedsLayout];
}
Expand Down
9 changes: 5 additions & 4 deletions Frameworks/UIKit/UrlLauncher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
//******************************************************************************

#import "UrlLauncher.h"
#import "Starboard.h"
#import "NSLogging.h"

static const wchar_t* TAG = L"UrlLauncher";

@interface UrlLauncher () {
Class _launcher;
NSCondition* _launchCondition;
StrongId<NSCondition> _launchCondition;
BOOL _launchCompleted;
BOOL _launchDidSucceed;
NSCondition* _canOpenCondition;
StrongId<NSCondition> _canOpenCondition;
BOOL _canOpenCompleted;
BOOL _canOpenDidSucceed;
}
Expand All @@ -34,8 +35,8 @@ @implementation UrlLauncher
- (UrlLauncher*)initWithLauncher:(Class)launcher {
if (self = [super init]) {
_launcher = launcher;
_launchCondition = [NSCondition new];
_canOpenCondition = [NSCondition new];
_launchCondition.attach([NSCondition new]);
_canOpenCondition.attach([NSCondition new]);
}

return self;
Expand Down

0 comments on commit 75effb9

Please sign in to comment.