diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-11-04 12:27:37 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-11-04 12:28:48 +0100 |
commit | f8246099eafbfa08910544a89c7a5047af92f54d (patch) | |
tree | efd2a67ce5d866f4b46a2bbf804a5f9195d0d863 /src/corelib/io | |
parent | 1bf639d5605863970b8dc5a91d5fc785cdf0ecf1 (diff) | |
parent | 6ed957fd7fc748143093fa335d8b4506c3ea16fa (diff) |
Merge remote-tracking branch 'origin/5.5' into 5.6
Conflicts:
src/corelib/io/qstorageinfo_unix.cpp
src/plugins/platforms/windows/qwindowsmousehandler.cpp
src/widgets/styles/qwindowsvistastyle.cpp
Change-Id: Ie1725933815891cc8c86258d4c0e8ed0ab386edf
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qstorageinfo_unix.cpp | 10 | ||||
-rw-r--r-- | src/corelib/io/qwindowspipereader.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qwinoverlappedionotifier.cpp | 62 |
3 files changed, 59 insertions, 17 deletions
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 262703b9e6..e365d8d7e6 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -68,8 +68,8 @@ #if defined(Q_OS_BSD4) # if defined(Q_OS_NETBSD) - define QT_STATFSBUF struct statvfs - define QT_STATFS ::statvfs +# define QT_STATFSBUF struct statvfs +# define QT_STATFS ::statvfs # else # define QT_STATFSBUF struct statfs # define QT_STATFS ::statfs @@ -507,9 +507,15 @@ void QStorageInfoPrivate::retrieveVolumeInfo() valid = true; ready = true; +#if defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD) + bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize; + bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize; + bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize; +#else bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize; bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize; bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize; +#endif blockSize = statfs_buf.f_bsize; #if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4) #if defined(_STATFS_F_FLAGS) diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index a49fcdaf9f..f0d6417483 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -186,6 +186,10 @@ void QWindowsPipeReader::notified(quint32 numberOfBytesRead, quint32 errorCode, case ERROR_PIPE_NOT_CONNECTED: pipeBroken = true; break; + case ERROR_OPERATION_ABORTED: + if (stopped) + break; + // fall through default: emit winError(errorCode, QLatin1String("QWindowsPipeReader::notified")); pipeBroken = true; diff --git a/src/corelib/io/qwinoverlappedionotifier.cpp b/src/corelib/io/qwinoverlappedionotifier.cpp index 083feb4a20..c6ce15c2c9 100644 --- a/src/corelib/io/qwinoverlappedionotifier.cpp +++ b/src/corelib/io/qwinoverlappedionotifier.cpp @@ -33,6 +33,7 @@ #include "qwinoverlappedionotifier_p.h" #include <qdebug.h> +#include <qatomic.h> #include <qelapsedtimer.h> #include <qmutex.h> #include <qpointer.h> @@ -99,6 +100,7 @@ public: { } + OVERLAPPED *waitForAnyNotified(int msecs); void notify(DWORD numberOfBytes, DWORD errorCode, OVERLAPPED *overlapped); OVERLAPPED *_q_notified(); @@ -108,6 +110,7 @@ public: HANDLE hHandle; HANDLE hSemaphore; HANDLE hResultsMutex; + QAtomicInt waiting; QQueue<IOResult> results; }; @@ -286,28 +289,21 @@ void QWinOverlappedIoNotifier::setEnabled(bool enabled) d->iocp->unregisterNotifier(d); } -/*! - * Wait synchronously for any notified signal. - * - * The function returns a pointer to the OVERLAPPED object corresponding to the completed I/O - * operation. In case no I/O operation was completed during the \a msec timeout, this function - * returns a null pointer. - */ -OVERLAPPED *QWinOverlappedIoNotifier::waitForAnyNotified(int msecs) +OVERLAPPED *QWinOverlappedIoNotifierPrivate::waitForAnyNotified(int msecs) { - Q_D(QWinOverlappedIoNotifier); - if (!d->iocp->isRunning()) { + if (!iocp->isRunning()) { qWarning("Called QWinOverlappedIoNotifier::waitForAnyNotified on inactive notifier."); return 0; } if (msecs == 0) - d->iocp->drainQueue(); + iocp->drainQueue(); - switch (WaitForSingleObject(d->hSemaphore, msecs == -1 ? INFINITE : DWORD(msecs))) { + const DWORD wfso = WaitForSingleObject(hSemaphore, msecs == -1 ? INFINITE : DWORD(msecs)); + switch (wfso) { case WAIT_OBJECT_0: - ReleaseSemaphore(d->hSemaphore, 1, NULL); - return d->_q_notified(); + ReleaseSemaphore(hSemaphore, 1, NULL); + return _q_notified(); case WAIT_TIMEOUT: return 0; default: @@ -316,6 +312,39 @@ OVERLAPPED *QWinOverlappedIoNotifier::waitForAnyNotified(int msecs) } } +class QScopedAtomicIntIncrementor +{ +public: + QScopedAtomicIntIncrementor(QAtomicInt &i) + : m_int(i) + { + ++m_int; + } + + ~QScopedAtomicIntIncrementor() + { + --m_int; + } + +private: + QAtomicInt &m_int; +}; + +/*! + * Wait synchronously for any notified signal. + * + * The function returns a pointer to the OVERLAPPED object corresponding to the completed I/O + * operation. In case no I/O operation was completed during the \a msec timeout, this function + * returns a null pointer. + */ +OVERLAPPED *QWinOverlappedIoNotifier::waitForAnyNotified(int msecs) +{ + Q_D(QWinOverlappedIoNotifier); + QScopedAtomicIntIncrementor saii(d->waiting); + OVERLAPPED *result = d->waitForAnyNotified(msecs); + return result; +} + /*! * Wait synchronously for the notified signal. * @@ -324,6 +353,8 @@ OVERLAPPED *QWinOverlappedIoNotifier::waitForAnyNotified(int msecs) */ bool QWinOverlappedIoNotifier::waitForNotified(int msecs, OVERLAPPED *overlapped) { + Q_D(QWinOverlappedIoNotifier); + QScopedAtomicIntIncrementor saii(d->waiting); int t = msecs; QElapsedTimer stopWatch; stopWatch.start(); @@ -350,7 +381,8 @@ void QWinOverlappedIoNotifierPrivate::notify(DWORD numberOfBytes, DWORD errorCod results.enqueue(IOResult(numberOfBytes, errorCode, overlapped)); ReleaseMutex(hResultsMutex); ReleaseSemaphore(hSemaphore, 1, NULL); - emit q->_q_notify(); + if (!waiting) + emit q->_q_notify(); } OVERLAPPED *QWinOverlappedIoNotifierPrivate::_q_notified() |