Notification-display bridges own their window controllers, so having each window controller to retain its bridge (as introduced in [325018a38208]) leaks both. Fixing this.
authorPeter Hosey <hg@boredzo.org>
Mon May 24 04:14:10 2010 -0700 (2010-05-24)
changeset 4620cd1d446f791b
parent 4619 ce8b07d8de26
child 4621 507967d00c44
Notification-display bridges own their window controllers, so having each window controller to retain its bridge (as introduced in [325018a38208]) leaks both. Fixing this.

This introduces a crash, previously masked by the leak.
Plugins/Displays/GrowlDisplayWindowController.m
     1.1 --- a/Plugins/Displays/GrowlDisplayWindowController.m	Mon May 24 02:10:55 2010 -0700
     1.2 +++ b/Plugins/Displays/GrowlDisplayWindowController.m	Mon May 24 04:14:10 2010 -0700
     1.3 @@ -115,7 +115,6 @@
     1.4  	NSFreeMapTable(startTimes);
     1.5  	NSFreeMapTable(endTimes);
     1.6  
     1.7 -	[bridge				 release];
     1.8  	[target              release];
     1.9  	[clickContext        release];
    1.10  	[clickHandlerEnabled release];
    1.11 @@ -560,9 +559,10 @@
    1.12  			NSLog(@"*** This may be an error. %@ had its bridge reset", self);
    1.13  			[bridge removeObserver:self forKeyPath:@"notification"];
    1.14  		}
    1.15 -		
    1.16 -		bridge = [theBridge retain];
    1.17 -		
    1.18 +
    1.19 +		//Do not retain! The bridge owns us; retaining the bridge here is a mutual retention—i.e., a leak.
    1.20 +		bridge = theBridge;
    1.21 +
    1.22  		[bridge addObserver:self forKeyPath:@"notification" options:NSKeyValueObservingOptionNew context:NULL];
    1.23  		[self observeValueForKeyPath:@"notification" ofObject:bridge change:nil context:NULL];
    1.24  	}