* Source/NSAnimation.m (NSViewAnimation -dealloc): Use DESTROY

instead of RELEASE as _viewAnimationDesc to prevent segmentation
        fault in super call.
        * Source/NSWindow.m (-setFrame:display:animate:): Use
        NSViewAnimation instead of local blocking code.
        * Source/NSWindow.m (-animationResizeTime:): Use abs() in all
        * directions.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33624 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2011-07-24 18:53:07 +00:00
parent 1043d6ecce
commit d2011237e8
3 changed files with 56 additions and 48 deletions

View file

@ -1,3 +1,12 @@
2011-07-24 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSAnimation.m (NSViewAnimation -dealloc): Use DESTROY
instead of RELEASE as _viewAnimationDesc to prevent segmentation
fault in super call.
* Source/NSWindow.m (-setFrame:display:animate:): Use
NSViewAnimation instead of local blocking code.
* Source/NSWindow.m (-animationResizeTime:): Use abs() in all directions.
2011-07-23 Fred Kiefer <FredKiefer@gmx.de>
* Tests/gui/NSView/NSView_visibleRect.m: New test.

View file

@ -1445,8 +1445,8 @@ nsanimation_progressMarkSorter(NSAnimationProgress first, NSAnimationProgress se
- (void) dealloc
{
RELEASE(_viewAnimations);
RELEASE(_viewAnimationDesc);
DESTROY(_viewAnimations);
DESTROY(_viewAnimationDesc);
[super dealloc];
}

View file

@ -35,6 +35,7 @@
#include <math.h>
#include <float.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSRunLoop.h>
#import <Foundation/NSScanner.h>
@ -52,6 +53,7 @@
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSUndoManager.h>
#import "AppKit/NSAnimation.h"
#import "AppKit/NSApplication.h"
#import "AppKit/NSButton.h"
#import "AppKit/NSButtonCell.h"
@ -129,6 +131,25 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
- (void) _setWindow: (NSWindow *)window inactive: (BOOL)inactive;
@end
@interface GSWindowAnimationDelegate : NSObject
{
}
@end
@implementation GSWindowAnimationDelegate
- (void) animationDidEnd: (NSAnimation *)animation
{
AUTORELEASE(animation);
}
- (void) animationDidStop: (NSAnimation *)animation
{
AUTORELEASE(animation);
}
@end
static GSWindowAnimationDelegate *animationDelegate;
/*
* Category for internal methods (for use only within the NSWindow class itself
@ -1958,57 +1979,35 @@ many times.
display: (BOOL)displayFlag
animate: (BOOL)animationFlag
{
if (animationFlag)
if (animationFlag && !NSEqualRects(_frame, frameRect))
{
// time that the resize is expected to take in seconds
NSTimeInterval resizeTime;
// velocity
NSRect v;
// time parameter
float t;
float tdiff;
v.origin.x = _frame.origin.x - frameRect.origin.x;
v.origin.y = _frame.origin.y - frameRect.origin.y;
v.size.width = _frame.size.width - frameRect.size.width;
v.size.height = _frame.size.height - frameRect.size.height;
NSArray *animations;
NSViewAnimation *viewAnimation;
resizeTime = [self animationResizeTime: frameRect];
tdiff = 0.1 / resizeTime;
[NSEvent startPeriodicEventsAfterDelay: 0 withPeriod: 0.02];
t = 1.0;
while (t > 0.0)
animations = [NSArray arrayWithObject:
[NSDictionary dictionaryWithObjectsAndKeys:
self, NSViewAnimationTargetKey,
[NSValue valueWithRect: frameRect], NSViewAnimationEndFrameKey,
nil]];
viewAnimation = [[NSViewAnimation alloc] initWithViewAnimations: animations];
[viewAnimation setAnimationBlockingMode: NSAnimationNonblocking];
[viewAnimation setDuration: resizeTime];
if (animationDelegate == nil)
{
NSEvent *theEvent = [NSApp nextEventMatchingMask: NSPeriodicMask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
if ([theEvent type] == NSPeriodic)
{
NSRect newFrame;
t -= tdiff;
if (t <= 0.0)
{
break;
}
// move
newFrame.origin.x = frameRect.origin.x + v.origin.x * t;
newFrame.origin.y = frameRect.origin.y + v.origin.y * t;
// strech
newFrame.size.width = frameRect.size.width + v.size.width * t;
newFrame.size.height = frameRect.size.height + v.size.height * t;
[self setFrame: newFrame display: displayFlag];
}
animationDelegate = [[GSWindowAnimationDelegate alloc] init];
}
[NSEvent stopPeriodicEvents];
// The delegate handles the release of the viewAnimation
[viewAnimation setDelegate: animationDelegate];
[viewAnimation startAnimation];
//AUTORELEASE(viewAnimation);
}
else
{
[self setFrame: frameRect display: displayFlag];
}
[self setFrame: frameRect display: displayFlag];
}
- (NSTimeInterval) animationResizeTime: (NSRect)newFrame
@ -2033,9 +2032,9 @@ many times.
// Find the biggest difference
maxDiff = abs(newFrame.origin.x - _frame.origin.x);
maxDiff = MAX(maxDiff, newFrame.origin.y - _frame.origin.y);
maxDiff = MAX(maxDiff, newFrame.size.width - _frame.size.width);
maxDiff = MAX(maxDiff, newFrame.size.height - _frame.size.height);
maxDiff = MAX(maxDiff, abs(newFrame.origin.y - _frame.origin.y));
maxDiff = MAX(maxDiff, abs(newFrame.size.width - _frame.size.width));
maxDiff = MAX(maxDiff, abs(newFrame.size.height - _frame.size.height));
return (maxDiff * resizeTime) / 150;
}