[vlc-devel] commit: macosx vout: another memleak (Derk-Jan Hartman )

git version control git at videolan.org
Tue Jun 2 01:34:28 CEST 2009


vlc | branch: 1.0-bugfix | Derk-Jan Hartman <hartman at videolan.org> | Tue Jun  2 01:26:32 2009 +0200| [1c6e5232ce0995179ff6b922d305831e8a7d6003] | committer: Derk-Jan Hartman 

macosx vout: another memleak

A memleak in the handling of NSAnimation
(cherry picked from commit 9d7513aea570d26822f26a7b0567133ab4fd6324)

Signed-off-by: Derk-Jan Hartman <hartman at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1c6e5232ce0995179ff6b922d305831e8a7d6003
---

 modules/gui/macosx/embeddedwindow.m |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/modules/gui/macosx/embeddedwindow.m b/modules/gui/macosx/embeddedwindow.m
index 9409690..123dd48 100644
--- a/modules/gui/macosx/embeddedwindow.m
+++ b/modules/gui/macosx/embeddedwindow.m
@@ -80,7 +80,7 @@
     [o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
 
     o_fullscreen_window = nil;
-    o_fullscreen_anim1 = o_fullscreen_anim2 = nil;
+    o_makekey_anim = o_fullscreen_anim1 = o_fullscreen_anim2 = nil;
 
     /* Not fullscreen when we wake up */
     [o_btn_fullscreen setState: NO];
@@ -356,8 +356,8 @@
         - Keep at most 2 animation at a time
         - leaveFullscreen/enterFullscreen are the only responsible for releasing and alloc-ing
     */
-    o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict1, nil]];
-    o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict2, nil]];
+    o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict1]];
+    o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict2]];
 
     [dict1 release];
     [dict2 release];
@@ -525,7 +525,11 @@
 - (void)animationDidEnd:(NSAnimation*)animation
 {
     NSArray *viewAnimations;
-
+    if( o_makekey_anim == animation )
+    {
+        [o_makekey_anim release];
+        return;
+    }
     if ([animation currentValue] < 1.0)
         return;
 
@@ -569,17 +573,19 @@
     [super setAlphaValue:0.0f];
     [super makeKeyAndOrderFront: sender];
 
-    NSMutableDictionary * dict = [[[NSMutableDictionary alloc] initWithCapacity:2] autorelease];
+    NSMutableDictionary * dict = [[NSMutableDictionary alloc] initWithCapacity:2];
     [dict setObject:self forKey:NSViewAnimationTargetKey];
     [dict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
 
-    NSViewAnimation * anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict]];
+    o_makekey_anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict]];
+    [dict release];
 
-    [anim setAnimationBlockingMode: NSAnimationNonblocking];
-    [anim setDuration: 0.1];
-    [anim setFrameRate: 30];
+    [o_makekey_anim setAnimationBlockingMode: NSAnimationNonblocking];
+    [o_makekey_anim setDuration: 0.1];
+    [o_makekey_anim setFrameRate: 30];
+    [o_makekey_anim setDelegate: self];
 
-    [anim startAnimation];
+    [o_makekey_anim startAnimation];
     b_window_is_invisible = NO;
 
     /* fullscreenAnimation will be unlocked when animation ends */
@@ -616,7 +622,8 @@
             [NSValue valueWithRect:[self frame]], NSViewAnimationStartFrameKey,
             [NSValue valueWithRect:args->frame], NSViewAnimationEndFrameKey, nil];
 
-        NSViewAnimation * anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict, nil]];
+        NSViewAnimation * anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict]];
+        [dict release];
 
         [anim setAnimationBlockingMode: NSAnimationNonblocking];
         [anim setDuration: 0.4];




More information about the vlc-devel mailing list