Fixed a crash when Core Image was available.
[ITKit.git] / ITCoreImageWindowEffect.m
index 9fd49aa..afef08f 100644 (file)
 - (void)setupEffect;
 @end
 
+static BOOL _running = NO;
+
 @implementation ITCoreImageWindowEffect
 
 + (NSString *)effectName
 {
-    return @"Core Image - Ripple";
+    return @"Ripple";
 }
 
 + (NSDictionary *)supportedPositions
@@ -96,6 +98,7 @@
     [self setWindowVisibility:ITWindowVisibleState];
 
     __idle = YES;
+       
     if ( __shouldReleaseWhenIdle ) {
         [self release];
     }
 
 - (void)performVanish
 {
-    __idle = NO;
+       __idle = NO;
        
-    [self setWindowVisibility:ITWindowVanishingState];
-    [self performVanishFromProgress:1.0 effectTime:_effectTime];
+       [self setWindowVisibility:ITWindowVanishingState];
+       [self performVanishFromProgress:1.0 effectTime:_effectTime];
 }
 
 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
     [self setWindowVisibility:ITWindowHiddenState];
 
     __idle = YES;
-    
+       
     if ( __shouldReleaseWhenIdle ) {
         [self release];
     }
        NSRect rippleRect = [_window frame];
        NSRect screenRect = [[_window screen] frame];
        
+       if (_running) {
+               //Short-circuit to avoid layering effects and crashing
+               return;
+       }
+       
+       _running = YES;
        _ripple = YES;
        
     rippleRect.origin.y = - (NSMaxY(rippleRect) - screenRect.size.height);
        [[_effectWindow contentView] release];
     [_effectWindow release];
     [pool release];
+       
+       _running = NO;
 }
 
 @end