NSAnimation crash
NSAnimation crash
- Subject: NSAnimation crash
- From: Matt Neuburg <email@hidden>
- Date: Wed, 01 Feb 2006 10:58:43 -0800
- Thread-topic: NSAnimation crash
Here's an update on this: saying [self display] just before starting the
animation seems to solve the crash. (This was inspired by an offline note
from Jim Correia.) I'm continuing to experiment. m.
> I'm shrinking an NSMatrix by deleting a row of it. The NSMatrix is strutted to
> the bottom of the window, so to keep the position of the matrix correct, I
> simply shrink the window vertically by the reduction in matrix height. It
> occurred to me that this might look cool with NSAnimation, and sure enough, it
> does. The problem is that sometimes, just sometimes, *if*, besides the
> animation of the window, I also include an animation of the matrix itself, my
> app crashes.
>
> Here's the code (in the NSMatrix subclass):
>
> NSRect oldF = [self frame];
> [self removeRow:row];
> [self sizeToCells];
> NSRect newF = [self frame];
> float deltaH = oldF.size.height - newF.size.height;
> NSRect oldW = [[self window] frame];
> NSRect newW = NSMakeRect(oldW.origin.x, oldW.origin.y + deltaH,
> oldW.size.width, oldW.size.height - deltaH);
> NSViewAnimation* anim = [[NSViewAnimation alloc]
> initWithViewAnimations:[NSArray arrayWithObjects:
> // -- *
> [NSDictionary dictionaryWithObjectsAndKeys:
> self,
> NSViewAnimationTargetKey,
> NSViewAnimationFadeInEffect,
> NSViewAnimationEffectKey,
> [NSValue valueWithBytes:&newF objCType:@encode(NSRect)],
> NSViewAnimationStartFrameKey,
> [NSValue valueWithBytes:&newF objCType:@encode(NSRect)],
> NSViewAnimationEndFrameKey,
> nil],
> // -- *
> [NSDictionary dictionaryWithObjectsAndKeys:
> [self window],
> NSViewAnimationTargetKey,
> [NSValue valueWithBytes:&oldW objCType:@encode(NSRect)],
> NSViewAnimationStartFrameKey,
> [NSValue valueWithBytes:&newW objCType:@encode(NSRect)],
> NSViewAnimationEndFrameKey,
> nil],
> nil]];
> [anim setAnimationBlockingMode:NSAnimationBlocking];
> [anim startAnimation];
> [anim autorelease];
> [self setNeedsDisplay];
>
> If the dictionary between the comment marks is commented out, everything is
> fine. If it's left in, we sometimes crash (and we sometimes don't). I don't
> insist on having both parts of the animation - it's cute regardless, and
> anyhow it's just an experiment - but it seems to me this might be an
> NSAnimation bug. Any suggestions? Thx. m.
>
> PS The converse animation - growing the matrix and the window, and animating
> *both* - works perfectly.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide -
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Take Control of Word 2004, Tiger, and more -
http://www.takecontrolbooks.com/tiger-customizing.html
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden