-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix various Uikit memory leaks #1803
Changes from 3 commits
4f735bd
f861dca
5ba191e
8decb17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😲 we are literally allocating an objective-c thing that wraps a com thing to get at the com thing and discard the objective-c thing. what the actual heck #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
wasn't quite sure how these are used coupled with autolayout, we can sync offline. #Resolved |
||
} | ||
|
||
// 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(); | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change in this file does not appear to match anything related to the pull request. #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Autolayout testing #Resolved |
||
|
||
[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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there anything preventing us from turning on arc on UIButton/UILabel? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question; i'll give it a shot
In reply to: 97843932 [](ancestors = 97843932)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for pushing this!
In reply to: 97875917 [](ancestors = 97875917,97843932)