summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-03-31 10:03:31 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-03-31 10:03:31 +0200
commitce9519593a0b3deb99d1dd2529770f7e9fffef92 (patch)
treec9bca05230dd68f49494240ae930bad1fe0c5956 /src/corelib/io
parent509f77cca28aa3edea5523c5869bae4412ed2ccc (diff)
parent7baaec17edb06634f1d6235a55c7adbd112cba3e (diff)
Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts: mkspecs/android-g++/qmake.conf qmake/generators/unix/unixmake2.cpp src/gui/image/qimage_conversions.cpp Change-Id: Ib76264b8c2d29a0228438ec02bd97d4b97545be0
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp2
-rw-r--r--src/corelib/io/qiodevice.cpp17
-rw-r--r--src/corelib/io/qiodevice_p.h2
-rw-r--r--src/corelib/io/qprocess.cpp6
-rw-r--r--src/corelib/io/qprocess_unix.cpp19
-rw-r--r--src/corelib/io/qstandardpaths.cpp3
-rw-r--r--src/corelib/io/qwinoverlappedionotifier.cpp9
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;
}
}