Fix runMode:beforeDate: to work with nil date.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14634 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-10-03 16:21:06 +00:00
parent 6a8a097842
commit 51291c6815
2 changed files with 21 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2002-10-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSRunLoop.m: ([-runMode:beforeDate:]) permit the use of a
nil date and document it. This is the behavior MacOS seems to have
and seems to be more useful than prohibiting nil dates.
2002-10-02 Richard Frith-Macdonald <rfm@gnu.org> 2002-10-02 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSDistributedLock.m: Document and tidy. * Source/NSDistributedLock.m: Document and tidy.

View file

@ -475,7 +475,7 @@ static const NSMapTableValueCallBacks ArrayMapValueCallBacks =
} }
/** /**
* Mark this poll conext as having completed, so that if we are * Mark this poll context as having completed, so that if we are
* executing a re-entrant poll, the enclosing poll operations * executing a re-entrant poll, the enclosing poll operations
* know they can stop what they are doing because an inner * know they can stop what they are doing because an inner
* operation has done the job. * operation has done the job.
@ -1357,10 +1357,14 @@ if (0) {
item->_date = RETAIN(d); item->_date = RETAIN(d);
} }
else else
item->_date = RETAIN(theFuture); {
item->_date = RETAIN(theFuture);
}
} }
else else
item->_date = RETAIN(theFuture); {
item->_date = RETAIN(theFuture);
}
GSIArrayInsertSorted(watchers, (GSIArrayItem)item, aSort); GSIArrayInsertSorted(watchers, (GSIArrayItem)item, aSort);
} }
@ -2033,6 +2037,8 @@ if (0) {
/** /**
* Calls -acceptInputForMode:beforeDate: to run the loop once.<br /> * Calls -acceptInputForMode:beforeDate: to run the loop once.<br />
* The specified date may be nil ... in which case the loop runs
* until the first input or timeout.<br />
* If the limit dates for all of mode's input sources have passed, * If the limit dates for all of mode's input sources have passed,
* returns NO without running the loop, otherwise returns YES. * returns NO without running the loop, otherwise returns YES.
*/ */
@ -2040,9 +2046,9 @@ if (0) {
{ {
id d; id d;
NSAssert(mode && date, NSInvalidArgumentException); NSAssert(mode != nil, NSInvalidArgumentException);
/* If date has already passed, simply return. */ /* If date has already passed, simply return. */
if ([date timeIntervalSinceNow] < 0) if (date != nil && [date timeIntervalSinceNow] < 0)
{ {
NSDebugMLLog(@"NSRunLoop", @"run mode with date already past"); NSDebugMLLog(@"NSRunLoop", @"run mode with date already past");
/* /*
@ -2075,7 +2081,10 @@ if (0) {
* Retain the date in case the firing of a timer (or some other event) * Retain the date in case the firing of a timer (or some other event)
* releases it. * releases it.
*/ */
d = [d earlierDate: date]; if (date != nil)
{
d = [d earlierDate: date];
}
IF_NO_GC(RETAIN(d)); IF_NO_GC(RETAIN(d));
/* Wait, listening to our input sources. */ /* Wait, listening to our input sources. */