Use "Ex"-versions of WaitForSingle/MultipleObject(s) where possible

Not only should using the "Ex"-versions be the rule and not the
exception on Windows, but it's only the only way to share as much
code as possible between Desktop Windows and WinRT (which is pushed
by Microsoft a lot). The current rule of Desktop and WinCE vs WinRT
does not make a lot of sense any longer, as WinCE is getting less
and less important. By moving these #ifdefs in favor of WinRT,
WinCe code might be removed easier in the future.

Change-Id: I0ef94fb14fbf8add9c2dfa2a3fb8036d25fb697d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Oliver Wolff 2015-06-10 12:44:43 +02:00
parent d3ad8cff17
commit 1de6fd49d1
5 changed files with 10 additions and 11 deletions

View File

@ -652,7 +652,7 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
if (!pid) if (!pid)
return false; return false;
if (WaitForSingleObject(pid->hProcess, 0) == WAIT_OBJECT_0) { if (WaitForSingleObjectEx(pid->hProcess, 0, false) == WAIT_OBJECT_0) {
bool readyReadEmitted = drainOutputPipes(); bool readyReadEmitted = drainOutputPipes();
_q_processDied(); _q_processDied();
return readyReadEmitted; return readyReadEmitted;
@ -721,7 +721,7 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
// Wait for the process to signal any change in its state, // Wait for the process to signal any change in its state,
// such as incoming data, or if the process died. // such as incoming data, or if the process died.
if (WaitForSingleObject(pid->hProcess, 0) == WAIT_OBJECT_0) { if (WaitForSingleObjectEx(pid->hProcess, 0, false) == WAIT_OBJECT_0) {
_q_processDied(); _q_processDied();
return false; return false;
} }

View File

@ -1075,11 +1075,10 @@ void QEventDispatcherWin32::activateEventNotifiers()
for (int i=0; i<d->winEventNotifierList.count(); i++) { for (int i=0; i<d->winEventNotifierList.count(); i++) {
#if !defined(Q_OS_WINCE) #if !defined(Q_OS_WINCE)
if (WaitForSingleObjectEx(d->winEventNotifierList.at(i)->handle(), 0, TRUE) == WAIT_OBJECT_0) if (WaitForSingleObjectEx(d->winEventNotifierList.at(i)->handle(), 0, TRUE) == WAIT_OBJECT_0)
d->activateEventNotifier(d->winEventNotifierList.at(i));
#else #else
if (WaitForSingleObject(d->winEventNotifierList.at(i)->handle(), 0) == WAIT_OBJECT_0) if (WaitForSingleObject(d->winEventNotifierList.at(i)->handle(), 0) == WAIT_OBJECT_0)
d->activateEventNotifier(d->winEventNotifierList.at(i));
#endif #endif
d->activateEventNotifier(d->winEventNotifierList.at(i));
} }
} }

View File

@ -115,7 +115,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
return false; return false;
} }
} else { } else {
#if defined(Q_OS_WINRT) #if !defined(Q_OS_WINCE)
if (WAIT_OBJECT_0 != WaitForSingleObjectEx(semaphore, INFINITE, FALSE)) { if (WAIT_OBJECT_0 != WaitForSingleObjectEx(semaphore, INFINITE, FALSE)) {
#else #else
if (WAIT_OBJECT_0 != WaitForSingleObject(semaphore, INFINITE)) { if (WAIT_OBJECT_0 != WaitForSingleObject(semaphore, INFINITE)) {

View File

@ -55,10 +55,10 @@ QMutexPrivate::~QMutexPrivate()
bool QMutexPrivate::wait(int timeout) bool QMutexPrivate::wait(int timeout)
{ {
#ifndef Q_OS_WINRT #ifndef Q_OS_WINCE
return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
#else
return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0); return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0);
#else
return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
#endif #endif
} }

View File

@ -109,10 +109,10 @@ bool QWaitConditionPrivate::wait(QWaitConditionEvent *wce, unsigned long time)
{ {
// wait for the event // wait for the event
bool ret = false; bool ret = false;
#ifndef Q_OS_WINRT #ifndef Q_OS_WINCE
switch (WaitForSingleObject(wce->event, time)) {
#else
switch (WaitForSingleObjectEx(wce->event, time, FALSE)) { switch (WaitForSingleObjectEx(wce->event, time, FALSE)) {
#else
switch (WaitForSingleObject(wce->event, time)) {
#endif #endif
default: break; default: break;