NSLayoutConstraint & animator proxy leads to crashes
NSLayoutConstraint & animator proxy leads to crashes
- Subject: NSLayoutConstraint & animator proxy leads to crashes
- From: Robert Vojta <email@hidden>
- Date: Wed, 24 Jul 2013 12:50:53 +0200
Howdy,
I've got NSScrollView and NSLayoutConstraint which is defined as:
_scrollViewHeightConstraint = [TMIntegralLayoutConstraint constraintWithItem:self.scrollView
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1.0
constant:sDefaultScrollViewHeight];
[self addConstraint:_scrollViewHeightConstraint];
… TMIntegralLayoutConstraint is subclass of NSLayoutConstraint with one overriden method only …
- (void)setConstant:(CGFloat)constant {
[super setConstant:round( constant )];
}
This is because if I do not round constant NSWindow jumps up & down during animation, because animator sets constant to real number sometimes.
I'm animating height of scroll view with this simple line of code ...
[self.scrollViewHeightConstraint.animator setConstant:height];
… so far, so good and everything does work. But when I close & release window with this scroll view before the animation ends, app crashes …
*** -[NSScrollView nsli_lowerAttribute:intoExpression:withCoefficient:container:]: message sent to deallocated instance 0x109cd4da0
… NSScrollView is deallocated, so, I tried to do this …
NSView *view = self;
[NSAnimationContext beginGrouping];
[self.scrollViewHeightConstraint.animator setConstant:height];
[view setNeedsUpdateConstraints:YES];
[[NSAnimationContext currentContext] setCompletionHandler:^{
[view layoutSubtreeIfNeeded];
}];
[NSAnimationContext endGrouping];
… to capture NSView until the animation ends. But I still do receive crashes.
Height constraint is added to the NSScrollView's superview. I tried to add it directly to the NSScrollView, but same problems.
Anynoe has an idea why this is happening? Should I stop animation somehow and remove this particular constraint before window is closed & released?
Thanks,
Robert
--
Robert @ Tapmates, Inc.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden