Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

Commit

Permalink
Fixed memory leak in MWCocoaEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
cstawarz committed Jun 22, 2010
1 parent c48e63d commit 5a7645d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Source/MWCocoaEvent.m
Expand Up @@ -23,10 +23,19 @@ - (id) initWithData:(Datum *)data
return self;
}

- (void)dealloc {
delete _data;
[super dealloc];
}

// finalize is called instead of dealloc when garbage collection is enabled. Since we don't currently
// support GC, there's no need for this.
/*
- (void)finalize {
delete _data;
[super finalize];
}
*/

- (MWorksTime)time {
return _time;
Expand Down
9 changes: 5 additions & 4 deletions Source/MWCocoaEventFunctor.h
Expand Up @@ -57,9 +57,9 @@ namespace mw {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

Datum data(event->getData());
id cocoaEvent = [[[MWCocoaEvent alloc] initWithData:&data
andCode:event->getEventCode()
andTime:event->getTime()] autorelease];
MWCocoaEvent *cocoaEvent = [[MWCocoaEvent alloc] initWithData:&data
andCode:event->getEventCode()
andTime:event->getTime()];

//@synchronized(syncobject){
if([receiver respondsToSelector:selector]) {
Expand All @@ -79,7 +79,8 @@ namespace mw {
merror(M_CLIENT_MESSAGE_DOMAIN, [[errorMessage stringByAppendingString:sn] cStringUsingEncoding:NSASCIIStringEncoding]);
}
//}
[pool release];
[cocoaEvent release];
[pool drain];
};
};

Expand Down

0 comments on commit 5a7645d

Please sign in to comment.