summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2013-07-04 14:45:36 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-05 13:37:22 +0200
commit3f605c8b45634c3fae06610b1102cbeae2382bec (patch)
tree2adbbbbef17501243b4afc35b87a63c070a25b74
parenta4478b28966c5f630ba3d93b97bc91a3cec2fdbe (diff)
bail out early in QWinOverlappedIoNotifier::waitForNotified
Calling waitForNotified on an uninitialized notifier will print a warning and return false. The autotest has been adjusted. Change-Id: I85e18d6d0a8a5462e1a5d451613add941d89b5fb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
-rw-r--r--src/corelib/io/qwinoverlappedionotifier.cpp7
-rw-r--r--tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp1
2 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/io/qwinoverlappedionotifier.cpp b/src/corelib/io/qwinoverlappedionotifier.cpp
index 8f4b8be9a3..7ba862c602 100644
--- a/src/corelib/io/qwinoverlappedionotifier.cpp
+++ b/src/corelib/io/qwinoverlappedionotifier.cpp
@@ -122,6 +122,8 @@ public:
mutex.unlock();
}
+ using QThread::isRunning;
+
protected:
void run()
{
@@ -216,6 +218,11 @@ void QWinOverlappedIoNotifier::setEnabled(bool enabled)
*/
bool QWinOverlappedIoNotifier::waitForNotified(int msecs, OVERLAPPED *overlapped)
{
+ if (!iocp->isRunning()) {
+ qWarning("Called QWinOverlappedIoNotifier::waitForNotified on inactive notifier.");
+ return false;
+ }
+
forever {
DWORD result = WaitForSingleObject(hSemaphore, msecs == -1 ? INFINITE : DWORD(msecs));
if (result == WAIT_OBJECT_0) {
diff --git a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp
index bad77b1e06..0944f32443 100644
--- a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp
+++ b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp
@@ -175,7 +175,6 @@ void tst_QWinOverlappedIoNotifier::waitForNotified()
HANDLE hFile = CreateFile(reinterpret_cast<const wchar_t*>(fileName.utf16()),
GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
- QCOMPARE(notifier.waitForNotified(0, 0), false);
notifier.setHandle(hFile);
notifier.setEnabled(true);
QCOMPARE(notifier.waitForNotified(100, 0), false);