Hmmm sorry but its clearly none of these solutions that will fix the problem: if context watchers is empty the run loop will never execute -[GSRunLoopCtxt pollUntil:within:]!
So I suggest an another patch to fix this. Sorry for the inconvenience. Regards On Fri, 2013-03-01 at 17:39 +0100, Jean-Charles BERTIN wrote: > Ok, I didn't see this one: by adding systematically the dispatch watcher > in GSRunLoopCtxt for the main thread, I broke the -[NSRunLoop run] and > -[NSRunLoop runUntilDate:] methods. Since there is always at least one > watcher, the methods never return. > > I wonder how I can correct this: > 1/ add an ivar specialWatchers which is a GSIArray and add the dispatch > watcher to it. We can then factorize the code in -[GSRunLoopCtxt > pollUntil:within:] which prepare the poll to a new private method which > could be like this: -(BOOL)_prepareForPoll:(GSIArray)watchers. This > method returns the value of immediate variable. > 2/ or add an ivar dispatchWatcher only if GS_HAVE_LIBDISPATCH_COMPAT > macro is defined and handle it if not NULL inside -[GSRunLoopCtxt > pollUntil:within:]. > > The main goal for these two solutions is to not modify the behavior of > code where GSIArrayCount(context->watchers) is compared against zero. > > I prefer the first one because this specialWatchers could be reused if > needed. However it implies that every loop contexts will be impacted. > > What do you think? > > On Wed, 2013-02-27 at 17:29 +0100, Jean-Charles BERTIN wrote: > > --- > > Source/GSRunLoopWatcher.h | 11 +++ > > Source/GSRunLoopWatcher.m | 163 > > ++++++++++++++++++++++++++++++++++++++++++-- > > Source/unix/GSRunLoopCtxt.m | 13 ++++ > > 3 files changed, 182 insertions(+), 5 deletions(-) > > > > _______________________________________________ > > Gnustep-dev mailing list > > [email protected] > > https://lists.gnu.org/mailman/listinfo/gnustep-dev > > _______________________________________________ > Gnustep-dev mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/gnustep-dev -- Jean-Charles BERTIN Axinoe - Software Engineer Tel.: (+33) (0)1.80.82.59.23 Fax : (+33) (0)1.80.82.59.29 Skype: jcbertin Web: <http://www.axinoe.com/> Certificate Authority: <https://ca.axinoe.com/axinoe-root.crt>
diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m
index e8d03e3..1b623f5 100644
--- a/Source/NSRunLoop.m
+++ b/Source/NSRunLoop.m
@@ -1259,8 +1259,16 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSDate *d;
+ GSRunLoopCtxt *context;
+ unsigned int inputCount;
NSAssert1(mode != nil, @"%@", NSInvalidArgumentException);
+ context = NSMapGet(_contextMap, mode);
+ if (context == nil)
+ {
+ [arp drain];
+ return NO;
+ }
/* Find out how long we can wait before first limit date. */
d = [self limitDateForMode: mode];
@@ -1284,9 +1292,23 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
/* Wait, listening to our input sources. */
[self acceptInputForMode: mode beforeDate: d];
+ inputCount = GSIArrayCount(context->watchers);
+#if GS_HAVE_LIBDISPATCH_COMPAT
+ if (GSIsMainThread() && inputCount == 1)
+ {
+ id dispatchWatcher = [GSDispatchWatcher sharedInstance];
+ id lastWatcher = GSIArrayItemAtIndex(context->watchers, 0).obj;
+ if (lastWatcher == dispatchWatcher)
+ {
+ inputCount --;
+ }
+ }
+#endif
+ inputCount += GSIArrayCount(context->timers);
+
[d release];
[arp drain];
- return YES;
+ return (inputCount == 0) ? NO : YES;
}
/**
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Gnustep-dev mailing list [email protected] https://lists.gnu.org/mailman/listinfo/gnustep-dev
