[Adium-commits] adium 2041:cb5494214b9e: Silently breaking on mutate-while-enume...

adium-commits at adiumx.com adium-commits at adiumx.com
Wed Apr 29 15:15:58 UTC 2009


details:	http://hg.adiumx.com/adium/rev/cb5494214b9e
revision:	2041:cb5494214b9e
author:		David Smith <catfish.man at gmail.com>
date:		Wed Apr 29 08:15:41 2009 -0700

Silently breaking on mutate-while-enumerating is super annoying and not useful. We need to die on the spot so we can get a backtrace and fix it
Subject: adium 2042:efda39dfffb9: Automated merge with ssh://hg@hg.adiumx.com/adium

details:	http://hg.adiumx.com/adium/rev/efda39dfffb9
revision:	2042:efda39dfffb9
author:		David Smith <catfish.man at gmail.com>
date:		Wed Apr 29 08:15:51 2009 -0700

Automated merge with ssh://hg@hg.adiumx.com/adium

diffstat:

 Frameworks/AIUtilities Framework/Source/AIFloater.h |   2 +-
 Frameworks/AIUtilities Framework/Source/AIFloater.m |  41 ++++++++------------
 Source/ESDebugController.m                          |  10 +++++
 3 files changed, 27 insertions(+), 26 deletions(-)

diffs (120 lines):

diff -r 28244ecc5cca -r efda39dfffb9 Frameworks/AIUtilities Framework/Source/AIFloater.h
--- a/Frameworks/AIUtilities Framework/Source/AIFloater.h	Wed Apr 29 01:54:58 2009 -0700
+++ b/Frameworks/AIUtilities Framework/Source/AIFloater.h	Wed Apr 29 08:15:51 2009 -0700
@@ -18,7 +18,7 @@
     NSImageView			*staticView;
     NSPanel				*panel;
     BOOL                windowIsVisible;
-    NSTimer             *visibilityTimer;
+    NSViewAnimation     *fadeAnimation;
     float               maxOpacity;
 }
 
diff -r 28244ecc5cca -r efda39dfffb9 Frameworks/AIUtilities Framework/Source/AIFloater.m
--- a/Frameworks/AIUtilities Framework/Source/AIFloater.m	Wed Apr 29 01:54:58 2009 -0700
+++ b/Frameworks/AIUtilities Framework/Source/AIFloater.m	Wed Apr 29 08:15:51 2009 -0700
@@ -33,7 +33,7 @@
 	if ((self = [super init])) {
 		NSRect  frame;
 		windowIsVisible = NO;
-		visibilityTimer = nil;
+		fadeAnimation = nil;
 		maxOpacity = WINDOW_FADE_MAX;
 
 		//Set up the panel
@@ -89,7 +89,7 @@
 //
 - (IBAction)close:(id)sender
 {
-    [visibilityTimer invalidate]; [visibilityTimer release]; visibilityTimer = nil;
+    [fadeAnimation stopAnimation]; [fadeAnimation release]; fadeAnimation = nil;
     [panel orderOut:nil];
     [panel release]; panel = nil;
 
@@ -111,8 +111,20 @@
         windowIsVisible = inVisible;
         
         if (animate) {
-            if (!visibilityTimer) {
-                visibilityTimer = [[NSTimer scheduledTimerWithTimeInterval:(1.0/WINDOW_FADE_FPS) target:self selector:@selector(_updateWindowVisiblityTimer:) userInfo:nil repeats:YES] retain];
+            if (!fadeAnimation) {
+				NSDictionary *animDict = [NSDictionary dictionaryWithObjectsAndKeys:
+					panel, NSViewAnimationTargetKey,
+					inVisible ? NSViewAnimationFadeInEffect : NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey,
+					nil];
+                fadeAnimation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:animDict]];
+
+				//1.0 / FPS = duration per step
+				//1.0 / step = number of steps (e.g.: If step = 0.1, 1.0 / step = 10 steps)
+				//duration per step * number of steps = total duration
+				NSTimeInterval step = [[NSApp currentEvent] shiftKey] ? WINDOW_FADE_SLOW_STEP : WINDOW_FADE_STEP;
+				fadeAnimation.duration = (1.0 / step) * (1.0 / WINDOW_FADE_FPS);
+
+				[fadeAnimation startAnimation];
             }
         } else {
             [self _setWindowOpacity:(windowIsVisible ? maxOpacity : WINDOW_FADE_MIN)];
@@ -120,30 +132,9 @@
     }
 }
 
-//Smoothly 
-- (void)_updateWindowVisiblityTimer:(NSTimer *)inTimer
-{
-    float   alphaValue = [panel alphaValue];
-    
-    if (windowIsVisible) {
-        alphaValue += (maxOpacity - alphaValue) * ([NSEvent shiftKey] ? WINDOW_FADE_SLOW_STEP : WINDOW_FADE_STEP);
-        if (alphaValue > maxOpacity - WINDOW_FADE_SNAP) alphaValue = maxOpacity;
-    } else {
-        alphaValue -= (alphaValue - WINDOW_FADE_MIN) * ([NSEvent shiftKey] ? WINDOW_FADE_SLOW_STEP : WINDOW_FADE_STEP);
-        if (alphaValue < WINDOW_FADE_MIN + WINDOW_FADE_SNAP) alphaValue = WINDOW_FADE_MIN;
-    }
-    [self _setWindowOpacity:alphaValue];
-    
-    //
-    if (alphaValue == maxOpacity || alphaValue == WINDOW_FADE_MIN) {
-        [visibilityTimer invalidate]; [visibilityTimer release]; visibilityTimer = nil;
-    }
-}
-
 - (void)_setWindowOpacity:(float)opacity
 {
     [panel setAlphaValue:opacity];
-    [panel setOpaque:(opacity == 1.0)];
 }
 
 
diff -r 28244ecc5cca -r efda39dfffb9 Source/ESDebugController.m
--- a/Source/ESDebugController.m	Wed Apr 29 01:54:58 2009 -0700
+++ b/Source/ESDebugController.m	Wed Apr 29 08:15:51 2009 -0700
@@ -26,6 +26,8 @@
 #include <errno.h>  //errno
 #include <string.h> //strerror(3)
 
+#import <objc/objc-runtime.h>
+
 #define	CACHED_DEBUG_LOGS		100		//Number of logs to keep at any given time
 #define	KEY_DEBUG_WINDOW_OPEN	@"Debug Window Open"
 
@@ -33,12 +35,20 @@
 
 static ESDebugController	*sharedDebugController = nil;
 
+//Throwing an exception isn't enough, we need to die completely.
+void AIExplodeOnEnumerationMutation(id dummy) {
+	NSLog(@"Attempted to mutate collection %@ of class %@ while enumerating", dummy, [dummy class]);
+	*((int*)0xdeadbeef) = 42;
+}
+
 - (id)init
 {
 	if (sharedDebugController)
 		self = sharedDebugController;
 	else {	
 		if ((self = [super init])) {
+			objc_setEnumerationMutationHandler(AIExplodeOnEnumerationMutation);
+
 			sharedDebugController = self;
 
 			debugLogArray = [[NSMutableArray alloc] init];		




More information about the commits mailing list