diff --git a/ChangeLog b/ChangeLog index 497fc7222..9068c8a5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-04-03 Richard Frith-Macdonald + + * Source/unix/GSRunLoopCtxt.m: + * Source/win32/GSRunLoopCtxt.m: + Fix pointer ownership issue in callbacks in GC environment so we let + the garbage collector handle watchers rather than trying to free them + explicitly when we shouldn't. + 2011-04-03 Richard Frith-Macdonald * Source/NSObject.m: Fix problem with finalization of proxies and diff --git a/Source/unix/GSRunLoopCtxt.m b/Source/unix/GSRunLoopCtxt.m index 66a8931cc..5f23298f5 100644 --- a/Source/unix/GSRunLoopCtxt.m +++ b/Source/unix/GSRunLoopCtxt.m @@ -58,7 +58,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = 0 }; #else -#define WatcherMapValueCallBacks NSOwnedPointerMapValueCallBacks +#define WatcherMapValueCallBacks NSNonOwnedPointerMapValueCallBacks #endif @implementation GSRunLoopCtxt diff --git a/Source/win32/GSRunLoopCtxt.m b/Source/win32/GSRunLoopCtxt.m index f75eef037..d7fa4d74e 100644 --- a/Source/win32/GSRunLoopCtxt.m +++ b/Source/win32/GSRunLoopCtxt.m @@ -45,7 +45,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = 0 }; #else -#define WatcherMapValueCallBacks NSOwnedPointerMapValueCallBacks +#define WatcherMapValueCallBacks NSNonOwnedPointerMapValueCallBacks #endif @implementation GSRunLoopCtxt diff --git a/Tests/base/NSRunLoop/performers.m b/Tests/base/NSRunLoop/performers.m index b8c4fa913..39c970dc0 100644 --- a/Tests/base/NSRunLoop/performers.m +++ b/Tests/base/NSRunLoop/performers.m @@ -15,6 +15,7 @@ int main() NSDate *date; NSMutableString *str; NSFileHandle *fh = [NSFileHandle fileHandleWithStandardInput]; + NSTimeInterval delay = 0.1; [fh retain]; [fh readInBackgroundAndNotify]; @@ -30,7 +31,7 @@ int main() argument: @"foo" order: 0 modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; - date = [NSDate dateWithTimeIntervalSinceNow: 0.1]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; [run runUntilDate: date]; PASS([str isEqual: @"foo"], "-performSelector:target:argument:order:modes: works for one performer"); @@ -41,7 +42,7 @@ int main() argument: @"foo" order: 0 modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; - date = [NSDate dateWithTimeIntervalSinceNow: 0.1]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; [run runUntilDate: date]; [run runUntilDate: date]; PASS([str isEqual: @"foo"], @@ -58,7 +59,7 @@ int main() argument: @"foo" order: 10 modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; - date = [NSDate dateWithTimeIntervalSinceNow: 0.1]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; [run runUntilDate: date]; PASS([str isEqual: @"foobar"], "-performSelector:target:argument:order:modes: orders performers correctly"); @@ -82,7 +83,7 @@ int main() [run cancelPerformSelector: @selector(appendString:) target: str argument: @"bar"]; - date = [NSDate dateWithTimeIntervalSinceNow: 0.1]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; [run runUntilDate: date]; PASS([str isEqual: @"foozot"], "-cancelPerformSelector:target:argument: works"); @@ -99,7 +100,7 @@ int main() order: 11 modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; [run cancelPerformSelectorsWithTarget: str]; - date = [NSDate dateWithTimeIntervalSinceNow: 0.1]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; [run runUntilDate: date]; PASS([str isEqualToString: @""], "-cancelPerformSelectorsWithTarget: works %s",[str cString]);