Core/Source/GrowlApplication.m
author Peter Hosey <hg@boredzo.org>
Sat Sep 26 17:36:19 2009 -0700 (2009-09-26)
changeset 4439 8e5827d639dc
parent 4317 1e9e11a7092f
child 4858 ec71a469e0b8
permissions -rw-r--r--
Fix a bug found by the static analyzer: We do not own this timer, and we were (technically) leaking it. We now correctly manage its lifetime.
evands@3551
     1
//
evands@3551
     2
//  GrowlApplication.m
evands@3551
     3
//  Growl
evands@3551
     4
//
evands@3551
     5
//  Created by Evan Schoenberg on 5/10/07.
evands@3551
     6
//
evands@3551
     7
evands@3551
     8
#import "GrowlApplication.h"
evands@3551
     9
evands@3551
    10
@implementation GrowlApplication
Evan@4317
    11
evands@3551
    12
- (void)resetAutoreleasePool:(NSTimer *)timer
evands@3551
    13
{
evands@3551
    14
#pragma unused (timer)
Evan@4317
    15
	[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined
Evan@4317
    16
										location:NSZeroPoint
Evan@4317
    17
								   modifierFlags:0
Evan@4317
    18
									   timestamp: (double)(AbsoluteToDuration(UpTime())) / 1000.0
Evan@4317
    19
									windowNumber:0
Evan@4317
    20
										 context:NULL
Evan@4317
    21
										 subtype:0
Evan@4317
    22
										   data1:0 
Evan@4317
    23
										   data2:0]
Evan@4317
    24
			 atStart:YES];
evands@3551
    25
}
evands@3551
    26
evands@3551
    27
- (void)run
evands@3551
    28
{
Evan@4317
    29
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
hg@4439
    30
	autoreleasePoolRefreshTimer = [[NSTimer scheduledTimerWithTimeInterval:30
evands@3551
    31
									  target:self
evands@3551
    32
									selector:@selector(resetAutoreleasePool:)
evands@3551
    33
									userInfo:nil
evands@3551
    34
									 repeats:YES] retain];
Evan@4317
    35
	[pool release];
Evan@4317
    36
evands@3551
    37
	[super run];
hg@4439
    38
hg@4439
    39
	[autoreleasePoolRefreshTimer invalidate];
hg@4439
    40
	[autoreleasePoolRefreshTimer release];
hg@4439
    41
	autoreleasePoolRefreshTimer = nil;
evands@3551
    42
}
evands@3551
    43
evands@3551
    44
@end