diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-01 11:27:03 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-04-01 11:27:03 +0000 |
commit | 26a9783d55da551984b8c408faa837ff83df8c50 (patch) | |
tree | ad8ec0b16013fecbd6dc99bbf8999db4c6073b67 /src/corelib/io | |
parent | f53621af053f313eff7fa7b204b5cceff675cb64 (diff) | |
parent | ce9519593a0b3deb99d1dd2529770f7e9fffef92 (diff) |
Merge "Merge remote-tracking branch 'origin/5.4' into 5.5" into refs/staging/5.5
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 17 | ||||
-rw-r--r-- | src/corelib/io/qiodevice_p.h | 2 | ||||
-rw-r--r-- | src/corelib/io/qprocess.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 19 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths.cpp | 3 | ||||
-rw-r--r-- | src/corelib/io/qwinoverlappedionotifier.cpp | 9 |
7 files changed, 32 insertions, 26 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 5b18a85dd4..19343f22ff 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -545,7 +545,7 @@ bool QFSFileEngine::renameOverwrite(const QString &newName) (wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0; if (!ret) { ret = ::DeleteFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0; - if (ret) + if (ret || ::GetLastError() == ERROR_FILE_NOT_FOUND) ret = ::MoveFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(), (wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0; } diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 7eb917c71f..f2655dab3c 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1629,6 +1629,23 @@ QString QIODevice::errorString() const \sa read(), write() */ +/*! + \internal + \fn int qt_subtract_from_timeout(int timeout, int elapsed) + + Reduces the \a timeout by \a elapsed, taking into account that -1 is a + special value for timeouts. +*/ + +int qt_subtract_from_timeout(int timeout, int elapsed) +{ + if (timeout == -1) + return -1; + + timeout = timeout - elapsed; + return timeout < 0 ? 0 : timeout; +} + #if !defined(QT_NO_DEBUG_STREAM) QDebug operator<<(QDebug debug, QIODevice::OpenMode modes) diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h index 7b4657f262..f4cf387eb5 100644 --- a/src/corelib/io/qiodevice_p.h +++ b/src/corelib/io/qiodevice_p.h @@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE #define QIODEVICE_BUFFERSIZE Q_INT64_C(16384) #endif +Q_CORE_EXPORT int qt_subtract_from_timeout(int timeout, int elapsed); + // This is QIODevice's read buffer, optimized for read(), isEmpty() and getChar() class QIODevicePrivateLinearBuffer { diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 6451bae0ba..7d7cdef203 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1806,8 +1806,7 @@ bool QProcess::waitForBytesWritten(int msecs) bool started = waitForStarted(msecs); if (!started) return false; - if (msecs != -1) - msecs -= stopWatch.elapsed(); + msecs = qt_subtract_from_timeout(msecs, stopWatch.elapsed()); } return d->waitForBytesWritten(msecs); @@ -1843,8 +1842,7 @@ bool QProcess::waitForFinished(int msecs) bool started = waitForStarted(msecs); if (!started) return false; - if (msecs != -1) - msecs -= stopWatch.elapsed(); + msecs = qt_subtract_from_timeout(msecs, stopWatch.elapsed()); } return d->waitForFinished(msecs); diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index fcebc08d7f..ffdf6f9e2e 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -822,19 +822,6 @@ void QProcessPrivate::killProcess() ::kill(pid_t(pid), SIGKILL); } -/* - Returns the difference between msecs and elapsed. If msecs is -1, - however, -1 is returned. -*/ -static int qt_timeout_value(int msecs, int elapsed) -{ - if (msecs == -1) - return -1; - - int timeout = msecs - elapsed; - return timeout < 0 ? 0 : timeout; -} - bool QProcessPrivate::waitForStarted(int msecs) { Q_Q(QProcess); @@ -909,7 +896,7 @@ bool QProcessPrivate::waitForReadyRead(int msecs) if (!stdinChannel.buffer.isEmpty() && stdinChannel.pipe[1] != -1) add_fd(nfds, stdinChannel.pipe[1], &fdwrite); - int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); + int timeout = qt_subtract_from_timeout(msecs, stopWatch.elapsed()); #ifdef Q_OS_BLACKBERRY int ret = bb_select(notifiers, nfds + 1, &fdread, &fdwrite, timeout); #else @@ -990,7 +977,7 @@ bool QProcessPrivate::waitForBytesWritten(int msecs) if (!stdinChannel.buffer.isEmpty() && stdinChannel.pipe[1] != -1) add_fd(nfds, stdinChannel.pipe[1], &fdwrite); - int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); + int timeout = qt_subtract_from_timeout(msecs, stopWatch.elapsed()); #ifdef Q_OS_BLACKBERRY int ret = bb_select(notifiers, nfds + 1, &fdread, &fdwrite, timeout); #else @@ -1065,7 +1052,7 @@ bool QProcessPrivate::waitForFinished(int msecs) if (!stdinChannel.buffer.isEmpty() && stdinChannel.pipe[1] != -1) add_fd(nfds, stdinChannel.pipe[1], &fdwrite); - int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); + int timeout = qt_subtract_from_timeout(msecs, stopWatch.elapsed()); #ifdef Q_OS_BLACKBERRY int ret = bb_select(notifiers, nfds + 1, &fdread, &fdwrite, timeout); #else diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 4fd429cad4..c5c596fd2e 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -113,6 +113,9 @@ QT_BEGIN_NAMESPACE \value GenericCacheLocation Returns a directory location where user-specific non-essential (cached) data, shared across applications, should be written. This is a generic value. Note that the returned path may be empty if the system has no concept of shared cache. + \value GenericDataLocation Returns a directory location where persistent + data shared across applications can be stored. This is a generic value. The returned + path is never empty. \value RuntimeLocation Returns a directory location where runtime communication files should be written, like Unix local sockets. This is a generic value. The returned path may be empty on some systems. diff --git a/src/corelib/io/qwinoverlappedionotifier.cpp b/src/corelib/io/qwinoverlappedionotifier.cpp index 17d546c0ce..083feb4a20 100644 --- a/src/corelib/io/qwinoverlappedionotifier.cpp +++ b/src/corelib/io/qwinoverlappedionotifier.cpp @@ -41,6 +41,7 @@ #include <qthread.h> #include <qt_windows.h> #include <private/qobject_p.h> +#include <private/qiodevice_p.h> QT_BEGIN_NAMESPACE @@ -332,11 +333,9 @@ bool QWinOverlappedIoNotifier::waitForNotified(int msecs, OVERLAPPED *overlapped return false; if (triggeredOverlapped == overlapped) return true; - if (msecs != -1) { - t = msecs - stopWatch.elapsed(); - if (t < 0) - return false; - } + msecs = qt_subtract_from_timeout(msecs, stopWatch.elapsed()); + if (t == 0) + return false; } } |