From 4f735bdf00be9feb91c97ea7d0c0190128b7d685 Mon Sep 17 00:00:00 2001 From: Jared Henderson Date: Mon, 23 Jan 2017 15:51:07 -0800 Subject: [PATCH 1/4] Fixing some UIKit/WinRT projections memory leaks. Any time we allocate a WinRT projected object via make*, we are responsible for freeing it. --- Frameworks/UIKit/UIButton.mm | 5 ++--- Frameworks/UIKit/UILabel.mm | 4 ++-- Frameworks/UIKit/XamlUtilities.mm | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Frameworks/UIKit/UIButton.mm b/Frameworks/UIKit/UIButton.mm index e6e493a370..8329adf5c4 100644 --- a/Frameworks/UIKit/UIButton.mm +++ b/Frameworks/UIKit/UIButton.mm @@ -269,7 +269,7 @@ - (void)initAccessibility { - (void)setImage:(UIImage*)image forState:(UIControlState)state { _states[state].image = image; - // NOTE: check if image is nil before creating inspetableImage + // NOTE: check if image is nil before creating inspectableImage // ConvertUIImageToWUXMImageBrush:nil creates a valid imageBrush with null comObj // which isn't what we want if (image) { @@ -552,8 +552,7 @@ - (void)setTitleColor:(UIColor*)color forState:(UIControlState)state { // ConvertUIColorToWUColor:nil creates a valid WUColor with null comObj // which isn't what we want if (color) { - WUColor* convertedColor = XamlUtilities::ConvertUIColorToWUColor(color); - WUXMSolidColorBrush* titleColorBrush = [WUXMSolidColorBrush makeInstanceWithColor:convertedColor]; + WUXMSolidColorBrush* titleColorBrush = [[WUXMSolidColorBrush makeInstanceWithColor:XamlUtilities::ConvertUIColorToWUColor(color)] autorelease]; if (titleColorBrush) { _states[state].inspectableTitleColor = [titleColorBrush comObj]; } diff --git a/Frameworks/UIKit/UILabel.mm b/Frameworks/UIKit/UILabel.mm index 6e1ee983f5..eaa452484e 100644 --- a/Frameworks/UIKit/UILabel.mm +++ b/Frameworks/UIKit/UILabel.mm @@ -109,7 +109,7 @@ - (void)adjustTextLayerSize { [_textBlock setFontStyle:static_cast([_font _fontStyle])]; [_textBlock setFontStretch:static_cast([_font _fontStretch])]; - [_textBlock setFontFamily:[WUXMFontFamily makeInstanceWithName:[_font _compatibleFamilyName]]]; + [_textBlock setFontFamily:[[WUXMFontFamily makeInstanceWithName:[_font _compatibleFamilyName]] autorelease]]; [_textBlock setTextAlignment:XamlUtilities::ConvertUITextAlignmentToWXTextAlignment(_alignment)]; @@ -122,7 +122,7 @@ - (void)adjustTextLayerSize { if (_isHighlighted && _highlightedTextColor != nil) { color = _highlightedTextColor; } - [_textBlock setForeground:[WUXMSolidColorBrush makeInstanceWithColor:XamlUtilities::ConvertUIColorToWUColor(color)]]; + [_textBlock setForeground:[[WUXMSolidColorBrush makeInstanceWithColor:XamlUtilities::ConvertUIColorToWUColor(color)] autorelease]]; [self invalidateIntrinsicContentSize]; [self setNeedsDisplay]; diff --git a/Frameworks/UIKit/XamlUtilities.mm b/Frameworks/UIKit/XamlUtilities.mm index c4085f7259..cbf8f25d9f 100644 --- a/Frameworks/UIKit/XamlUtilities.mm +++ b/Frameworks/UIKit/XamlUtilities.mm @@ -13,6 +13,7 @@ // THE SOFTWARE. // //****************************************************************************** +#import "AssertARCEnabled.h" #import "XamlUtilities.h" #import From f861dca54f02ca4ebe247a4329235875220080ff Mon Sep 17 00:00:00 2001 From: Jared Henderson Date: Tue, 24 Jan 2017 16:07:18 -0800 Subject: [PATCH 2/4] Fixing leak in Autolayout and its usage of ClSlackVariables. --- Frameworks/AutoLayout/AutoLayout.mm | 6 +++ .../cassowary-0.60/c++/ClSimplexSolver.cc | 11 +++-- deps/3rdparty/cassowary-0.60/c++/ClVariable.h | 1 + .../WOCCatalog/AutoLayoutViewController.m | 46 +++++++++++++++++-- 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/Frameworks/AutoLayout/AutoLayout.mm b/Frameworks/AutoLayout/AutoLayout.mm index 9495ad5a9f..642988114f 100644 --- a/Frameworks/AutoLayout/AutoLayout.mm +++ b/Frameworks/AutoLayout/AutoLayout.mm @@ -463,6 +463,12 @@ - (void)autoLayoutLayoutSubviews { - (BOOL)autoLayoutInvalidateContentSize { AutoLayoutProperties* layoutProperties = self._autoLayoutProperties; + if (DEBUG_AUTO_LAYOUT_LIGHT) { + TraceVerbose(TAG, L"autoLayoutInvalidateContentSize: %hs(0x%p).", + object_getClassName(self), + self); + } + CGSize newContentSize = [self intrinsicContentSize]; if (CGSizeEqualToSize(layoutProperties->_intrinsicContentSize, newContentSize)) { if (DEBUG_AUTO_LAYOUT_LIGHT) { diff --git a/deps/3rdparty/cassowary-0.60/c++/ClSimplexSolver.cc b/deps/3rdparty/cassowary-0.60/c++/ClSimplexSolver.cc index 16470bd882..470d73d59f 100644 --- a/deps/3rdparty/cassowary-0.60/c++/ClSimplexSolver.cc +++ b/deps/3rdparty/cassowary-0.60/c++/ClSimplexSolver.cc @@ -440,6 +440,9 @@ ClSimplexSolver::RemoveConstraintInternal(const ClConstraint *const pcn) cerr << "delete@ " << pexpr << endl; #endif delete pexpr; + + // Delete the ClAbstractVarable that backs marker, else we leak + delete marker.get_pclv(); } // Delete any error variables. If cn is an inequality, it also @@ -453,9 +456,11 @@ ClSimplexSolver::RemoveConstraintInternal(const ClConstraint *const pcn) { ClVariable v = (*it); if (v != marker) - { - RemoveColumn(v); - } + { + RemoveColumn(v); + // Delete the ClAbstractVarable that backs v, else we leak + delete v.get_pclv(); + } } } diff --git a/deps/3rdparty/cassowary-0.60/c++/ClVariable.h b/deps/3rdparty/cassowary-0.60/c++/ClVariable.h index 3ec4f7b665..5114a6ef47 100644 --- a/deps/3rdparty/cassowary-0.60/c++/ClVariable.h +++ b/deps/3rdparty/cassowary-0.60/c++/ClVariable.h @@ -90,6 +90,7 @@ class ClVariable { } ClAbstractVariable *get_pclv() const { return pclv; } + ClAbstractVariable *get_pclv() { return pclv; } bool IsNil() const { return pclv == NULL; } virtual FDNumber DesiredValue() const diff --git a/samples/WOCCatalog/WOCCatalog/AutoLayoutViewController.m b/samples/WOCCatalog/WOCCatalog/AutoLayoutViewController.m index 1c26d9b8c9..67a2f27b22 100644 --- a/samples/WOCCatalog/WOCCatalog/AutoLayoutViewController.m +++ b/samples/WOCCatalog/WOCCatalog/AutoLayoutViewController.m @@ -38,7 +38,9 @@ - (instancetype)init { @end -@implementation AutoLayoutViewController +@implementation AutoLayoutViewController { + CenteredAutoLayoutLabel* _addRemoveLabel; +}; - (void)viewDidLoad { [super viewDidLoad]; @@ -64,7 +66,7 @@ - (void)viewDidLoad { [self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat:@"V:[bottomLabel(30)]-[bottomGuide]" options:NO metrics:nil views:NSDictionaryOfVariableBindings(bottomLabel, bottomGuide)]]; UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; - + [button setTitle:@"Button For Baseline" forState:UIControlStateNormal]; [button setTitle:@"Highlighted State Changes Intrinsic Content Size" forState:UIControlStateHighlighted]; [button setContentHuggingPriority:251 forAxis:UILayoutConstraintAxisVertical]; @@ -73,7 +75,7 @@ - (void)viewDidLoad { button.layer.cornerRadius = 5.0f; button.backgroundColor = [UIColor lightGrayColor]; [self.view addSubview:button]; - + [self.view addConstraint:[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:bottomLabel attribute:NSLayoutAttributeTop multiplier:1.0 constant:-8.0f]]; [self.view addConstraint:[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:button.superview attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20.0f]]; @@ -107,6 +109,44 @@ - (void)viewDidLoad { [self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat:@"|-[label1]-[label2(label1)]-[label3(label1)]-[label4(label1)]-|" options:NO metrics:nil views:NSDictionaryOfVariableBindings(label1, label2, label3, label4)]]; [self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat:@"V:[topLabel]-[label1]-[label2(label1)]-[label3(label1)]-[label4(label1)]-[button]" options:NO metrics:nil views:NSDictionaryOfVariableBindings(topLabel, button, label1, label2, label3, label4)]]; + + UIButton* button2 = [UIButton buttonWithType : UIButtonTypeRoundedRect]; + [button2 setTitle:@"Add a new label" forState:UIControlStateNormal]; + + [button2 setTitle:@"Delete the new label" forState:UIControlStateSelected]; + [button2 setTitle:@"Delete the new label" forState:UIControlStateSelected | UIControlStateHighlighted]; + + [button2 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted]; + [button2 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted | UIControlStateSelected]; + + [button2 setContentHuggingPriority:251 forAxis:UILayoutConstraintAxisVertical]; + button2.contentEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10); + button2.translatesAutoresizingMaskIntoConstraints = NO; + button2.layer.cornerRadius = 5.0f; + button2.backgroundColor = [UIColor lightGrayColor]; + [button2 addTarget:self action:@selector(_button2TouchUp:) forControlEvents:UIControlEventTouchUpInside]; + [self.view addSubview:button2]; + + [self.view addConstraint:[NSLayoutConstraint constraintWithItem:button2 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:buttonLabel attribute:NSLayoutAttributeRight multiplier:1.0 constant:8.0f]]; + [self.view addConstraint:[NSLayoutConstraint constraintWithItem:button2 attribute:NSLayoutAttributeBaseline relatedBy:NSLayoutRelationEqual toItem:buttonLabel attribute:NSLayoutAttributeBaseline multiplier:1.0 constant:0]]; +} + +- (void)_button2TouchUp:(UIButton*)button { + BOOL wasSelected = button.isSelected; + [button setSelected:!wasSelected]; + + if (wasSelected) { + // Delete the label + [_addRemoveLabel removeFromSuperview]; + _addRemoveLabel = nil; + } else { + // Add the new label + _addRemoveLabel = [CenteredAutoLayoutLabel new]; + _addRemoveLabel.text = @"Temporary"; + _addRemoveLabel.backgroundColor = [UIColor purpleColor]; + [_addRemoveLabel sizeToFit]; + [self.view addSubview:_addRemoveLabel]; + } } @end \ No newline at end of file From 5ba191e13fc72216926417a12fec543157533cdd Mon Sep 17 00:00:00 2001 From: Jared Henderson Date: Tue, 24 Jan 2017 16:10:18 -0800 Subject: [PATCH 3/4] Updating libcassowary build output with memory leak fix. --- deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.lib | 4 ++-- deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.pdb | 4 ++-- deps/prebuilt/Universal Windows/ARM/cassowary-0.60.lib | 4 ++-- deps/prebuilt/Universal Windows/ARM/cassowary-0.60.pdb | 4 ++-- deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.lib | 4 ++-- deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.pdb | 4 ++-- deps/prebuilt/Universal Windows/x86/cassowary-0.60.lib | 4 ++-- deps/prebuilt/Universal Windows/x86/cassowary-0.60.pdb | 4 ++-- deps/prebuilt/include/cassowary-0.60/ClVariable.h | 1 + 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.lib b/deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.lib index 3b545ba4b2..5499e960aa 100644 --- a/deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.lib +++ b/deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.lib @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2380e10b0aebd2904bd9911716547ce8233a3b11aca394b17386e841d0c759ac -size 2661486 +oid sha256:82da2c972aa9da27d99c931eb3c10bbef56d72b2ac07003e41edb232981304ec +size 2665364 diff --git a/deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.pdb b/deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.pdb index 9fc20fb592..1ceef28718 100644 --- a/deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.pdb +++ b/deps/prebuilt/Universal Windows/ARM/cassowary-0.60-Debug.pdb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:19839e0799ebcde23b2cf5979092b9c7ba97b59e2feee625a37397355ac10acb -size 1470464 +oid sha256:704d1c7cb3222e593634757cf13c9e0dd8bf7096f9cbb35981b74264a3c2181a +size 1454080 diff --git a/deps/prebuilt/Universal Windows/ARM/cassowary-0.60.lib b/deps/prebuilt/Universal Windows/ARM/cassowary-0.60.lib index 922030fbf1..0cef33d940 100644 --- a/deps/prebuilt/Universal Windows/ARM/cassowary-0.60.lib +++ b/deps/prebuilt/Universal Windows/ARM/cassowary-0.60.lib @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fdbd9b5619f9d20dda0c6c003350a583da51ab3424e9d37471db9a656da4a5b7 -size 21925426 +oid sha256:e44b86e3e7c73d5e4ddbab0a212b9e2a14a03dd16353326d635e70a095bb5369 +size 22201656 diff --git a/deps/prebuilt/Universal Windows/ARM/cassowary-0.60.pdb b/deps/prebuilt/Universal Windows/ARM/cassowary-0.60.pdb index e13758da39..dc225a78e5 100644 --- a/deps/prebuilt/Universal Windows/ARM/cassowary-0.60.pdb +++ b/deps/prebuilt/Universal Windows/ARM/cassowary-0.60.pdb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f105324c28bc1a60ed3027e35f61d3217aa4ad34b777766b911af9d236d38bfd -size 1191936 +oid sha256:c2df823628b2d92dd250dd178a13960be861b8439ebb0ad394441a95468b5eb5 +size 1183744 diff --git a/deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.lib b/deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.lib index 5036dbf865..b221583da9 100644 --- a/deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.lib +++ b/deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.lib @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b184a8a28e6bd234a83c8e8cc4aa48f463e80c7496e9a6c49ec27208737d761b -size 2549686 +oid sha256:1fce833b1adb070a36db769a5c44ea56c43a275bdb2c48521b351b75e187c886 +size 2577394 diff --git a/deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.pdb b/deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.pdb index cca9ff023a..bdcf2e267a 100644 --- a/deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.pdb +++ b/deps/prebuilt/Universal Windows/x86/cassowary-0.60-Debug.pdb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3928d2d972b7a04b2c292f6bcc6f96c97e99cc744c35a65c784d76aca0b1dd05 -size 1462272 +oid sha256:7fbcaf283850bba8d4cdff85d447ec026e2066f1c8094d3e3e16c2efcf76ef19 +size 1445888 diff --git a/deps/prebuilt/Universal Windows/x86/cassowary-0.60.lib b/deps/prebuilt/Universal Windows/x86/cassowary-0.60.lib index 765addb3e3..aafce7bbd5 100644 --- a/deps/prebuilt/Universal Windows/x86/cassowary-0.60.lib +++ b/deps/prebuilt/Universal Windows/x86/cassowary-0.60.lib @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:39847501dd6c5f24c90e09064e80266c918d11cabc98badea2863a7961ccb49d -size 21042552 +oid sha256:03123eb452e92a7bd3855781aa75ba418baa93bb0f7ce11e5e6920df86ecba9d +size 21283602 diff --git a/deps/prebuilt/Universal Windows/x86/cassowary-0.60.pdb b/deps/prebuilt/Universal Windows/x86/cassowary-0.60.pdb index fe1ef26e9a..74884fa211 100644 --- a/deps/prebuilt/Universal Windows/x86/cassowary-0.60.pdb +++ b/deps/prebuilt/Universal Windows/x86/cassowary-0.60.pdb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:14aa33c07599f7b986f59fe475bba78558e593ab22a25dff90081928777071f6 -size 1191936 +oid sha256:db43959aa2638326e6dda8fb3b12c62ad01e95576d90d0d4a2e16cae4d4006c5 +size 1183744 diff --git a/deps/prebuilt/include/cassowary-0.60/ClVariable.h b/deps/prebuilt/include/cassowary-0.60/ClVariable.h index 3ec4f7b665..5114a6ef47 100644 --- a/deps/prebuilt/include/cassowary-0.60/ClVariable.h +++ b/deps/prebuilt/include/cassowary-0.60/ClVariable.h @@ -90,6 +90,7 @@ class ClVariable { } ClAbstractVariable *get_pclv() const { return pclv; } + ClAbstractVariable *get_pclv() { return pclv; } bool IsNil() const { return pclv == NULL; } virtual FDNumber DesiredValue() const From 8decb17a086372dca0d22f05097bfe6156075af8 Mon Sep 17 00:00:00 2001 From: Jared Henderson Date: Wed, 25 Jan 2017 17:58:34 -0800 Subject: [PATCH 4/4] Incorporating CR feedback. --- Frameworks/UIKit/UIButton.mm | 31 ++++++++++------------------- Frameworks/UIKit/UILabel.mm | 30 +++++++--------------------- Frameworks/include/UIViewInternal.h | 8 ++++---- build/UIKit/lib/UIKitLib.vcxproj | 8 ++++++-- 4 files changed, 28 insertions(+), 49 deletions(-) diff --git a/Frameworks/UIKit/UIButton.mm b/Frameworks/UIKit/UIButton.mm index 8329adf5c4..d2d9263c34 100644 --- a/Frameworks/UIKit/UIButton.mm +++ b/Frameworks/UIKit/UIButton.mm @@ -14,8 +14,9 @@ // //****************************************************************************** +#import "AssertARCEnabled.h" #import "Starboard.h" -#import +#import "StubReturn.h" #import #import @@ -173,11 +174,11 @@ - (void)_initUIButton { WXCTextBlock* templateText = rt_dynamic_cast([WXCTextBlock class], [_xamlButton getTemplateChild:@"buttonText"]); if (templateText) { - _proxyLabel.attach([[_UILabel_Proxy alloc] initWithXamlElement:templateText font:[UIFont buttonFont]]); + _proxyLabel = [[_UILabel_Proxy alloc] initWithXamlElement:templateText font:[UIFont buttonFont]]; } if (templateImage) { - _proxyImageView.attach([[_UIImageView_Proxy alloc] initWithXamlElement:templateImage]); + _proxyImageView = [[_UIImageView_Proxy alloc] initWithXamlElement:templateImage]; } _contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; @@ -443,14 +444,14 @@ - (CGRect)titleRectForContentRect:(CGRect)contentRect { @Status Interoperable */ - (void)setEnabled:(BOOL)enabled { - _xamlButton.get().isEnabled = enabled; + _xamlButton.isEnabled = enabled; } /** @Status Interoperable */ - (BOOL)isEnabled { - return _xamlButton.get().isEnabled; + return _xamlButton.isEnabled; } /** @@ -500,7 +501,7 @@ - (UIImage*)currentBackgroundImage { @Status Interoperable */ - (void)setTitle:(NSString*)title forState:(UIControlState)state { - _states[state].title.attach([title copy]); + _states[state].title = [title copy]; // NOTE: check if title is nil before creating inspectableTitle // createString:nil creates a valid rtString with null comObj @@ -552,7 +553,7 @@ - (void)setTitleColor:(UIColor*)color forState:(UIControlState)state { // ConvertUIColorToWUColor:nil creates a valid WUColor with null comObj // which isn't what we want if (color) { - WUXMSolidColorBrush* titleColorBrush = [[WUXMSolidColorBrush makeInstanceWithColor:XamlUtilities::ConvertUIColorToWUColor(color)] autorelease]; + WUXMSolidColorBrush* titleColorBrush = [WUXMSolidColorBrush makeInstanceWithColor:XamlUtilities::ConvertUIColorToWUColor(color)]; if (titleColorBrush) { _states[state].inspectableTitleColor = [titleColorBrush comObj]; } @@ -803,16 +804,6 @@ - (BOOL)showsTouchWhenHighlighted { - (void)dealloc { XamlRemovePointerEvents([_xamlButton comObj]); XamlRemoveLayoutEvent([_xamlButton comObj]); - - for (auto& state : _states) { - state.second.backgroundImage = nil; - state.second.image = nil; - state.second.textColor = nil; - state.second.title = nil; - } - - _xamlButton = nil; - [super dealloc]; } /** @@ -825,7 +816,7 @@ + (UIButton*)buttonWithType:(UIButtonType)type { [ret setTitleColor:[UIColor colorWithRed:0.0f green:0.47843137f blue:1.0f alpha:1.0f] forState:UIControlStateNormal]; } - return [ret autorelease]; + return ret; } /** @@ -888,7 +879,7 @@ - (UIColor*)currentTitleColor { @Notes Returns a mock UILabel that proxies some common properties and selectors to the underlying TextBlock */ - (UILabel*)titleLabel { - return (UILabel*)[[_proxyLabel retain] autorelease]; + return (UILabel*)_proxyLabel; } /** @@ -896,7 +887,7 @@ - (UILabel*)titleLabel { @Notes Returns a mock UIImageView that proxies some common properties and selectors to the underlying Image */ - (UIImageView*)imageView { - return (UIImageView*)[[_proxyImageView retain] autorelease]; + return (UIImageView*)_proxyImageView; } /** diff --git a/Frameworks/UIKit/UILabel.mm b/Frameworks/UIKit/UILabel.mm index eaa452484e..d874f49719 100644 --- a/Frameworks/UIKit/UILabel.mm +++ b/Frameworks/UIKit/UILabel.mm @@ -14,6 +14,7 @@ // //****************************************************************************** +#import "AssertARCEnabled.h" #import "Starboard.h" #import @@ -102,14 +103,13 @@ - (void)adjustTextLayerSize { [_textBlock setText:_text]; [_textBlock setFontSize:[_font pointSize]]; - StrongId fontWeight; - fontWeight.attach([WUTFontWeight new]); - fontWeight.get().weight = static_cast([_font _fontWeight]); + WUTFontWeight* fontWeight =[WUTFontWeight new]; + fontWeight.weight = static_cast([_font _fontWeight]); [_textBlock setFontWeight:fontWeight]; [_textBlock setFontStyle:static_cast([_font _fontStyle])]; [_textBlock setFontStretch:static_cast([_font _fontStretch])]; - [_textBlock setFontFamily:[[WUXMFontFamily makeInstanceWithName:[_font _compatibleFamilyName]] autorelease]]; + [_textBlock setFontFamily:[WUXMFontFamily makeInstanceWithName:[_font _compatibleFamilyName]]]; [_textBlock setTextAlignment:XamlUtilities::ConvertUITextAlignmentToWXTextAlignment(_alignment)]; @@ -122,7 +122,7 @@ - (void)adjustTextLayerSize { if (_isHighlighted && _highlightedTextColor != nil) { color = _highlightedTextColor; } - [_textBlock setForeground:[[WUXMSolidColorBrush makeInstanceWithColor:XamlUtilities::ConvertUIColorToWUColor(color)] autorelease]]; + [_textBlock setForeground:[WUXMSolidColorBrush makeInstanceWithColor:XamlUtilities::ConvertUIColorToWUColor(color)]]; [self invalidateIntrinsicContentSize]; [self setNeedsDisplay]; @@ -306,7 +306,7 @@ - (void)setText:(NSString*)newStr { newStr = [newStr description]; } if (newStr == nil || ![_text isEqual:newStr]) { - _text.attach([newStr copy]); + _text = [newStr copy]; if (_adjustFontSize) { [self adjustFontSizeToFit]; @@ -323,7 +323,7 @@ - (void)setText:(NSString*)newStr { */ - (void)setAttributedText:(NSAttributedString*)newStr { UNIMPLEMENTED(); - _attributedText.attach([newStr copy]); + _attributedText = [newStr copy]; [self setText:[_attributedText string]]; } @@ -381,7 +381,6 @@ - (void)setTextColor:(UIColor*)color { return; } if (![_textColor isEqual:color]) { - [[_textColor retain] autorelease]; _textColor = color; [self adjustTextLayerSize]; } @@ -622,21 +621,6 @@ - (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)max return ret; } -/** - @Status Interoperable -*/ -- (void)dealloc { - _text = nil; - _font = nil; - _textColor = nil; - _shadowColor = nil; - _highlightedTextColor = nil; - _savedBackgroundColor = nil; - _attributedText = nil; - - [super dealloc]; -} - /** @Status Interoperable */ diff --git a/Frameworks/include/UIViewInternal.h b/Frameworks/include/UIViewInternal.h index a82e3a7c41..7d66f64bfb 100644 --- a/Frameworks/include/UIViewInternal.h +++ b/Frameworks/include/UIViewInternal.h @@ -86,9 +86,9 @@ class UIViewPrivateState : public LLTreeNode { userInteractionEnabled = YES; multipleTouchEnabled = NO; contentMode = UIViewContentModeScaleToFill; - currentTouches.attach([[NSMutableArray alloc] initWithCapacity:16]); - gestures.attach([NSMutableArray new]); - constraints.attach([NSMutableArray new]); + currentTouches = [[NSMutableArray alloc] initWithCapacity:16]; + gestures = [NSMutableArray new]; + constraints = [NSMutableArray new]; translatesAutoresizingMaskIntoConstraints = YES; _isChangingParent = false; _constraintsNeedUpdate = false; @@ -96,7 +96,7 @@ class UIViewPrivateState : public LLTreeNode { _contentHuggingPriority.width = 250.0f; _contentCompressionResistancePriority.height = 750.0f; _contentCompressionResistancePriority.width = 750.0f; - _layoutGuides.attach([NSMutableArray new]); + _layoutGuides = [NSMutableArray new]; memset(&_resizeRoundingError, 0, sizeof(_resizeRoundingError)); diff --git a/build/UIKit/lib/UIKitLib.vcxproj b/build/UIKit/lib/UIKitLib.vcxproj index 200f705a63..34518cc23e 100644 --- a/build/UIKit/lib/UIKitLib.vcxproj +++ b/build/UIKit/lib/UIKitLib.vcxproj @@ -39,7 +39,9 @@ - + + true + @@ -57,7 +59,9 @@ - + + true + true