• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSLayoutConstraint & animator proxy leads to crashes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSLayoutConstraint & animator proxy leads to crashes
      • From: Robert Vojta <email@hidden>
  • Prev by Date: NSDraggingInfo protocol, -slideDraggedImageTo: hair-pulling woes
  • Next by Date: Re: NSLayoutConstraint & animator proxy leads to crashes
  • Previous by thread: NSDraggingInfo protocol, -slideDraggedImageTo: hair-pulling woes
  • Next by thread: Re: NSLayoutConstraint & animator proxy leads to crashes
  • Index(es):
    • Date
    • Thread