summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-06 19:10:10 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-06 19:10:25 +0200
commit20cac3d9c9c22153e9e316daff32b6050ff6be6b (patch)
treeb563a89475df9afb4f40841ec371be9488d5b1ed /src/corelib
parent8ce85d74b692392a4ea0785360156f37418cff13 (diff)
parent9eb0b09abce28b11e4915fc9c3b3e996eb19cef2 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp2
-rw-r--r--src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp7
-rw-r--r--src/corelib/doc/snippets/qloggingcategory/main.cpp7
-rw-r--r--src/corelib/global/qcompilerdetection.h3
-rw-r--r--src/corelib/global/qglobal.cpp4
-rw-r--r--src/corelib/global/qlibraryinfo.cpp2
-rw-r--r--src/corelib/global/qnamespace.qdoc6
-rw-r--r--src/corelib/io/io.pri1
-rw-r--r--src/corelib/io/qdebug_p.h129
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp2
-rw-r--r--src/corelib/io/qiodevice.cpp23
-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/qfunctions_winrt.cpp4
-rw-r--r--src/corelib/kernel/qmath.qdoc1
-rw-r--r--src/corelib/kernel/qmetatype.h6
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp2
-rw-r--r--src/corelib/plugin/quuid.cpp53
-rw-r--r--src/corelib/plugin/quuid.h39
-rw-r--r--src/corelib/tools/qcollator_icu.cpp43
-rw-r--r--src/corelib/tools/qelapsedtimer_win.cpp10
-rw-r--r--src/corelib/tools/qmargins.cpp21
-rw-r--r--src/corelib/tools/qpoint.cpp13
-rw-r--r--src/corelib/tools/qrect.cpp15
-rw-r--r--src/corelib/tools/qsize.cpp13
-rw-r--r--src/corelib/tools/qstring.cpp6
-rw-r--r--src/corelib/tools/qvarlengtharray.h9
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc9
31 files changed, 349 insertions, 120 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
index d2043539c9..6ff4f57945 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -61,7 +61,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(MyClass::Options)
//! [1]
//! [meta-object flags]
-Q_FLAGS(Options)
+Q_FLAG(Options)
//! [meta-object flags]
//! [2]
diff --git a/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp b/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp
index f71d61ed47..a9ab83f5bf 100644
--- a/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp
+++ b/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp
@@ -51,11 +51,12 @@ public:
};
//! [0]
-QDebug operator<<(QDebug dbg, const Coordinate &c)
+QDebug operator<<(QDebug debug, const Coordinate &c)
{
- dbg.nospace() << "(" << c.x() << ", " << c.y() << ")";
+ QDebugStateSaver saver(debug);
+ debug.nospace() << '(' << c.x() << ", " << c.y() << ')';
- return dbg.space();
+ return debug;
}
//! [0]
diff --git a/src/corelib/doc/snippets/qloggingcategory/main.cpp b/src/corelib/doc/snippets/qloggingcategory/main.cpp
index 6b66424875..8d76c5736e 100644
--- a/src/corelib/doc/snippets/qloggingcategory/main.cpp
+++ b/src/corelib/doc/snippets/qloggingcategory/main.cpp
@@ -59,10 +59,11 @@ struct UsbEntry {
int classtype;
};
-QDebug operator<<(QDebug &dbg, const UsbEntry &entry)
+QDebug operator<<(QDebug &debug, const UsbEntry &entry)
{
- dbg.nospace() << "" << entry.id << " (" << entry.classtype << ")";
- return dbg.space();
+ QDebugStateSaver saver(debug);
+ debug.nospace() << "" << entry.id << " (" << entry.classtype << ')';
+ return debug;
}
QList<UsbEntry> usbEntries() {
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 1774378c06..33a24a3866 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -910,6 +910,9 @@
# undef Q_COMPILER_UNICODE_STRINGS
# undef Q_COMPILER_NOEXCEPT
# endif
+# if defined(_HAS_DINKUM_CLIB) && !defined(_HAS_NULLPTR_T)
+# undef Q_COMPILER_NULLPTR
+# endif
# if defined(_HAS_DINKUM_CLIB) && !defined(_HAS_CONSTEXPR)
// The libcpp is missing constexpr keywords on important functions like std::numeric_limits<>::min()
// Disable constexpr support on QNX even if the compiler supports it
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 3006c75794..d462595804 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -205,7 +205,7 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
The Q_DECLARE_FLAGS() macro does not expose the flags to the meta-object
system, so they cannot be used by Qt Script or edited in Qt Designer.
- To make the flags available for these purposes, the Q_FLAGS() macro must
+ To make the flags available for these purposes, the Q_FLAG() macro must
be used:
\snippet code/src_corelib_global_qglobal.cpp meta-object flags
@@ -2991,7 +2991,7 @@ QString qt_error_string(int errorCode)
// Retrieve the system error message for the last-error code.
# ifndef Q_OS_WINRT
wchar_t *string = 0;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL,
errorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 5db2e94602..2912e68580 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -447,7 +447,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
if (!QLibraryInfoPrivate::configuration())
#endif
{
- const char *path = 0;
+ const char * volatile path = 0;
if (loc == PrefixPath) {
path =
#ifdef QT_BUILD_QMAKE
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/io.pri b/src/corelib/io/io.pri
index 78349fbc49..4c189bfe57 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -7,6 +7,7 @@ HEADERS += \
io/qdatastream_p.h \
io/qdataurl_p.h \
io/qdebug.h \
+ io/qdebug_p.h \
io/qdir.h \
io/qdir_p.h \
io/qdiriterator.h \
diff --git a/src/corelib/io/qdebug_p.h b/src/corelib/io/qdebug_p.h
new file mode 100644
index 0000000000..0525929169
--- /dev/null
+++ b/src/corelib/io/qdebug_p.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDEBUG_P_H
+#define QDEBUG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qdebug.h"
+#include "QtCore/qmetaobject.h"
+#include "QtCore/qflags.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QtDebugUtils {
+
+// inline helpers for formatting basic classes.
+
+template <class Point>
+static inline void formatQPoint(QDebug &debug, const Point &point)
+{
+ debug << point.x() << ',' << point.y();
+}
+
+template <class Size>
+static inline void formatQSize(QDebug &debug, const Size &size)
+{
+ debug << size.width() << ", " << size.height();
+}
+
+template <class Rect>
+static inline void formatQRect(QDebug &debug, const Rect &rect)
+{
+ debug << rect.x() << ',' << rect.y() << ' ' << rect.width() << 'x' << rect.height();
+}
+
+template <class Margins>
+static inline void formatQMargins(QDebug &debug, const Margins &margins)
+{
+ debug << margins.left() << ", " << margins.top() << ", " << margins.right()
+ << ", " << margins.bottom();
+}
+
+#ifndef QT_NO_QOBJECT
+template <class QEnum>
+static inline void formatQEnum(QDebug &debug, QEnum value)
+{
+ const QMetaObject *metaObject = qt_getEnumMetaObject(value);
+ const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(value)));
+ if (const char *key = me.valueToKey(value))
+ debug << key;
+ else
+ debug << int(value);
+}
+
+template <class QEnum>
+static inline void formatNonNullQEnum(QDebug &debug, const char *prefix, QEnum value)
+{
+ if (value) {
+ debug << prefix;
+ formatQEnum(debug, value);
+ }
+}
+
+template <class Enum>
+static inline void formatQFlags(QDebug &debug, const QFlags<Enum> &value)
+{
+ const QMetaObject *metaObject = qt_getEnumMetaObject(Enum());
+ const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(Enum())));
+ const QDebugStateSaver saver(debug);
+ debug.noquote();
+ debug << me.valueToKeys(value);
+}
+
+template <class Enum>
+static inline void formatNonNullQFlags(QDebug &debug, const char *prefix, const QFlags<Enum> &value)
+{
+ if (value) {
+ debug << prefix;
+ formatQFlags(debug, value);
+ }
+}
+
+#endif // !QT_NO_QOBJECT
+
+} // namespace QtDebugUtils
+
+QT_END_NAMESPACE
+
+#endif // QDEBUG_P_H
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..7a87a78c60 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -972,6 +972,7 @@ QByteArray QIODevice::readAll()
QByteArray result;
qint64 readBytes = 0;
+ const bool sequential = d->isSequential();
// flush internal read buffer
if (!(d->openMode & Text) && !d->buffer.isEmpty()) {
@@ -979,11 +980,12 @@ QByteArray QIODevice::readAll()
return QByteArray();
result = d->buffer.readAll();
readBytes = result.size();
- d->pos += readBytes;
+ if (!sequential)
+ d->pos += readBytes;
}
qint64 theSize;
- if (d->isSequential() || (theSize = size()) == 0) {
+ if (sequential || (theSize = size()) == 0) {
// Size is unknown, read incrementally.
qint64 readResult;
do {
@@ -1629,6 +1631,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 d5c861f9ad..80eb08b01b 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/qfunctions_winrt.cpp b/src/corelib/kernel/qfunctions_winrt.cpp
index 3be42d76e9..ea7f2ac671 100644
--- a/src/corelib/kernel/qfunctions_winrt.cpp
+++ b/src/corelib/kernel/qfunctions_winrt.cpp
@@ -30,9 +30,11 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifdef Q_OS_WINRT
#include "qfunctions_winrt.h"
+
+#ifdef Q_OS_WINRT
+
#include "qstring.h"
#include "qbytearray.h"
#include "qhash.h"
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/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 55f8fc9b2c..aa8d826ed9 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -1364,6 +1364,11 @@ namespace QtPrivate
enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(void*) };
};
+
+QT_WARNING_PUSH
+// In C++03 mode, clang consider local or unnamed type and throw a warning instead of ignoring them
+QT_WARNING_DISABLE_CLANG("-Wunnamed-type-template-args")
+QT_WARNING_DISABLE_CLANG("-Wlocal-type-template-args")
template<typename T> char qt_getEnumMetaObject(const T&);
template<typename T>
@@ -1375,6 +1380,7 @@ namespace QtPrivate
// qt_getEnumMetaObject(T) which returns 'char'
enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) };
};
+QT_WARNING_POP
template<typename T, typename Enable = void>
struct MetaObjectForType
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/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 8b940aa2dc..72f662dc1e 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -721,7 +721,7 @@ QDataStream &operator>>(QDataStream &s, QUuid &id)
Returns \c true if this is the null UUID
{00000000-0000-0000-0000-000000000000}; otherwise returns \c false.
*/
-bool QUuid::isNull() const
+bool QUuid::isNull() const Q_DECL_NOTHROW
{
return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 &&
data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 &&
@@ -770,7 +770,7 @@ bool QUuid::isNull() const
\sa version()
*/
-QUuid::Variant QUuid::variant() const
+QUuid::Variant QUuid::variant() const Q_DECL_NOTHROW
{
if (isNull())
return VarUnknown;
@@ -791,7 +791,7 @@ QUuid::Variant QUuid::variant() const
\sa variant()
*/
-QUuid::Version QUuid::version() const
+QUuid::Version QUuid::version() const Q_DECL_NOTHROW
{
// Check the 4 MSB of data3
Version ver = (Version)(data3>>12);
@@ -814,18 +814,19 @@ QUuid::Version QUuid::version() const
\sa variant()
*/
-#define ISLESS(f1, f2) if (f1!=f2) return (f1<f2);
-bool QUuid::operator<(const QUuid &other) const
+bool QUuid::operator<(const QUuid &other) const Q_DECL_NOTHROW
{
if (variant() != other.variant())
return variant() < other.variant();
+#define ISLESS(f1, f2) if (f1!=f2) return (f1<f2);
ISLESS(data1, other.data1);
ISLESS(data2, other.data2);
ISLESS(data3, other.data3);
for (int n = 0; n < 8; n++) {
ISLESS(data4[n], other.data4[n]);
}
+#undef ISLESS
return false;
}
@@ -840,22 +841,40 @@ bool QUuid::operator<(const QUuid &other) const
\sa variant()
*/
-#define ISMORE(f1, f2) if (f1!=f2) return (f1>f2);
-bool QUuid::operator>(const QUuid &other) const
+bool QUuid::operator>(const QUuid &other) const Q_DECL_NOTHROW
{
- if (variant() != other.variant())
- return variant() > other.variant();
-
- ISMORE(data1, other.data1);
- ISMORE(data2, other.data2);
- ISMORE(data3, other.data3);
- for (int n = 0; n < 8; n++) {
- ISMORE(data4[n], other.data4[n]);
- }
- return false;
+ return other < *this;
}
/*!
+ \fn bool operator<=(const QUuid &lhs, const QUuid &rhs)
+ \relates QUuid
+ \since 5.5
+
+ Returns \c true if \a lhs has the same \l{Variant field}
+ {variant field} as \a rhs and is lexicographically
+ \e{not after} \a rhs. If \a rhs has a
+ different variant field, the return value is determined by
+ comparing the two \l{QUuid::Variant} {variants}.
+
+ \sa variant()
+*/
+
+/*!
+ \fn bool operator>=(const QUuid &lhs, const QUuid &rhs)
+ \relates QUuid
+ \since 5.5
+
+ Returns \c true if \a lhs has the same \l{Variant field}
+ {variant field} as \a rhs and is lexicographically
+ \e{not before} \a rhs. If \a rhs has a
+ different variant field, the return value is determined by
+ comparing the two \l{QUuid::Variant} {variants}.
+
+ \sa variant()
+*/
+
+/*!
\fn QUuid QUuid::createUuid()
On any platform other than Windows, this function returns a new
diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h
index 13fd236a5e..f004cba77e 100644
--- a/src/corelib/plugin/quuid.h
+++ b/src/corelib/plugin/quuid.h
@@ -75,13 +75,13 @@ public:
};
#if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_QDOC)
- Q_DECL_CONSTEXPR QUuid() : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {}
+ Q_DECL_CONSTEXPR QUuid() Q_DECL_NOTHROW : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {}
Q_DECL_CONSTEXPR QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3,
- uchar b4, uchar b5, uchar b6, uchar b7, uchar b8)
+ uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) Q_DECL_NOTHROW
: data1(l), data2(w1), data3(w2), data4{b1, b2, b3, b4, b5, b6, b7, b8} {}
#else
- QUuid()
+ QUuid() Q_DECL_NOTHROW
{
data1 = 0;
data2 = 0;
@@ -89,7 +89,7 @@ public:
for(int i = 0; i < 8; i++)
data4[i] = 0;
}
- QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8)
+ QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) Q_DECL_NOTHROW
{
data1 = l;
data2 = w1;
@@ -112,9 +112,9 @@ public:
QByteArray toByteArray() const;
QByteArray toRfc4122() const;
static QUuid fromRfc4122(const QByteArray &);
- bool isNull() const;
+ bool isNull() const Q_DECL_NOTHROW;
- Q_DECL_RELAXED_CONSTEXPR bool operator==(const QUuid &orig) const
+ Q_DECL_RELAXED_CONSTEXPR bool operator==(const QUuid &orig) const Q_DECL_NOTHROW
{
if (data1 != orig.data1 || data2 != orig.data2 ||
data3 != orig.data3)
@@ -127,24 +127,24 @@ public:
return true;
}
- Q_DECL_RELAXED_CONSTEXPR bool operator!=(const QUuid &orig) const
+ Q_DECL_RELAXED_CONSTEXPR bool operator!=(const QUuid &orig) const Q_DECL_NOTHROW
{
return !(*this == orig);
}
- bool operator<(const QUuid &other) const;
- bool operator>(const QUuid &other) const;
+ bool operator<(const QUuid &other) const Q_DECL_NOTHROW;
+ bool operator>(const QUuid &other) const Q_DECL_NOTHROW;
#if defined(Q_OS_WIN)
// On Windows we have a type GUID that is used by the platform API, so we
// provide convenience operators to cast from and to this type.
#if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_QDOC)
- Q_DECL_CONSTEXPR QUuid(const GUID &guid)
+ Q_DECL_CONSTEXPR QUuid(const GUID &guid) Q_DECL_NOTHROW
: data1(guid.Data1), data2(guid.Data2), data3(guid.Data3),
data4{guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]} {}
#else
- QUuid(const GUID &guid)
+ QUuid(const GUID &guid) Q_DECL_NOTHROW
{
data1 = guid.Data1;
data2 = guid.Data2;
@@ -154,24 +154,24 @@ public:
}
#endif
- Q_DECL_RELAXED_CONSTEXPR QUuid &operator=(const GUID &guid)
+ Q_DECL_RELAXED_CONSTEXPR QUuid &operator=(const GUID &guid) Q_DECL_NOTHROW
{
*this = QUuid(guid);
return *this;
}
- Q_DECL_RELAXED_CONSTEXPR operator GUID() const
+ Q_DECL_RELAXED_CONSTEXPR operator GUID() const Q_DECL_NOTHROW
{
GUID guid = { data1, data2, data3, { data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7] } };
return guid;
}
- Q_DECL_RELAXED_CONSTEXPR bool operator==(const GUID &guid) const
+ Q_DECL_RELAXED_CONSTEXPR bool operator==(const GUID &guid) const Q_DECL_NOTHROW
{
return *this == QUuid(guid);
}
- Q_DECL_RELAXED_CONSTEXPR bool operator!=(const GUID &guid) const
+ Q_DECL_RELAXED_CONSTEXPR bool operator!=(const GUID &guid) const Q_DECL_NOTHROW
{
return !(*this == guid);
}
@@ -192,8 +192,8 @@ public:
#endif
- QUuid::Variant variant() const;
- QUuid::Version version() const;
+ QUuid::Variant variant() const Q_DECL_NOTHROW;
+ QUuid::Version version() const Q_DECL_NOTHROW;
uint data1;
ushort data2;
@@ -214,6 +214,11 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &);
Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0) Q_DECL_NOTHROW;
+inline bool operator<=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW
+{ return !(rhs < lhs); }
+inline bool operator>=(const QUuid &lhs, const QUuid &rhs) Q_DECL_NOTHROW
+{ return !(lhs < rhs); }
+
QT_END_NAMESPACE
#endif // QUUID_H
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;
diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp
index a9413d6b5c..92c977a73b 100644
--- a/src/corelib/tools/qmargins.cpp
+++ b/src/corelib/tools/qmargins.cpp
@@ -33,7 +33,8 @@
#include "qmargins.h"
#include "qdatastream.h"
-#include "qdebug.h"
+
+#include <private/qdebug_p.h>
QT_BEGIN_NAMESPACE
@@ -431,10 +432,13 @@ QDataStream &operator>>(QDataStream &s, QMargins &m)
#endif // QT_NO_DATASTREAM
#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QMargins &m) {
+QDebug operator<<(QDebug dbg, const QMargins &m)
+{
QDebugStateSaver saver(dbg);
- dbg.nospace() << "QMargins(" << m.left() << ", "
- << m.top() << ", " << m.right() << ", " << m.bottom() << ')';
+ dbg.nospace();
+ dbg << "QMargins" << '(';
+ QtDebugUtils::formatQMargins(dbg, m);
+ dbg << ')';
return dbg;
}
#endif
@@ -764,10 +768,13 @@ QDataStream &operator>>(QDataStream &s, QMarginsF &m)
#endif // QT_NO_DATASTREAM
#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QMarginsF &m) {
+QDebug operator<<(QDebug dbg, const QMarginsF &m)
+{
QDebugStateSaver saver(dbg);
- dbg.nospace() << "QMarginsF(" << m.left() << ", "
- << m.top() << ", " << m.right() << ", " << m.bottom() << ')';
+ dbg.nospace();
+ dbg << "QMarginsF" << '(';
+ QtDebugUtils::formatQMargins(dbg, m);
+ dbg << ')';
return dbg;
}
#endif
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index ebce6c9422..dc2a2d9739 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -33,7 +33,8 @@
#include "qpoint.h"
#include "qdatastream.h"
-#include "qdebug.h"
+
+#include <private/qdebug_p.h>
QT_BEGIN_NAMESPACE
@@ -447,14 +448,20 @@ QDataStream &operator>>(QDataStream &s, QPoint &p)
QDebug operator<<(QDebug dbg, const QPoint &p)
{
QDebugStateSaver saver(dbg);
- dbg.nospace() << "QPoint(" << p.x() << ',' << p.y() << ')';
+ dbg.nospace();
+ dbg << "QPoint" << '(';
+ QtDebugUtils::formatQPoint(dbg, p);
+ dbg << ')';
return dbg;
}
QDebug operator<<(QDebug dbg, const QPointF &p)
{
QDebugStateSaver saver(dbg);
- dbg.nospace() << "QPointF(" << p.x() << ',' << p.y() << ')';
+ dbg.nospace();
+ dbg << "QPointF" << '(';
+ QtDebugUtils::formatQPoint(dbg, p);
+ dbg << ')';
return dbg;
}
#endif
diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp
index 35cf2d5e5b..b2174745e4 100644
--- a/src/corelib/tools/qrect.cpp
+++ b/src/corelib/tools/qrect.cpp
@@ -33,9 +33,10 @@
#include "qrect.h"
#include "qdatastream.h"
-#include "qdebug.h"
#include "qmath.h"
+#include <private/qdebug_p.h>
+
QT_BEGIN_NAMESPACE
/*!
@@ -1279,8 +1280,10 @@ QDataStream &operator>>(QDataStream &s, QRect &r)
QDebug operator<<(QDebug dbg, const QRect &r)
{
QDebugStateSaver saver(dbg);
- dbg.nospace() << "QRect(" << r.x() << ',' << r.y() << ' '
- << r.width() << 'x' << r.height() << ')';
+ dbg.nospace();
+ dbg << "QRect" << '(';
+ QtDebugUtils::formatQRect(dbg, r);
+ dbg << ')';
return dbg;
}
#endif
@@ -2488,8 +2491,10 @@ QDataStream &operator>>(QDataStream &s, QRectF &r)
QDebug operator<<(QDebug dbg, const QRectF &r)
{
QDebugStateSaver saver(dbg);
- dbg.nospace() << "QRectF(" << r.x() << ',' << r.y() << ' '
- << r.width() << 'x' << r.height() << ')';
+ dbg.nospace();
+ dbg << "QRectF" << '(';
+ QtDebugUtils::formatQRect(dbg, r);
+ dbg << ')';
return dbg;
}
#endif
diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp
index d91dd0d130..19227432f2 100644
--- a/src/corelib/tools/qsize.cpp
+++ b/src/corelib/tools/qsize.cpp
@@ -33,7 +33,8 @@
#include "qsize.h"
#include "qdatastream.h"
-#include "qdebug.h"
+
+#include <private/qdebug_p.h>
QT_BEGIN_NAMESPACE
@@ -440,7 +441,10 @@ QDataStream &operator>>(QDataStream &s, QSize &sz)
QDebug operator<<(QDebug dbg, const QSize &s)
{
QDebugStateSaver saver(dbg);
- dbg.nospace() << "QSize(" << s.width() << ", " << s.height() << ')';
+ dbg.nospace();
+ dbg << "QSize(";
+ QtDebugUtils::formatQSize(dbg, s);
+ dbg << ')';
return dbg;
}
#endif
@@ -867,7 +871,10 @@ QDataStream &operator>>(QDataStream &s, QSizeF &sz)
QDebug operator<<(QDebug dbg, const QSizeF &s)
{
QDebugStateSaver saver(dbg);
- dbg.nospace() << "QSizeF(" << s.width() << ", " << s.height() << ')';
+ dbg.nospace();
+ dbg << "QSizeF(";
+ QtDebugUtils::formatQSize(dbg, s);
+ dbg << ')';
return dbg;
}
#endif
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 7a5f9b3614..56dab68f33 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -8507,12 +8507,6 @@ QDataStream &operator<<(QDataStream &out, const QString &str)
QDataStream &operator>>(QDataStream &in, QString &str)
{
-#ifdef QT_QSTRING_UCS_4
-#if defined(Q_CC_GNU)
-#warning "operator>> not working properly"
-#endif
-#endif
-
if (in.version() == 1) {
QByteArray l;
in >> l;
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 2933e40549..bb15d66439 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -92,6 +92,15 @@ public:
return *this;
}
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+ QVarLengthArray<T, Prealloc> &operator=(std::initializer_list<T> list)
+ {
+ resize(list.size());
+ std::copy(list.begin(), list.end(), this->begin());
+ return *this;
+ }
+#endif
+
inline void removeLast() {
Q_ASSERT(s > 0);
realloc(s - 1, a);
diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc
index 1f3a73073f..2b7f9c5241 100644
--- a/src/corelib/tools/qvarlengtharray.qdoc
+++ b/src/corelib/tools/qvarlengtharray.qdoc
@@ -362,6 +362,15 @@
Assigns \a other to this array and returns a reference to this array.
*/
+/*! \fn QVarLengthArray<T, Prealloc> &QVarLengthArray::operator=(std::initializer_list<T> list)
+ \since 5.5
+
+ Assigns the values of \a list to this array, and returns a reference to this array.
+
+ This constructor is only enabled if the compiler supports C++11 initializer
+ lists.
+*/
+
/*! \fn QVarLengthArray::QVarLengthArray(const QVarLengthArray<T, Prealloc> &other)
Constructs a copy of \a other.
*/