mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
fix bad return value when polling for windows messages
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40000 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
39cc09e2ca
commit
f8f4bb51e3
4 changed files with 34 additions and 19 deletions
|
@ -1,3 +1,10 @@
|
|||
2016-07-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/win32/GSRunLoopCtxt.m: fix bug in return value when polling.
|
||||
The poll method must return YES if any input source fired, including
|
||||
handling of windows messages which are already available and require
|
||||
no wait.
|
||||
|
||||
2016-07-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* configure.ac:
|
||||
|
|
|
@ -83,7 +83,7 @@ typedef struct{
|
|||
}
|
||||
/* Check to see of the thread has been awakened, blocking until it
|
||||
* does get awakened or until the limit date has been reached.
|
||||
* A date in the past (or nil) results in a check follwed by an
|
||||
* A date in the past (or nil) results in a check followed by an
|
||||
* immediate return.
|
||||
*/
|
||||
+ (BOOL) awakenedBefore: (NSDate*)when;
|
||||
|
|
|
@ -1163,11 +1163,6 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
|
|||
BOOL done = NO;
|
||||
NSDate *when;
|
||||
|
||||
if ([_contextStack indexOfObjectIdenticalTo: context] == NSNotFound)
|
||||
{
|
||||
[_contextStack addObject: context];
|
||||
}
|
||||
|
||||
while (NO == done)
|
||||
{
|
||||
when = [self _limitDateForContext: context];
|
||||
|
@ -1224,6 +1219,10 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
|
|||
@"accept I/P before %d millisec from now in %@",
|
||||
timeout_ms, mode);
|
||||
|
||||
if ([_contextStack indexOfObjectIdenticalTo: context] == NSNotFound)
|
||||
{
|
||||
[_contextStack addObject: context];
|
||||
}
|
||||
done = [context pollUntil: timeout_ms within: _contextStack];
|
||||
if (NO == done)
|
||||
{
|
||||
|
@ -1236,16 +1235,18 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
|
|||
[self _checkPerformers: context];
|
||||
GSPrivateNotifyASAP(_currentMode);
|
||||
[context endPoll];
|
||||
|
||||
/* Once a poll has been completed on a context, we can remove that
|
||||
* context from the stack even if it actually polling at an outer
|
||||
* level of re-entrancy ... since the poll we have just done will
|
||||
* have handled any events that the outer levels would have wanted
|
||||
* to handle, and the polling for this context will be marked as
|
||||
* ended.
|
||||
*/
|
||||
[_contextStack removeObjectIdenticalTo: context];
|
||||
}
|
||||
|
||||
/* Once a poll has been completed on a context, we can remove that
|
||||
* context from the stack even if it actually polling at an outer
|
||||
* level of re-entrancy ... since the poll we have just done will
|
||||
* have handled any events that the outer levels would have wanted
|
||||
* to handle, and the polling for this context will be marked as ended.
|
||||
*/
|
||||
_currentMode = savedMode;
|
||||
[_contextStack removeObjectIdenticalTo: context];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
|
|
|
@ -282,6 +282,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
int wait_timeout;
|
||||
DWORD wait_return;
|
||||
BOOL immediate = NO;
|
||||
BOOL existingMessages = NO;
|
||||
|
||||
// Set timeout how much time should wait
|
||||
if (milliseconds >= 0)
|
||||
|
@ -404,10 +405,11 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
*/
|
||||
if ([self processAllWindowsMessages: num_winMsgs within: contexts] == YES)
|
||||
{
|
||||
wait_timeout = 0; // Processed something ... no need to wait.
|
||||
// Processed something ... no need to wait.
|
||||
wait_return = WAIT_OBJECT_0;
|
||||
existingMessages = YES;
|
||||
}
|
||||
|
||||
if (num_winMsgs > 0)
|
||||
else if (num_winMsgs > 0)
|
||||
{
|
||||
/*
|
||||
* Wait for signalled events or window messages.
|
||||
|
@ -465,7 +467,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
}
|
||||
|
||||
/*
|
||||
* Trigger any watchers which are set up to for every runloop wait.
|
||||
* Trigger any watchers which are set up to trigger for every runloop wait.
|
||||
*/
|
||||
count = GSIArrayCount(_trigger);
|
||||
completed = NO;
|
||||
|
@ -499,12 +501,17 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
|||
GSPrivateNotifyASAP(mode);
|
||||
}
|
||||
|
||||
if (existingMessages)
|
||||
{
|
||||
NSDebugMLLog(@"NSRunLoop", @"processed windows messages");
|
||||
return YES;
|
||||
}
|
||||
|
||||
// if there are windows message
|
||||
if (wait_return == WAIT_OBJECT_0 + num_handles)
|
||||
{
|
||||
NSDebugMLLog(@"NSRunLoop", @"processing windows messages");
|
||||
[self processAllWindowsMessages: num_winMsgs within: contexts];
|
||||
return NO;
|
||||
return [self processAllWindowsMessages: num_winMsgs within: contexts];
|
||||
}
|
||||
|
||||
// if there aren't events
|
||||
|
|
Loading…
Reference in a new issue