summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qnamespace.qdoc6
-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
-rw-r--r--src/corelib/kernel/qmath.qdoc1
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp2
-rw-r--r--src/corelib/tools/qcollator_icu.cpp43
-rw-r--r--src/corelib/tools/qelapsedtimer_win.cpp10
12 files changed, 71 insertions, 49 deletions
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 669bc7a17a..ea174abca9 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2126,7 +2126,8 @@
regardless of whether the parent widget is embedded in a scene or
not.
- \value WindowShadeButtonHint
+ \value WindowShadeButtonHint Adds a shade button in place of the minimize
+ button if the underlying window manager supports it.
\value WindowStaysOnTopHint Informs the window system that the
window should stay on top of all other windows. Note that
@@ -2448,8 +2449,9 @@
Flags that alter the behavior:
- \value ImhHiddenText Characters should be hidden, as is typically used when entering passwords.
+ \value ImhHiddenText The input method should not show the characters while typing.
This is automatically set when setting QLineEdit::echoMode to \c Password.
+ Note that setting \c ImhHiddenText does not change the echo mode.
\value ImhSensitiveData Typed text should not be stored by the active input method
in any persistent storage like predictive user dictionary.
\value ImhNoAutoUppercase The input method should not try to automatically switch to upper case
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;
}
}
diff --git a/src/corelib/kernel/qmath.qdoc b/src/corelib/kernel/qmath.qdoc
index b2c8b42209..b0583d818e 100644
--- a/src/corelib/kernel/qmath.qdoc
+++ b/src/corelib/kernel/qmath.qdoc
@@ -215,6 +215,7 @@
\snippet code/src_corelib_kernel_qmath.cpp 3
\sa qDegreesToRadians()
+*/
/*!
\fn quint32 qNextPowerOfTwo(quint32 value)
diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp
index 9693558a4c..c8508ac0d2 100644
--- a/src/corelib/mimetypes/qmimemagicrule.cpp
+++ b/src/corelib/mimetypes/qmimemagicrule.cpp
@@ -217,6 +217,8 @@ static inline QByteArray makePattern(const QByteArray &value)
*data++ = '\n';
} else if (*p == 'r') {
*data++ = '\r';
+ } else if (*p == 't') {
+ *data++ = '\t';
} else { // escaped
*data++ = *p;
}
diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp
index 6fa681b63b..f068f22d13 100644
--- a/src/corelib/tools/qcollator_icu.cpp
+++ b/src/corelib/tools/qcollator_icu.cpp
@@ -52,8 +52,12 @@ void QCollatorPrivate::init()
UErrorCode status = U_ZERO_ERROR;
QByteArray name = locale.bcp47Name().replace(QLatin1Char('-'), QLatin1Char('_')).toLatin1();
collator = ucol_open(name.constData(), &status);
- if (U_FAILURE(status))
+ if (U_FAILURE(status)) {
qWarning("Could not create collator: %d", status);
+ collator = 0;
+ dirty = false;
+ return;
+ }
// enable normalization by default
ucol_setAttribute(collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
@@ -97,17 +101,26 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con
if (d->dirty)
d->init();
- return ucol_strcoll(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2);
+ if (d->collator)
+ return ucol_strcoll(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2);
+
+ return QString::compare(QString(s1, len1), QString(s2, len2), d->caseSensitivity);
}
int QCollator::compare(const QString &s1, const QString &s2) const
{
- return compare(s1.constData(), s1.size(), s2.constData(), s2.size());
+ if (d->collator)
+ return compare(s1.constData(), s1.size(), s2.constData(), s2.size());
+
+ return QString::compare(s1, s2, d->caseSensitivity);
}
int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const
{
- return compare(s1.constData(), s1.size(), s2.constData(), s2.size());
+ if (d->collator)
+ return compare(s1.constData(), s1.size(), s2.constData(), s2.size());
+
+ return QStringRef::compare(s1, s2, d->caseSensitivity);
}
QCollatorSortKey QCollator::sortKey(const QString &string) const
@@ -115,16 +128,20 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
if (d->dirty)
d->init();
- QByteArray result(16 + string.size() + (string.size() >> 2), Qt::Uninitialized);
- int size = ucol_getSortKey(d->collator, (const UChar *)string.constData(),
- string.size(), (uint8_t *)result.data(), result.size());
- if (size > result.size()) {
- result.resize(size);
- size = ucol_getSortKey(d->collator, (const UChar *)string.constData(),
- string.size(), (uint8_t *)result.data(), result.size());
+ if (d->collator) {
+ QByteArray result(16 + string.size() + (string.size() >> 2), Qt::Uninitialized);
+ int size = ucol_getSortKey(d->collator, (const UChar *)string.constData(),
+ string.size(), (uint8_t *)result.data(), result.size());
+ if (size > result.size()) {
+ result.resize(size);
+ size = ucol_getSortKey(d->collator, (const UChar *)string.constData(),
+ string.size(), (uint8_t *)result.data(), result.size());
+ }
+ result.truncate(size);
+ return QCollatorSortKey(new QCollatorSortKeyPrivate(result));
}
- result.truncate(size);
- return QCollatorSortKey(new QCollatorSortKeyPrivate(result));
+
+ return QCollatorSortKey(new QCollatorSortKeyPrivate(QByteArray()));
}
int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp
index dcddc96e32..eab2f8ef6c 100644
--- a/src/corelib/tools/qelapsedtimer_win.cpp
+++ b/src/corelib/tools/qelapsedtimer_win.cpp
@@ -52,19 +52,13 @@ static void resolveLibs()
if (done)
return;
-#ifndef Q_OS_WINRT
+#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
// try to get GetTickCount64 from the system
HMODULE kernel32 = GetModuleHandleW(L"kernel32");
if (!kernel32)
return;
-
-#if defined(Q_OS_WINCE)
- // does this function exist on WinCE, or will ever exist?
- ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, L"GetTickCount64");
-#else
ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64");
-#endif
-#endif // !Q_OS_WINRT
+#endif // !Q_OS_WINRT && !Q_OS_WINCE
// Retrieve the number of high-resolution performance counter ticks per second
LARGE_INTEGER frequency;