From 227bb20dedc4156c1a4653d55252b0790fd1ae75 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 27 Feb 2015 19:52:22 +0100 Subject: Call MoveFile() anyway if the delete failed because it did not exist Since the new filename might not yet exist and DeleteFile() will fail if the new file does not exist then MoveFile() should still be called. Change-Id: Id4576ade079ad8593f824b7100bb0d94aec1fa0a Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qfsfileengine_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index ea2b1bbc63..a7ccfb2dea 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; } -- cgit v1.2.3 From ed0c0070f9b05c647019270dfc42073d071c830a Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Mon, 8 Dec 2014 15:29:19 +0100 Subject: Introduce qt_subtract_from_timeout to reduce code duplication. The same qt_timeout_value function was copied 5 times in qtbase's code, so provide a common implementation in QIoDevice that can be used by everyone. This commit also corrects the remaining time calculation in QProcess::waitForBytesWritten and QProcess::waitForFinished by using this new function. For QProcess::waitForFinished, if the process started within almost exactly the timeout time passed to waitForFinished, msecs - stopWatch.elapsed() would be -1, which is a special value. Change-Id: I7b76ee6bae695eafdd02e3db03e2ff1e23a7f40c Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qiodevice.cpp | 17 +++++++++++++++++ src/corelib/io/qiodevice_p.h | 2 ++ src/corelib/io/qprocess.cpp | 6 ++---- src/corelib/io/qprocess_unix.cpp | 19 +++---------------- src/corelib/io/qwinoverlappedionotifier.cpp | 9 ++++----- 5 files changed, 28 insertions(+), 25 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index f1c42c9bb5..35911934df 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1667,6 +1667,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 d764cb0fbb..ddd222e9a8 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 94912ad616..baba9a0f9e 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1793,8 +1793,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); @@ -1830,8 +1829,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 cc154cfbc5..1c1c058c7a 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -1019,19 +1019,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); @@ -1106,7 +1093,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 @@ -1187,7 +1174,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 @@ -1262,7 +1249,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/qwinoverlappedionotifier.cpp b/src/corelib/io/qwinoverlappedionotifier.cpp index de0e205d26..7a005430ea 100644 --- a/src/corelib/io/qwinoverlappedionotifier.cpp +++ b/src/corelib/io/qwinoverlappedionotifier.cpp @@ -41,6 +41,7 @@ #include #include #include +#include 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; } } -- cgit v1.2.3 From 416438c2f35dc774e4c52a705c5a7098a69647fc Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 9 Mar 2015 17:04:20 +0100 Subject: QMimeDatabase: Fix magic rules with \t \t was not interpreted as a tab character. Task-number: QTBUG-44884 Change-Id: I3c733e227fba7e5fd5153df0ae4d0431903bb104 Reviewed-by: Daniel Teske Reviewed-by: David Faure --- src/corelib/mimetypes/qmimemagicrule.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index e83a38d82f..e81a0d62a0 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -215,6 +215,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; } -- cgit v1.2.3 From afd2246de26a81239b1f8d02a825685d9fcab94b Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 11 Mar 2015 08:35:17 +0100 Subject: Windows Embedded: GetTickCount64 won't be available so just remove it Since GetTickCount64 still relies on the usage of kernel32, then it will not find the function anyway as the library does not exist for Windows Embedded. Therefore it is best to remove it altogether to save time trying to locate something we know is not there. Change-Id: Id879382fdd0692fb9443231a405c0e28d9bcc328 Reviewed-by: Thiago Macieira --- src/corelib/tools/qelapsedtimer_win.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp index 55c93d6361..44d8cbc593 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; -- cgit v1.2.3 From a31fd4fb96574df44947adb7aa2ff1cd9941f605 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 11 Mar 2015 14:30:32 +0100 Subject: Clarify InputMethodHint documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The description of ImhHiddenText made it sound like it would change the echoMode of the input field. Task-number: QTBUG-38080 Change-Id: I379015b95e43b6eff181d51444c7e069728504ad Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Topi Reiniö Reviewed-by: Christian Stromme --- src/corelib/global/qnamespace.qdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 24de2541b8..514d630fbd 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2411,8 +2411,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 -- cgit v1.2.3 From 8f061836993059996d79d7fbed2bb68b16028ad7 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 9 Mar 2015 10:29:55 +0100 Subject: Core: fix crash in QCollator if ucol_open() failed If ucol_open() failed, call back to QString::compare() implementation. Task-number: QTBUG-44796 Change-Id: I03446e5227e1dedac6c5f824ac6d74a494fc0ace Reviewed-by: Gergely Nagy Reviewed-by: Lars Knoll --- src/corelib/tools/qcollator_icu.cpp | 43 ++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp index 4442442a65..4c13335521 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 -- cgit v1.2.3 From 3cadc688f8fea7e39d6b305bdd461dc77b121219 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Wed, 11 Mar 2015 16:38:11 +0100 Subject: Doc: Fix qmath documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qmath.qdoc:206: warning: No such parameter 'radians' in qNextPowerOfTwo() qmath.qdoc:206: warning: No such parameter 'value' in qRadiansToDegrees() Change-Id: Ia1556a98801ab694716235cc50edcc9e7d2f33f0 Reviewed-by: Topi Reiniö --- src/corelib/kernel/qmath.qdoc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmath.qdoc b/src/corelib/kernel/qmath.qdoc index 430a420eeb..5b3d44ae0b 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) -- cgit v1.2.3 From 619a0f14dc35998591720684b1ed794ea81f5331 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 24 Mar 2015 10:44:08 +0100 Subject: Re-add documentation for QStandardPaths::GenericDataLocation. The text was accidentally removed in 1afe110b8fe6da51ec23736fa3a105013255f904. Fixes qdoc warning: qtbase/src/corelib/io/qstandardpaths.cpp:60: warning: Undocumented enum item GenericDataLocation in QStandardPaths::StandardLocation Change-Id: I7f236c01d85ebf76b67ab7af7e61b8cbedee4c36 Reviewed-by: David Faure --- src/corelib/io/qstandardpaths.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 9d047123a1..ba1de461f8 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. -- cgit v1.2.3 From 06ecfb6fdedbf7d555bdf90bc3092be10fd763a9 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Thu, 19 Mar 2015 16:38:52 +0100 Subject: Doc: Added the missing description for WindowShadeButtonHint Task-number: QTBUG-44017 Change-Id: I024faa6214a041403f23fd91f0c8c38eabeef31e Reviewed-by: Christian Stromme --- src/corelib/global/qnamespace.qdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 514d630fbd..f7992b436c 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2113,7 +2113,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 -- cgit v1.2.3 From 7c2360b762817743484ddc5bc9ba3f48a7b68d84 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 30 Mar 2015 11:10:27 +0200 Subject: Split out some inline qdebug formatting helpers to qdebug_p.h. Extract helpers to be able to format classes without type names and use those for formatting QEvents to reduce clutter. For example: QWidgetWindow/"MainWindowClassWindow" QMouseEvent(QEvent::Type(MouseMove), buttons=QFlags(LeftButton), localPos=QPointF(50,116), screenPos=QPointF(948,652)) QWidget/"qt_scrollarea_viewport" QMouseEvent(QEvent::Type(MouseMove), buttons=QFlags(LeftButton), localPos=QPointF(45,32), screenPos=QPointF(948,652)) becomes QWidgetWindow/"MainWindowClassWindow" QMouseEvent(MouseMove, LeftButton, localPos=50,116, screenPos=948,652) QWidget/"qt_scrollarea_viewport" QMouseEvent(MouseMove, LeftButton, localPos=45,32, screenPos=948,652) Change-Id: Ie5441d922962a05caed6b7079a74ea8a2b8a64fb Reviewed-by: Kai Koehne --- src/corelib/io/io.pri | 1 + src/corelib/io/qdebug_p.h | 129 +++++++++++++++++++++++++++++++++++++++++ src/corelib/tools/qmargins.cpp | 21 ++++--- src/corelib/tools/qpoint.cpp | 13 ++++- src/corelib/tools/qrect.cpp | 15 +++-- src/corelib/tools/qsize.cpp | 13 ++++- 6 files changed, 174 insertions(+), 18 deletions(-) create mode 100644 src/corelib/io/qdebug_p.h (limited to 'src/corelib') 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 +static inline void formatQPoint(QDebug &debug, const Point &point) +{ + debug << point.x() << ',' << point.y(); +} + +template +static inline void formatQSize(QDebug &debug, const Size &size) +{ + debug << size.width() << ", " << size.height(); +} + +template +static inline void formatQRect(QDebug &debug, const Rect &rect) +{ + debug << rect.x() << ',' << rect.y() << ' ' << rect.width() << 'x' << rect.height(); +} + +template +static inline void formatQMargins(QDebug &debug, const Margins &margins) +{ + debug << margins.left() << ", " << margins.top() << ", " << margins.right() + << ", " << margins.bottom(); +} + +#ifndef QT_NO_QOBJECT +template +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 +static inline void formatNonNullQEnum(QDebug &debug, const char *prefix, QEnum value) +{ + if (value) { + debug << prefix; + formatQEnum(debug, value); + } +} + +template +static inline void formatQFlags(QDebug &debug, const QFlags &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 +static inline void formatNonNullQFlags(QDebug &debug, const char *prefix, const QFlags &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/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 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 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 + 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 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 -- cgit v1.2.3 From f53621af053f313eff7fa7b204b5cceff675cb64 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 31 Mar 2015 15:49:08 +0200 Subject: Update documentation snippets related to QDebug. Use QDebugStateSaver to store the formatting state and fix the return statement to return the unmodified stream. Change-Id: I476d13c5487a89f263dcc11334fc67c85d9433f5 Reviewed-by: Kai Koehne --- src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp | 7 ++++--- src/corelib/doc/snippets/qloggingcategory/main.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/corelib') 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 usbEntries() { -- cgit v1.2.3 From cbf28577ef49b6f5b5e45ae2e74143969cbd9327 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 30 Mar 2015 11:59:41 +0200 Subject: Force length of prefix path to be calculated at runtime Prevent compilers from calculating strlen at compile time by using a volatile pointer. This corrupted paths if the installation path is patched for the binary SDK installer. Task-number: QTBUG-45307 Change-Id: I624b0409e8b27299475a88eb1cbf03ffef9589c6 Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qlibraryinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') 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 -- cgit v1.2.3 From 4a6ba203b517cfe763d7661863dce78fbf8778f7 Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Wed, 1 Apr 2015 06:31:10 +0300 Subject: winrt: Fix non-PCH build This cpp file did not include its header. Change-Id: Ib68f4a1470c1dc213add5e8825ef972c07ee57df Reviewed-by: Thiago Macieira --- src/corelib/kernel/qfunctions_winrt.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') 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" -- cgit v1.2.3 From 8cec5e9a34812eea3d4e2182f0feed91e85a1eb3 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 14 Mar 2015 12:17:05 +0100 Subject: Update a few doc regarding Q_FLAG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic26b3d64c9a5d5109bd8a0b359f063529d0181fc Reviewed-by: Topi Reiniö --- src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp | 2 +- src/corelib/global/qglobal.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') 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/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index ac2f72d573..d69b1d346f 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 -- cgit v1.2.3 From 5322200076c95ca3db32481e1f035d7785ce88ae Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 31 Mar 2015 15:17:57 +0200 Subject: Silence clang warnings in C++03 mode C++03 forbid the use of local or unnamed type as template parameter. But in C++11 that is allowed, and clang accept them even in C++03 mode, but with a warning. The Warning happen for example with this code: enum { Foo = 3 }; int x = 3 << Foo; Then the compiler issues warnings: metatype.h:1379:31: warning: template argument uses local type [-Wlocal-type-template-args] enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) }; ^~~~~~~~~~~~~~~~~~~~ qdebug.h:269:42: note: in instantiation of template class 'QtPrivate::IsQEnumHelper<(anonymous enum)>' requested here typename QtPrivate::QEnableIf::Value, QDebug>::Type operator<<(QDebug dbg, T value) Normaly the compiler should not even try to instantiate the operator<< with such types in C++03 mode. Change-Id: I48c7d5d1836fd87986835fe15c7e0b1beb73c728 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib') 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(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 char qt_getEnumMetaObject(const T&); template @@ -1375,6 +1380,7 @@ namespace QtPrivate // qt_getEnumMetaObject(T) which returns 'char' enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) }; }; +QT_WARNING_POP template struct MetaObjectForType -- cgit v1.2.3 From 06671a3cbda8b74b350eb14c0fbc23c0a63a7c64 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 1 Apr 2015 16:04:14 +0200 Subject: Windows: Use FORMAT_MESSAGE_IGNORE_INSERTS for qt_error_string(). This will cause FormatMessage() to return messages with placeholders as well even though we do not pass the message parameters (for example: "The operating system cannot run %1." for ERROR_INVALID_ORDINAL). Task-number: QTBUG-43164 Change-Id: Ib95c1c0fabb543bbe4e8ab2bd8f244f73dff5fa4 Reviewed-by: Joerg Bornemann --- src/corelib/global/qglobal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index d69b1d346f..eb8dd73727 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2988,7 +2988,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), -- cgit v1.2.3 From 650de56c7fa2fd91b4c76e309fdd7b7eacd57ff5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 3 Apr 2015 21:08:13 +0200 Subject: QUuid: implement op> in terms of op< More maintainable, and less code. Change-Id: Ia99e5deefe4c510fe870076a03ec243ba631a7a3 Reviewed-by: Thiago Macieira --- src/corelib/plugin/quuid.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 8b940aa2dc..193657ce61 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -840,19 +840,9 @@ 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 { - 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; } /*! -- cgit v1.2.3 From 2b3d3cabe180b5ee5e027afc266b78090974a0e1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 3 Apr 2015 21:10:45 +0200 Subject: QUuid: properly scope macros Limit scope and undef after last use. Change-Id: I94f0adb2b9fc3ec65dd7a3b5e6f03685bc226d3d Reviewed-by: Thiago Macieira --- src/corelib/plugin/quuid.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 193657ce61..dc744e5ca5 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -814,18 +814,19 @@ QUuid::Version QUuid::version() const \sa variant() */ -#define ISLESS(f1, f2) if (f1!=f2) return (f1 Date: Fri, 3 Apr 2015 21:46:36 +0200 Subject: QUuid: add some noexcept Change-Id: I43647e558a761ff6e7a275e30382919ba038f467 Reviewed-by: Thiago Macieira --- src/corelib/plugin/quuid.cpp | 10 +++++----- src/corelib/plugin/quuid.h | 34 +++++++++++++++++----------------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index dc744e5ca5..f23ec5d75c 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,7 +814,7 @@ QUuid::Version QUuid::version() const \sa variant() */ -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(); @@ -841,7 +841,7 @@ bool QUuid::operator<(const QUuid &other) const \sa variant() */ -bool QUuid::operator>(const QUuid &other) const +bool QUuid::operator>(const QUuid &other) const Q_DECL_NOTHROW { return other < *this; } diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 13fd236a5e..38f3bdfb8b 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; -- cgit v1.2.3 From 1b109967c56c67d45a0b142fe9ba9adbce0a0d7b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 3 Apr 2015 21:47:52 +0200 Subject: QUuid: add missing relational operators QUuid has ==, !=, <, and >. Add <= and =>, too. Change-Id: I11a0b8028be766e2d48dc7664d935df4d327b3d3 Reviewed-by: Thiago Macieira --- src/corelib/plugin/quuid.cpp | 28 ++++++++++++++++++++++++++++ src/corelib/plugin/quuid.h | 5 +++++ 2 files changed, 33 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index f23ec5d75c..72f662dc1e 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -846,6 +846,34 @@ bool QUuid::operator>(const QUuid &other) const Q_DECL_NOTHROW 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() diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 38f3bdfb8b..f004cba77e 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -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 -- cgit v1.2.3 From f40cf77b0fa1cd5353ca866a7a5799da9f303081 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 28 Mar 2015 16:47:41 +0200 Subject: QIODevice: do not change the 'pos' member for sequential devices Concept of 'current position' exists only for random-access devices. As documented, for sequential devices QIODevice::pos() must always return 0. Prevent a modification of the internal 'pos' member in QIODevice::readAll() method to follow this rule. Change-Id: Ida2ee6a629ccfc3068d62f95ab1064ada13fdda5 Reviewed-by: Thiago Macieira --- src/corelib/io/qiodevice.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index f2655dab3c..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 { -- cgit v1.2.3 From ddb0628181ba6f2ebeedf7e8f4186861ab63b628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Sat, 28 Mar 2015 21:46:23 +0000 Subject: Fix BlackBerry build. BlackBerry SDK uses gcc 4.6 which supports nullptr, but by default it uses the dinkum C++ library, which doesn't support nullptr_t. Change-Id: Ifa95029a9bfa4dc2fc064db5d7a67012e95ac0e2 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib') 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 -- cgit v1.2.3 From 1db3de6a1e09216aaf92b60fc167a7326c6a62d8 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 19 Mar 2015 17:13:22 +0100 Subject: QVLA: Add operator= for initializer lists Add a dedicated operator=(std::initializer_list) that first resizes the QCLA, and then replaces the elements one by one. This should be usually faster than creating a temporary QCLA and then copying it, except for the case where the new array does not fit into the allocated stack - but this is IMO nothing to optimize for. Task-number: QTBUG-45041 Change-Id: I147d6d01186b1ca3c635b2c8365d8f6e638ce6fe GPush-Base: 08de3113051e1289f0de0651ec5647c9ee6feb27 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/tools/qvarlengtharray.h | 9 +++++++++ src/corelib/tools/qvarlengtharray.qdoc | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 95cd0447d8..90b54b7297 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -91,6 +91,15 @@ public: return *this; } +#ifdef Q_COMPILER_INITIALIZER_LISTS + QVarLengthArray &operator=(std::initializer_list 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 d1b87f381e..a2d4c55f7a 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 &QVarLengthArray::operator=(std::initializer_list 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 &other) Constructs a copy of \a other. */ -- cgit v1.2.3 From 9eb0b09abce28b11e4915fc9c3b3e996eb19cef2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 5 Apr 2015 12:39:14 -0700 Subject: Removed unused code on QT_STRING_UCS4 macro This isn't defined or used anywhere else. Change-Id: I9a75ad8521ae4e5cbbe5ffff13d2356883b82dbc Reviewed-by: Konstantin Ritt --- src/corelib/tools/qstring.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index e74a8eebee..a0067178ac 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -8379,12 +8379,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; -- cgit v1.2.3