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.
     1 //
     2 //  GrowlApplication.m
     3 //  Growl
     4 //
     5 //  Created by Evan Schoenberg on 5/10/07.
     6 //
     7 
     8 #import "GrowlApplication.h"
     9 
    10 @implementation GrowlApplication
    11 
    12 - (void)resetAutoreleasePool:(NSTimer *)timer
    13 {
    14 #pragma unused (timer)
    15 	[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined
    16 										location:NSZeroPoint
    17 								   modifierFlags:0
    18 									   timestamp: (double)(AbsoluteToDuration(UpTime())) / 1000.0
    19 									windowNumber:0
    20 										 context:NULL
    21 										 subtype:0
    22 										   data1:0 
    23 										   data2:0]
    24 			 atStart:YES];
    25 }
    26 
    27 - (void)run
    28 {
    29 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    30 	autoreleasePoolRefreshTimer = [[NSTimer scheduledTimerWithTimeInterval:30
    31 									  target:self
    32 									selector:@selector(resetAutoreleasePool:)
    33 									userInfo:nil
    34 									 repeats:YES] retain];
    35 	[pool release];
    36 
    37 	[super run];
    38 
    39 	[autoreleasePoolRefreshTimer invalidate];
    40 	[autoreleasePoolRefreshTimer release];
    41 	autoreleasePoolRefreshTimer = nil;
    42 }
    43 
    44 @end