diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-07-09 03:04:20 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2019-07-11 14:28:46 +0200 |
commit | b24e07cbcbf7d7846baaaab77d632a2422128ada (patch) | |
tree | 59b58db2a2450a696d5419b4f8f47112a40a80d3 /src | |
parent | 493697bf951d8baa40203027baa0528f4d27cdca (diff) | |
parent | 9509b6d3ee02c3c4a0b98dc95bc9787a3c514a18 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
.qmake.conf
Change-Id: I5ce880f305ebb0af7f7803769cecf2c899bede12
Diffstat (limited to 'src')
-rw-r--r-- | src/serialport/qwinoverlappedionotifier.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/serialport/qwinoverlappedionotifier.cpp b/src/serialport/qwinoverlappedionotifier.cpp index 615dacc9..233ee696 100644 --- a/src/serialport/qwinoverlappedionotifier.cpp +++ b/src/serialport/qwinoverlappedionotifier.cpp @@ -129,6 +129,7 @@ public: HANDLE hSemaphore = nullptr; HANDLE hResultsMutex = nullptr; QAtomicInt waiting; + QAtomicInt pendingNotifications; QQueue<IOResult> results; }; @@ -395,14 +396,17 @@ void QWinOverlappedIoNotifierPrivate::notify(DWORD numberOfBytes, DWORD errorCod results.enqueue(IOResult(numberOfBytes, errorCode, overlapped)); ReleaseMutex(hResultsMutex); ReleaseSemaphore(hSemaphore, 1, NULL); - if (!waiting) + if (!waiting && pendingNotifications-- == 0) emit q->_q_notify(); } void QWinOverlappedIoNotifierPrivate::_q_notified() { - if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0) - dispatchNextIoResult(); + int n = pendingNotifications.fetchAndStoreAcquire(0); + while (--n >= 0) { + if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0) + dispatchNextIoResult(); + } } OVERLAPPED *QWinOverlappedIoNotifierPrivate::dispatchNextIoResult() |