From 5e76cb16924a42cb020786f45cc3494dd5836c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 5 Apr 2017 12:39:15 +0200 Subject: Fix menu position when highdpi scaling Certain display and scale factor configurations would cause menus to pop up in incorrect locations or not be shown at all. This was due to QDesktopWidget::screenNumber() having a toNativePixels(QRect, QWindow) call which requires that QWindow::screen() returns the correct screen. Break the circular dependency by converting coordinates the other way for the intersection test: transform screen geometry to device independent coordinates. Task-number: QTBUG-58329 Change-Id: I5621de89a9a2b8df44bdae528baf011fc111eba3 Reviewed-by: Paolo Angelelli Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/widgets/kernel/qdesktopwidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index eee818b685..1e6fbfd239 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -269,12 +269,13 @@ int QDesktopWidget::screenNumber(const QWidget *w) const QRect frame = w->frameGeometry(); if (!w->isWindow()) frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); - const QRect nativeFrame = QHighDpi::toNativePixels(frame, winHandle); QScreen *widgetScreen = Q_NULLPTR; int largestArea = 0; foreach (QScreen *screen, screens) { - const QRect intersected = screen->handle()->geometry().intersected(nativeFrame); + const QRect deviceIndependentScreenGeometry = + QHighDpi::fromNativePixels(screen->handle()->geometry(), screen); + const QRect intersected = deviceIndependentScreenGeometry.intersected(frame); int area = intersected.width() * intersected.height(); if (largestArea < area) { widgetScreen = screen; -- cgit v1.2.3 From 872bff5b24ded4a5dfecad96df907f32830a980a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 31 Oct 2016 16:07:53 -0700 Subject: Enable a given SIMD feature if the compiler has enabled it Change-Id: I09100678ff4443e6be06fffd1482c08125adc0a4 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qsimd_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index f6164e2297..d5d887598e 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -169,7 +169,7 @@ || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && (__GNUC__-0) * 100 + (__GNUC_MINOR__-0) >= 409)) \ && !defined(QT_BOOTSTRAPPED) # define QT_COMPILER_SUPPORTS_SIMD_ALWAYS -# define QT_COMPILER_SUPPORTS_HERE(x) QT_COMPILER_SUPPORTS(x) +# define QT_COMPILER_SUPPORTS_HERE(x) (__ ## x ## __) || QT_COMPILER_SUPPORTS(x) # if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) /* GCC requires attributes for a function */ # define QT_FUNCTION_TARGET(x) __attribute__((__target__(QT_FUNCTION_TARGET_STRING_ ## x))) -- cgit v1.2.3 From 4a6cb89f2944b5d8ee3e50fd3a2085eba9189680 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Wed, 5 Apr 2017 18:35:52 +0200 Subject: Fix reusing FTP connection after abort The QNetworkAccessCache was keeping the connection alive and it was trying to reuse it for subsequent calls to download files from the same server. After closing the connection, it is not usable anymore and a new one should be created. Task-number: QTBUG-40368 Change-Id: I1a0d08956a94eb36f39d14112cdcab6c1e2add82 Reviewed-by: Edward Welbourne --- src/network/access/qnetworkaccessftpbackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index d242bdba82..6d1ee645fe 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -114,7 +114,7 @@ QNetworkAccessFtpBackend::~QNetworkAccessFtpBackend() //if backend destroyed while in use, then abort (this is the code path from QNetworkReply::abort) if (ftp && state != Disconnecting) ftp->abort(); - disconnectFromFtp(); + disconnectFromFtp(RemoveCachedConnection); } void QNetworkAccessFtpBackend::open() -- cgit v1.2.3 From f497dea73080c2d8910bd5b6d74c9a6226db0c92 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Mar 2017 13:19:15 +0200 Subject: Doc: Clarify the porting notes from QRegExp to QRegularExpression Add a small table to illustrate the results exactMatch() and split out the part on partial matching to a separate section since it is less common. Change-Id: Ifbd5c3cbd1d8c0ee9e8b2d58ed13f40776b03762 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Leena Miettinen --- src/corelib/tools/qregularexpression.cpp | 35 ++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index f1fac093b0..88b696f53a 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -445,19 +445,25 @@ QT_BEGIN_NAMESPACE Other differences are outlined below. - \section2 Exact matching + \section2 Porting from QRegExp::exactMatch() QRegExp::exactMatch() in Qt 4 served two purposes: it exactly matched a regular expression against a subject string, and it implemented partial - matching. In fact, if an exact match was not found, one could still find - out how much of the subject string was matched by the regular expression - by calling QRegExp::matchedLength(). If the returned length was equal - to the subject string's length, then one could desume that a partial match - was found. + matching. - QRegularExpression supports partial matching explicitly by means of the - appropriate MatchType. If instead you simply want to be sure that the - subject string matches the regular expression exactly, you can wrap the + \section3 Porting from QRegExp's Exact Matching + + Exact matching indicates whether the regular expression matches the entire + subject string. For example, the classes yield on the subject string \c{"abc123"}: + + \table + \header \li \li QRegExp::exactMatch() \li QRegularExpressionMatch::hasMatch() + \row \li \c{"\\d+"} \li \b false \li \b true + \row \li \c{"[a-z]+\\d+"} \li \b true \li \b true + \endtable + + Exact matching is not reflected in QRegularExpression. If you want to be + sure that the subject string matches the regular expression exactly, you can wrap the pattern between a couple of anchoring expressions. Simply putting the pattern between the \c{^} and the \c{$} anchors is enough in most cases: @@ -479,6 +485,17 @@ QT_BEGIN_NAMESPACE Note the usage of the non-capturing group in order to preserve the meaning of the branch operator inside the pattern. + \section3 Porting from QRegExp's Partial Matching + + When using QRegExp::exactMatch(), if an exact match was not found, one + could still find out how much of the subject string was matched by the + regular expression by calling QRegExp::matchedLength(). If the returned length + was equal to the subject string's length, then one could conclude that a partial + match was found. + + QRegularExpression supports partial matching explicitly by means of the + appropriate MatchType. + \section2 Global matching Due to limitations of the QRegExp API it was impossible to implement global -- cgit v1.2.3 From 795a54ff9688697c033fc5d522f4c50c707d5924 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 Mar 2017 13:54:56 +0100 Subject: QDataStream: add operator<< and >> for std::nullptr_t std::nullptr_t is nullary: it accepts only one value, nullptr. So we don't need to read or write anything. This commit simply adds the two operators that allow generic code to operate on std::nullptr_t if required. This commit also adds the actual use to QMetaType::load/save, even though there's no change in behavior. [ChangeLog][QtCore][QDataStream] Added operator<< and operator>> overloads that take std::nullptr_t, to facilitate generic code. Change-Id: Iae839f6a131a4f0784bffffd14aa37e7f62d2740 Reviewed-by: Marc Mutz Reviewed-by: Lars Knoll --- src/corelib/io/qdatastream.cpp | 20 ++++++++++++++++++++ src/corelib/io/qdatastream.h | 2 ++ src/corelib/kernel/qmetatype.cpp | 2 ++ 3 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 2369fe4726..9a42fb4a37 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -770,6 +770,17 @@ int QDataStream::readBlock(char *data, int len) return readResult; } +/*! + \fn QDataStream &QDataStream::operator>>(std::nullptr &ptr) + \since 5.9 + \overload + + Simulates reading a \c{std::nullptr_t} from the stream into \a ptr and + returns a reference to the stream. This function does not actually read + anything from the stream, as \c{std::nullptr_t} values are stored as 0 + bytes. +*/ + /*! \fn QDataStream &QDataStream::operator>>(quint8 &i) \overload @@ -1084,6 +1095,15 @@ int QDataStream::readRawData(char *s, int len) QDataStream write functions *****************************************************************************/ +/*! + \fn QDataStream &QDataStream::operator<<(std::nullptr ptr) + \since 5.9 + \overload + + Simulates writing a \c{std::nullptr_t}, \a ptr, to the stream and returns a + reference to the stream. This function does not actually write anything to + the stream, as \c{std::nullptr_t} values are stored as 0 bytes. +*/ /*! \fn QDataStream &QDataStream::operator<<(quint8 i) diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index db1bbfbd63..575607e147 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -152,6 +152,7 @@ public: QDataStream &operator>>(quint32 &i); QDataStream &operator>>(qint64 &i); QDataStream &operator>>(quint64 &i); + QDataStream &operator>>(std::nullptr_t &ptr) { ptr = nullptr; return *this; } QDataStream &operator>>(bool &i); QDataStream &operator>>(qfloat16 &f); @@ -167,6 +168,7 @@ public: QDataStream &operator<<(quint32 i); QDataStream &operator<<(qint64 i); QDataStream &operator<<(quint64 i); + QDataStream &operator<<(std::nullptr_t) { return *this; } QDataStream &operator<<(bool i); QDataStream &operator<<(qfloat16 f); QDataStream &operator<<(float f); diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index fc8d7dcfea..b75f2ad9dc 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1350,6 +1350,7 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) case QMetaType::QJsonDocument: return false; case QMetaType::Nullptr: + stream << *static_cast(data); return true; case QMetaType::Long: stream << qlonglong(*static_cast(data)); @@ -1573,6 +1574,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) case QMetaType::QJsonDocument: return false; case QMetaType::Nullptr: + stream >> *static_cast(data); return true; case QMetaType::Long: { qlonglong l; -- cgit v1.2.3 From 49163ca689562a4a000490fb137e5c9533684471 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 5 Apr 2017 13:34:12 +0200 Subject: Android: fix Menu and Back key handling Don't quit on Back key release when Back shortcut was accepted and likewise for the Menu key, don't trigger the platform menubar if Menu shortcut was accepted. Change-Id: Ifde87cbc2d95be1beb90ca59f55889b83a90ff02 Task-number: QTBUG-59670 Reviewed-by: Paul Olav Tvete --- src/gui/kernel/qguiapplication.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a3b2c4c1e4..56f112c36c 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2027,13 +2027,23 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE window = QGuiApplication::focusWindow(); } +#if defined(Q_OS_ANDROID) + static bool backKeyPressAccepted = false; + static bool menuKeyPressAccepted = false; +#endif + #if !defined(Q_OS_OSX) // FIXME: Include OS X in this code path by passing the key event through // QPlatformInputContext::filterEvent(). if (e->keyType == QEvent::KeyPress && window) { if (QWindowSystemInterface::handleShortcutEvent(window, e->timestamp, e->key, e->modifiers, - e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, e->unicode, e->repeat, e->repeatCount)) + e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, e->unicode, e->repeat, e->repeatCount)) { +#if defined(Q_OS_ANDROID) + backKeyPressAccepted = e->key == Qt::Key_Back; + menuKeyPressAccepted = e->key == Qt::Key_Menu; +#endif return; + } } #endif @@ -2050,8 +2060,6 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE else ev.setAccepted(false); - static bool backKeyPressAccepted = false; - static bool menuKeyPressAccepted = false; if (e->keyType == QEvent::KeyPress) { backKeyPressAccepted = e->key == Qt::Key_Back && ev.isAccepted(); menuKeyPressAccepted = e->key == Qt::Key_Menu && ev.isAccepted(); -- cgit v1.2.3 From 23d08ce2edab09562ad283dac5d46c09efec63ca Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Feb 2017 13:58:55 -0800 Subject: Fix QDir::mkpath() when the path contains "symlink/../" It is incorrect to collapse a "symlink/.." segment because the parent directory of the symlink's target may not be the directory where the symlink itself is located. [ChangeLog][QtCore][QDir] Fixed a bug that caused QDir::mkpath() to create the wrong directory if the requested path contained a symbolic link and "../". Change-Id: Iaddbecfbba5441c8b2e4fffd14a3e367730a1e24 Reviewed-by: Oswald Buddenhagen Reviewed-by: David Faure --- src/corelib/io/qfilesystemengine_unix.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 3cb412e47c..e195afdae9 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2017 Intel Corporation. ** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2013 Samuel Gaist ** Contact: https://www.qt.io/licensing/ @@ -603,25 +604,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea if (!createParents) return false; - // we need the cleaned path in order to create the parents - // and we save errno just in case encodeName needs to load codecs - int savedErrno = errno; - bool pathChanged; - { - QString cleanName = QDir::cleanPath(dirName); - - // Check if the cleaned name is the same or not. If we were given a - // path with resolvable "../" sections, cleanPath will remove them, but - // this may change the target dir if one of those segments was a - // symlink. This operation depends on cleanPath's optimization of - // returning the original string if it didn't modify anything. - pathChanged = !dirName.isSharedWith(cleanName); - if (pathChanged) - nativeName = QFile::encodeName(cleanName); - } - - errno = savedErrno; - return createDirectoryWithParents(nativeName, pathChanged); + return createDirectoryWithParents(nativeName, false); } //static -- cgit v1.2.3 From 43a5fe258b7f48baad69ac040f395cb597022fa9 Mon Sep 17 00:00:00 2001 From: Heiko Becker Date: Fri, 7 Apr 2017 16:21:23 +0200 Subject: Update attribution file for changed command line param 47c4d1378cc1eaffbc19c753726b36d2ff0decc0 changed the configuration command line parameter back to pcre, omitting the "2" which has been added after porting to PCRE2. Change-Id: Iadbd57725ab706cb4bae89c2decf8259bcad46b5 Reviewed-by: Oswald Buddenhagen --- src/3rdparty/pcre2/qt_attribution.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty/pcre2/qt_attribution.json b/src/3rdparty/pcre2/qt_attribution.json index 2e80d51298..bcf7650993 100644 --- a/src/3rdparty/pcre2/qt_attribution.json +++ b/src/3rdparty/pcre2/qt_attribution.json @@ -2,7 +2,7 @@ "Id": "pcre2", "Name": "PCRE2", "QDocModule": "qtcore", - "QtUsage": "Optionally used in Qt Core (QRegularExpression). Configure with -system-pcre2 or -no-pcre2 to avoid.", + "QtUsage": "Optionally used in Qt Core (QRegularExpression). Configure with -system-pcre or -no-pcre to avoid.", "Description": "The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.", "Homepage": "http://www.pcre.org/", -- cgit v1.2.3 From 944bf6867f8360e7ec79f542f65b4ea556ecc4e5 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Sun, 5 Mar 2017 17:28:56 +0100 Subject: Add more information about how to get a QString from qgetenv Change-Id: Ic712654c8d4735a59bf02cf6a7e1c689ca9a886c Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 54df8b1f61..6b3cb502e5 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3220,12 +3220,16 @@ static QBasicMutex environmentMutex; Returns the value of the environment variable with name \a varName. To get the variable string, use QByteArray::constData(). + To convert the data to a QString use QString::fromLocal8Bit(). \note qgetenv() was introduced because getenv() from the standard C library was deprecated in VC2005 (and later versions). qgetenv() uses the new replacement function in VC, and calls the standard C library's implementation on all other platforms. + \warning Don't use qgetenv on Windows if the content may contain + non-US-ASCII characters, like file paths. + \sa qputenv(), qEnvironmentVariableIsSet(), qEnvironmentVariableIsEmpty() */ QByteArray qgetenv(const char *varName) -- cgit v1.2.3 From 07bd5a90a3dccaa31940e3b1a78069f55e25405a Mon Sep 17 00:00:00 2001 From: Filipe Azevedo Date: Tue, 13 Dec 2016 16:02:23 +0100 Subject: Fix hidpi support for opengl window grabbing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now set the QImage devicePixelRatio so the content is correct on all screens. Task-number: QTBUG-53795 Change-Id: Ic92eee98f691ebb1e0212498c1ae13ede74bca93 Reviewed-by: Laszlo Agocs Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qopenglwindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index e1bd3d11b2..5170c7ab63 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -528,7 +528,9 @@ QImage QOpenGLWindow::grabFramebuffer() return QImage(); makeCurrent(); - return qt_gl_read_framebuffer(size() * devicePixelRatio(), false, false); + QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), false, false); + img.setDevicePixelRatio(devicePixelRatio()); + return img; } /*! -- cgit v1.2.3 From 75cdf654bcc192ba73a8834e507583a59140e7e4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 Apr 2017 13:12:05 -0700 Subject: QMap: fix UB (invalid cast) in QMapData::end() The end() pointer, like in all other containers, is a sentinel value that must never be dereferenced. But unlike array-based containers, end() in QMap is not "last element plus one", but points to a base class of Node, not a full Node. Therefore, the casting from QMapNodeBase to QMapNode must not be a static_cast, reinterpret_cast is required. libstdc++-v3's red-black tree had the exact same problem: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734 Change-Id: I43f05fedf0b44314a2dafffd14b33697861ae589 Reviewed-by: Marc Mutz --- src/corelib/tools/qmap.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 3f4f034b4e..da77ba4458 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -209,8 +209,10 @@ struct QMapData : public QMapDataBase Node *root() const { return static_cast(header.left); } - const Node *end() const { return static_cast(&header); } - Node *end() { return static_cast(&header); } + // using reinterpret_cast because QMapDataBase::header is not + // actually a QMapNode. + const Node *end() const { return reinterpret_cast(&header); } + Node *end() { return reinterpret_cast(&header); } const Node *begin() const { if (root()) return static_cast(mostLeftNode); return end(); } Node *begin() { if (root()) return static_cast(mostLeftNode); return end(); } -- cgit v1.2.3 From 9d1203bf02abec8b5ab73c4c8a81eb4627336ad8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 9 Apr 2017 09:19:41 +0200 Subject: QVariant: fix docs regarding QUuid - toUuid(): QUuid is a built-in type, so use type(), not userType() - canConvert()/toUuid(): QUuid converts to and from QString Change-Id: I5262ff7ab093040cb943b6ab9cfffe95491d2b9b Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 7c9df5b46f..8ad61be8ee 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2526,8 +2526,9 @@ QRegularExpression QVariant::toRegularExpression() const /*! \since 5.0 - Returns the variant as a QUuid if the variant has userType() \l - QUuid; otherwise returns a default constructed QUuid. + Returns the variant as a QUuid if the variant has type() + \l QMetaType::QUuid or \l QMetaType::QString; + otherwise returns a default-constructed QUuid. \sa canConvert(), convert() */ @@ -2995,7 +2996,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \l QMetaType::QDate, \l QMetaType::QDateTime, \l QMetaType::Double, \l QMetaType::QFont, \l QMetaType::Int, \l QMetaType::QKeySequence, \l QMetaType::LongLong, \l QMetaType::QStringList, \l QMetaType::QTime, - \l QMetaType::UInt, \l QMetaType::ULongLong + \l QMetaType::UInt, \l QMetaType::ULongLong, \l QMetaType::QUuid \row \li \l QMetaType::QStringList \li \l QMetaType::QVariantList, \l QMetaType::QString (if the list contains exactly one item) \row \li \l QMetaType::QTime \li \l QMetaType::QString @@ -3005,6 +3006,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \row \li \l QMetaType::ULongLong \li \l QMetaType::Bool, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt + \row \li \l QMetaType::QUuid \li \l QMetaType::QString \endtable A QVariant containing a pointer to a type derived from QObject will also return true for this -- cgit v1.2.3 From 45862976b7566d416aff887b74eb60cb039a3dd6 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 7 Apr 2017 11:00:54 +0200 Subject: winrt: Fix build for Windows 10 Creators Update Phone specific UI colors have been removed from the windows headers. Continue to use the enum values does not gain anything as the native calls return errors for those. Actually they did that already with 14393. Change-Id: I4b04d3af319766216ae7c550af704aab488c1d15 Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrttheme.cpp | 3 +++ src/plugins/platforms/winrt/winrt.pro | 1 + 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp index 6b35bde83e..5696ae7a10 100644 --- a/src/plugins/platforms/winrt/qwinrttheme.cpp +++ b/src/plugins/platforms/winrt/qwinrttheme.cpp @@ -146,6 +146,8 @@ static void nativeColorSettings(QPalette &p) if (uiColorSettings(L"Hotlight", UIElementType_Hotlight, &color)) p.setColor(QPalette::BrightText, fromColor(color)); + // Starting with SDK 15063 those have been removed. +#ifndef QT_WINRT_DISABLE_PHONE_COLORS //Phone related if (uiColorSettings(L"PopupBackground", UIElementType_PopupBackground, &color)) { p.setColor(QPalette::ToolTipBase, fromColor(color)); @@ -186,6 +188,7 @@ static void nativeColorSettings(QPalette &p) if (uiColorSettings(L"TextContrastWithHigh", UIElementType_TextContrastWithHigh, &color)) p.setColor(QPalette::BrightText, fromColor(color)); +#endif // QT_WINRT_DISABLE_PHONE_COLORS } QWinRTTheme::QWinRTTheme() diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 35801fdacc..02a848b03f 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -51,6 +51,7 @@ OTHER_FILES += winrt.json WINRT_SDK_VERSION_STRING = $$(UCRTVersion) WINRT_SDK_VERSION = $$member($$list($$split(WINRT_SDK_VERSION_STRING, .)), 2) lessThan(WINRT_SDK_VERSION, 14322): DEFINES += QT_WINRT_LIMITED_DRAGANDDROP +greaterThan(WINRT_SDK_VERSION, 14393): DEFINES += QT_WINRT_DISABLE_PHONE_COLORS contains(DEFINES, QT_NO_DRAGANDDROP) { SOURCES -= qwinrtdrag.cpp -- cgit v1.2.3 From c0ecfc08e3bfb8d93136a859808bf713c56b68e3 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 10 Apr 2017 11:05:51 +0200 Subject: QTextDocument: improve import of DIV tags
1
2 was inserting two newlines between 1 and 2, while all tested web browsers only insert one newline - as long as there is nothing between the
and the . This was the cause for extra newlines being inserted in KMail when replying to HTML emails, such as those generated by gmail. Change-Id: I5145d977701e68913264357bba22780e7cdd3f7d Reviewed-by: Simon Hausmann --- src/gui/text/qtextdocumentfragment.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index 3a78296c57..ea37695f4e 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -825,9 +825,13 @@ bool QTextHtmlImporter::closeTag() break; case Html_div: - if (closedNode->children.isEmpty()) - break; - Q_FALLTHROUGH(); + if (cursor.position() > 0) { + const QChar curChar = cursor.document()->characterAt(cursor.position() - 1); + if (!closedNode->children.isEmpty() && curChar != QChar::LineSeparator) { + blockTagClosed = true; + } + } + break; default: if (closedNode->isBlock()) blockTagClosed = true; -- cgit v1.2.3 From 2099709a721e2bc72350a02757099df6629475ca Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 10 Apr 2017 09:52:16 +0300 Subject: Fix build: Remove unused variable Change-Id: Ib5e7782e23eb1ff976caedd167d3df8b857d9883 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/qandroidplatformopenglcontext.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp index 6f979f614c..bef6bb9d42 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp @@ -67,10 +67,7 @@ void QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface) bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface) { - bool ret = QEGLPlatformContext::makeCurrent(surface); - QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); - - return ret; + return QEGLPlatformContext::makeCurrent(surface); } EGLSurface QAndroidPlatformOpenGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) -- cgit v1.2.3 From 88d3195164eb611f13aa9ac4bb8f45e08a38fef6 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Fri, 7 Apr 2017 14:54:18 +0200 Subject: QWindowsPrintDevice: Handle 0 from DocumentProperties correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-55090 Change-Id: I5fadd0f007c826ab6747f319dbf3eaee5f208a44 Reviewed-by: Michael Brüning --- src/plugins/printsupport/windows/qwindowsprintdevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp index 7e6eb7c559..99e8ec8999 100644 --- a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp +++ b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp @@ -86,7 +86,7 @@ static LPDEVMODE getDevmode(HANDLE hPrinter, const QString &printerId) LPWSTR printerIdUtf16 = const_cast(reinterpret_cast(printerId.utf16())); // Allocate the required DEVMODE buffer LONG dmSize = DocumentProperties(NULL, hPrinter, printerIdUtf16, NULL, NULL, 0); - if (dmSize < 0) + if (dmSize <= 0) return Q_NULLPTR; LPDEVMODE pDevMode = reinterpret_cast(malloc(dmSize)); // Get the default DevMode -- cgit v1.2.3 From db29042588ac406b46ec431badc2c12a5d3a8d56 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 9 Apr 2017 15:57:45 +0200 Subject: QQnxWindow: replace QUuid::toString().toLatin1() with QUuid::toByteArray() UUIDs are always US-ASCII. Change-Id: I335882a2df179204d8eca1cf9f02bc6473bac700 Reviewed-by: Edward Welbourne --- src/plugins/platforms/qnx/qqnxwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 6fd0191e43..30288ccb20 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -694,7 +694,7 @@ void QQnxWindow::initWindow() void QQnxWindow::createWindowGroup() { // Generate a random window group name - m_windowGroupName = QUuid::createUuid().toString().toLatin1(); + m_windowGroupName = QUuid::createUuid().toByteArray(); // Create window group so child windows can be parented by container window Q_SCREEN_CHECKERROR(screen_create_window_group(m_window, m_windowGroupName.constData()), -- cgit v1.2.3 From 46c66bce5de04396292600b0c2c87c2468a02102 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 7 Feb 2017 22:29:45 +0100 Subject: Optimize QLoggingSettingsParser Factor the line parsing into a separate function, parseNextLine(), taking a QStringRef. In setContent(QTextStream&), use the new readLineInto() function to re-use the capacity of a single QString for all lines. In setContent(QString), use splitRef() to split the lines. In either function, pass each line to parseNextLine(). In order to port all the parsing to QStringRef, I needed to make some semantic changes: the old code removed all whitespace right at the beginning. This is not possible with QStringRef. It also didn't feel right, since a line like [ r u l e s ] would successfully parse as the section named "rules". I added trimmed() calls at the beginning, and around the valueStr and pattern extraction, which should be good enough. Also, when a section is found, don't store it anymore. Instead, only store whether it was the [rules] section, because that's all we'll test for. That way, we don't have to convert QStringRefs to QString just to store them across parseNextLine() calls. Replace the setSection() function with setImplicitRulesSection(), because "rules" is all that was ever passed. This is private API, we can bring back some of the dropped flexibility later, as needed. [ChangeLog][Important Behavior Changes] Logging rules can no longer contain arbitrary whitespace such as within a category identifier. Change-Id: Ic26cd23c71f5c810b37ef4b972354ac31d3408fe Reviewed-by: Kai Koehne --- src/corelib/io/qloggingregistry.cpp | 83 ++++++++++++++++++++----------------- src/corelib/io/qloggingregistry_p.h | 7 +++- 2 files changed, 51 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index ff865dc9a1..47fb1fb6b8 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -186,9 +186,10 @@ void QLoggingRule::parse(const QStringRef &pattern) */ void QLoggingSettingsParser::setContent(const QString &content) { - QString content_ = content; - QTextStream stream(&content_, QIODevice::ReadOnly); - setContent(stream); + _rules.clear(); + const auto lines = content.splitRef(QLatin1Char('\n')); + for (const auto &line : lines) + parseNextLine(line); } /*! @@ -198,42 +199,50 @@ void QLoggingSettingsParser::setContent(const QString &content) void QLoggingSettingsParser::setContent(QTextStream &stream) { _rules.clear(); - while (!stream.atEnd()) { - QString line = stream.readLine(); - - // Remove all whitespace from line - line = line.simplified(); - line.remove(QLatin1Char(' ')); + QString line; + while (stream.readLineInto(&line)) + parseNextLine(QStringRef(&line)); +} - // comment - if (line.startsWith(QLatin1Char(';'))) - continue; +/*! + \internal + Parses one line of the configuation file +*/ - if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) { - // new section - _section = line.mid(1, line.size() - 2); - continue; - } +void QLoggingSettingsParser::parseNextLine(QStringRef line) +{ + // Remove whitespace at start and end of line: + line = line.trimmed(); + + // comment + if (line.startsWith(QLatin1Char(';'))) + return; + + if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) { + // new section + auto sectionName = line.mid(1, line.size() - 2).trimmed(); + m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0; + return; + } - if (_section.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0) { - int equalPos = line.indexOf(QLatin1Char('=')); - if (equalPos != -1) { - if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { - const QStringRef pattern = line.leftRef(equalPos); - const QStringRef valueStr = line.midRef(equalPos + 1); - int value = -1; - if (valueStr == QLatin1String("true")) - value = 1; - else if (valueStr == QLatin1String("false")) - value = 0; - QLoggingRule rule(pattern, (value == 1)); - if (rule.flags != 0 && (value != -1)) - _rules.append(rule); - else - warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); - } else { + if (m_inRulesSection) { + int equalPos = line.indexOf(QLatin1Char('=')); + if (equalPos != -1) { + if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { + const auto pattern = line.left(equalPos).trimmed(); + const auto valueStr = line.mid(equalPos + 1).trimmed(); + int value = -1; + if (valueStr == QLatin1String("true")) + value = 1; + else if (valueStr == QLatin1String("false")) + value = 0; + QLoggingRule rule(pattern, (value == 1)); + if (rule.flags != 0 && (value != -1)) + _rules.append(rule); + else warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); - } + } else { + warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); } } } @@ -286,7 +295,7 @@ void QLoggingRegistry::init() if (!rulesSrc.isEmpty()) { QTextStream stream(rulesSrc); QLoggingSettingsParser parser; - parser.setSection(QStringLiteral("Rules")); + parser.setImplicitRulesSection(true); parser.setContent(stream); er += parser.rules(); } @@ -350,7 +359,7 @@ void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat) void QLoggingRegistry::setApiRules(const QString &content) { QLoggingSettingsParser parser; - parser.setSection(QStringLiteral("Rules")); + parser.setImplicitRulesSection(true); parser.setContent(content); if (qtLoggingDebug()) diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 23740c4955..69fc6ea4ec 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -93,7 +93,7 @@ Q_DECLARE_TYPEINFO(QLoggingRule, Q_MOVABLE_TYPE); class Q_AUTOTEST_EXPORT QLoggingSettingsParser { public: - void setSection(const QString §ion) { _section = section; } + void setImplicitRulesSection(bool inRulesSection) { m_inRulesSection = inRulesSection; } void setContent(const QString &content); void setContent(QTextStream &stream); @@ -101,7 +101,10 @@ public: QVector rules() const { return _rules; } private: - QString _section; + void parseNextLine(QStringRef line); + +private: + bool m_inRulesSection = false; QVector _rules; }; -- cgit v1.2.3 From 6c4cbd4122edf8b78f34778400d485b11da98404 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 10 Apr 2017 14:19:12 +0300 Subject: Android: Fix crash at exit We need to remove and release the surface imediately, otherwise setSurface might be called after the object is deleted. Task-number: QTBUG-59818 Change-Id: I3a09e3de1ceecc22d8d7a48e2fc1cfe40cf09f0a Reviewed-by: Laszlo Agocs Reviewed-by: Mathias Hasselmann Reviewed-by: Christian Stromme --- src/plugins/platforms/android/androidjnimain.cpp | 27 +++++++++++----------- .../platforms/android/qandroidplatformscreen.cpp | 3 +++ 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 17c197ea38..bde7457c0b 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -402,11 +402,16 @@ namespace QtAndroid if (surfaceId == -1) return; - QJNIEnvironmentPrivate env; - if (!env) - return; + { + QMutexLocker lock(&m_surfacesMutex); + const auto &it = m_surfaces.find(surfaceId); + if (it != m_surfaces.end()) + m_surfaces.erase(it); + } - env->CallStaticVoidMethod(m_applicationClass, + QJNIEnvironmentPrivate env; + if (env) + env->CallStaticVoidMethod(m_applicationClass, m_destroySurfaceMethodID, surfaceId); } @@ -584,18 +589,12 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface, { QMutexLocker lock(&m_surfacesMutex); const auto &it = m_surfaces.find(id); - if (it == m_surfaces.end()) { - qWarning()<<"Can't find surface" << id; - return; - } - auto surfaceClient = it.value(); - if (!surfaceClient) // This should never happen... + if (it == m_surfaces.end()) return; - surfaceClient->surfaceChanged(env, jSurface, w, h); - - if (!jSurface) - m_surfaces.erase(it); + auto surfaceClient = it.value(); + if (surfaceClient) + surfaceClient->surfaceChanged(env, jSurface, w, h); } static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 155d6bfb8d..3b59b293a5 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -311,10 +311,13 @@ void QAndroidPlatformScreen::doRedraw() } } if (!hasVisibleRasterWindows) { + lockSurface(); if (m_id != -1) { QtAndroid::destroySurface(m_id); + releaseSurface(); m_id = -1; } + unlockSurface(); return; } QMutexLocker lock(&m_surfaceMutex); -- cgit v1.2.3 From 187427c0aec83deb08c9bd6466b5803089bd2c93 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 10 Apr 2017 15:06:08 +0300 Subject: Use latest stable version of the android:gradle plugin Change-Id: I15418015c6a206dd1a8e4b52894ec83ddaeb9fc2 Reviewed-by: Jake Petroules --- src/android/templates/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/android/templates/build.gradle b/src/android/templates/build.gradle index dbe841255d..3a3e0cd165 100644 --- a/src/android/templates/build.gradle +++ b/src/android/templates/build.gradle @@ -4,7 +4,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:2.2.0' + classpath 'com.android.tools.build:gradle:2.2.3' } } -- cgit v1.2.3 From eda7f6ea7863b80985f62b28fe99c1176bc54c77 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 6 Apr 2017 11:14:26 +0300 Subject: Don't hide critical info The developer should see what's wrong even on release builds. That code hides any mistakes we do in JNI which are pretty critical for developers because they can't see what's wrong with their code. e.g. QtAndroid::activity().callMethod("wrongMethodName") *silently* fails, which is so wrong! Change-Id: I8b6a24946dfef716fcd86ab9bba82666974e3991 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/kernel/qjni.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 41d55c8fde..60154328c2 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -64,9 +64,7 @@ static QString qt_convertJString(jstring string) static inline bool exceptionCheckAndClear(JNIEnv *env) { if (Q_UNLIKELY(env->ExceptionCheck())) { -#ifdef QT_DEBUG env->ExceptionDescribe(); -#endif // QT_DEBUG env->ExceptionClear(); return true; } -- cgit v1.2.3 From dbea118f120a781e1aed717856bb7ab3d3ec86f1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 2 Apr 2017 20:09:58 -0700 Subject: gtk3: Mark the minimum version we support This suppresses warnings for API that is deprecated. Gtk often marks API like: GDK_DEPRECATED_IN_3_22_FOR((gtk_menu_popup_at_widget, gtk_menu_popup_at_pointer, gtk_menu_popup_at_rect)) void gtk_menu_popup (GtkMenu *menu, Which generates this (found with ICC, accidentally an error): qgtk3menu.cpp(449): error #1786: function "gtk_menu_popup" (declared at line 138 of "/usr/include/gtk-3.0/gtk/gtkmenu.h") was declared deprecated ("Use '(gtk_menu_popup_at_widget, gtk_menu_popup_at_pointer, gtk_menu_popup_at_rect)' instead") The warning is generated by GDK_DEPRECATED_IN_xxxx_FOR when GDK_VERSION_MIN_REQUIRED is higher than xxxx. And by default, unlike the Qt equivalent macros, the minimum version required is equal to the current version. The minimum version our support requires is 3.6, as we depend on gtk_accel_label_set_accel, which was first introduced in that version. Change-Id: I27b55fdf514247549455fffd14b1c47e470510b2 Reviewed-by: Oswald Buddenhagen --- src/plugins/platformthemes/gtk3/gtk3.pro | 1 + src/widgets/configure.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platformthemes/gtk3/gtk3.pro b/src/plugins/platformthemes/gtk3/gtk3.pro index c291ac56a0..cac6f7054d 100644 --- a/src/plugins/platformthemes/gtk3/gtk3.pro +++ b/src/plugins/platformthemes/gtk3/gtk3.pro @@ -9,6 +9,7 @@ QT += core-private gui-private theme_support-private CONFIG += X11 QMAKE_USE += gtk3 +DEFINES += GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6 HEADERS += \ qgtk3dialoghelpers.h \ diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 13c7c774ed..ab8ced3849 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -20,9 +20,9 @@ "libraries": { "gtk3": { - "label": "GTK+", + "label": "GTK+ >= 3.6", "sources": [ - { "type": "pkgConfig", "args": "gtk+-3.0" } + { "type": "pkgConfig", "args": "gtk+-3.0 >= 3.6" } ] } }, -- cgit v1.2.3 From d5f62f7bc7895815546cd2f6be9605486907018d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 10 Apr 2017 08:37:08 -0700 Subject: Ask MS runtime to reload the timezone details if they've changed POSIX documents that localtime() ensures that tzset() has been called, but the wording could be understood to mean that it only needs to do so the first time. Anyway, we're sure that the MS runtime only gets the timezone information from the Control Panel once. That means Qt-based applications will not react to a change in the timezone. Attempt to do that by moving tzset() out of the #if, to apply to all operating systems. Task-number: QTBUG-60043 Change-Id: I6ab535fb61094af19fc1fffd14b413541fe5a64c Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index a4a7aabacb..bcdbc5af2a 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2287,10 +2287,11 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT tm local; bool valid = false; -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) // localtime() is required to work as if tzset() was called before it. // localtime_r() does not have this requirement, so make an explicit call. + // The explicit call should also request the timezone info be re-parsed. qt_tzset(); +#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) // Use the reentrant version of localtime() where available // as is thread-safe and doesn't use a shared static data area tm *res = 0; -- cgit v1.2.3 From da1be671cf4081fe41ed886113d6b50723df17d4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Apr 2017 18:43:51 +0200 Subject: QtTest: add toString(QUuid) [ChangeLog][QtTest] QUuids are now printed on failure. Change-Id: I39a7b9169aef8ab6ef5ce0790920547af23bd1b9 Reviewed-by: Milian Wolff --- src/testlib/qtest.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index b9bb10818e..ba63df5f36 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -164,6 +165,11 @@ template<> inline char *toString(const QUrl &uri) return qstrdup(uri.toEncoded().constData()); } +template <> inline char *toString(const QUuid &uuid) +{ + return qstrdup(uuid.toByteArray().constData()); +} + template<> inline char *toString(const QVariant &v) { QByteArray vstring("QVariant("); -- cgit v1.2.3 From 850c5dbcd3e56589a2825a7a156a14a0ccdd220d Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 19 Jan 2017 12:25:57 +0100 Subject: Doc: minor language issues in Qt Sql doc Change-Id: If9ad86644c097d78895e392acdf017f176d8f95d Reviewed-by: Edward Welbourne --- src/sql/doc/src/sql-driver.qdoc | 54 ++++++++++++++++++------------------ src/sql/doc/src/sql-programming.qdoc | 13 ++++----- 2 files changed, 33 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index 364d733e92..4f3f2ce007 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -62,7 +62,7 @@ \endtable SQLite is the in-process database system with the best test coverage - and support on all platforms. Oracle via OCI, and PostreSQL and MySQL + and support on all platforms. Oracle via OCI, PostgreSQL, and MySQL through either ODBC or a native driver are well-tested on Windows and Linux. The completeness of the support for other systems depends on the availability and quality of client libraries. @@ -92,7 +92,7 @@ on Windows), then pass the following parameter to configure: \c -I/usr/local/mysql (or \c{-I C:\mysql\include} for Windows). - On Windows the \c -I parameter doesn't accept spaces in + On Windows, the \c -I parameter doesn't accept spaces in filenames, so use the 8.3 name instead; for example, use \c{C:\progra~1\mysql} instead of \c{C:\Program Files\mysql}. @@ -110,7 +110,7 @@ \section3 QMYSQL Stored Procedure Support MySQL 5 introduces stored procedure support at the SQL level, but no - API to control IN, OUT and INOUT parameters. Therefore, parameters + API to control IN, OUT, and INOUT parameters. Therefore, parameters have to be set and read using SQL commands instead of QSqlQuery::bindValue(). Example stored procedure: @@ -141,8 +141,8 @@ \section3 How to Build the QMYSQL Plugin on Unix and \macos - You need the MySQL header files and as well as the shared library - \c{libmysqlclient.so}. Depending on your Linux distribution you may + You need the MySQL header files, as well as the shared library + \c{libmysqlclient.so}. Depending on your Linux distribution, you may need to install a package which is usually called "mysql-devel". Tell \l qmake where to find the MySQL header files and shared @@ -168,10 +168,10 @@ If you are not using a Microsoft compiler, replace \c nmake with \c make in the line above. - \note Including \c{"-o Makefile"} as an argument to \l qmake to - tell it where to build the makefile can cause the plugin to be - built in release mode only. If you are expecting a debug version - to be built as well, don't use the \c{"-o Makefile"} option. + \note Including \c{"-o Makefile"} as an argument to \l qmake, to + tell it where to build the makefile, can cause the plugin to be + built in release mode only. If you intend to build a debug version + as well, don't use the \c{"-o Makefile"} option. \target QOCI \section2 QOCI for the Oracle Call Interface (OCI) @@ -184,7 +184,7 @@ It's possible to connect to a Oracle database without a tnsnames.ora file. This requires that the database SID is passed to the driver as the database - name and that a hostname is given. + name, and that a hostname is given. \section3 OCI User Authentication @@ -230,13 +230,13 @@ \snippet code/doc_src_sql-driver.qdoc 7 \b{Note:} If you are using the Oracle Instant Client package, - you will need to set LD_LIBRARY_PATH when building the OCI SQL plugin + you will need to set LD_LIBRARY_PATH when building the OCI SQL plugin, and when running an application that uses the OCI SQL plugin. You can - avoid this requirement by setting and RPATH and listing all of the + avoid this requirement by setting RPATH, and listing all of the libraries to link to. Here is an example: \snippet code/doc_src_sql-driver.qdoc 32 - If you wish to build the OCI plugin manually with this method the procedure looks like this: + If you wish to build the OCI plugin manually with this method, the procedure looks like this: \snippet code/doc_src_sql-driver.qdoc 33 \section3 How to Build the OCI Plugin on Windows @@ -254,7 +254,7 @@ If you are not using a Microsoft compiler, replace \c nmake with \c make in the line above. - When you run your application you will also need to add the \c oci.dll + When you run your application, you will also need to add the \c oci.dll path to your \c PATH environment variable: \snippet code/doc_src_sql-driver.qdoc 9 @@ -271,25 +271,25 @@ driver manager that is installed on your system. The QODBC plugin then allows you to use these data sources in your Qt applications. - \b{Note:} You should use native drivers in preference to the ODBC - driver where they are available. ODBC support can be used as a fallback - for compliant databases if no native drivers are available. + \b{Note:} You should use the native driver, if it is available, instead + of the ODBC driver. ODBC support can be used as a fallback for compliant + databases if no native driver is available. - On Windows an ODBC driver manager should be installed by default. - For Unix systems there are some implementations which must be + On Windows, an ODBC driver manager should be installed by default. + For Unix systems, there are some implementations which must be installed first. Note that every client that uses your application is required to have an ODBC driver manager installed, otherwise the QODBC plugin will not work. - Be aware that when connecting to an ODBC datasource you must pass in - the name of the ODBC datasource to the QSqlDatabase::setDatabaseName() - function rather than the actual database name. + When connecting to an ODBC datasource, you should pass the name + of the ODBC datasource to the QSqlDatabase::setDatabaseName() + function, rather than the actual database name. The QODBC Plugin needs an ODBC compliant driver manager version 2.0 or - later to work. Some ODBC drivers claim to be version 2.0 compliant, + later. Some ODBC drivers claim to be version-2.0-compliant, but do not offer all the necessary functionality. The QODBC plugin therefore checks whether the data source can be used after a - connection has been established and refuses to work if the check + connection has been established, and refuses to work if the check fails. If you don't like this behavior, you can remove the \c{#define ODBC_CHECK_DRIVER} line from the file \c{qsql_odbc.cpp}. Do this at your own risk! @@ -332,7 +332,7 @@ driver and the DBMS must also support Unicode. Some driver managers and drivers don't support UNICODE. To use the - QODBC plugin with such drivers it has to be compiled with the + QODBC plugin with such drivers, it has to be compiled with Q_ODBC_VERSION_2 defined. For the Oracle 9 ODBC driver (Windows), it is necessary to check @@ -368,9 +368,9 @@ The QPSQL driver supports version 7.3 and higher of the PostgreSQL server. We recommend that you use a client library from version 7.3.15, 7.4.13, - 8.0.8, 8.1.4 or more recent as these versions contain security fixes, and + 8.0.8, 8.1.4, or more recent, as these versions contain security fixes, and as the QPSQL driver might not build with older versions of the client - library depending on your platform. + library, depending on your platform. For more information about PostgreSQL visit \l http://www.postgresql.org. diff --git a/src/sql/doc/src/sql-programming.qdoc b/src/sql/doc/src/sql-programming.qdoc index 39381ff296..ece89a30ab 100644 --- a/src/sql/doc/src/sql-programming.qdoc +++ b/src/sql/doc/src/sql-programming.qdoc @@ -227,7 +227,7 @@ Databases, please refer to \l{Data Types for Qt-supported Database Systems} {this table}. - You can iterate back and forth using QSqlQuery::next(), + You can navigate within the dataset using QSqlQuery::next(), QSqlQuery::previous(), QSqlQuery::first(), QSqlQuery::last(), and QSqlQuery::seek(). The current row index is returned by QSqlQuery::at(), and the total number of rows in the result set @@ -242,11 +242,10 @@ \snippet sqldatabase/sqldatabase.cpp 33 - If you iterate through a result set only using next() and seek() - with positive values, you can call - QSqlQuery::setForwardOnly(true) before calling exec(). This is an - easy optimization that will speed up the query significantly when - operating on large result sets. + If you navigate within a result set, and use next() and seek() + only for browsing forward, you can call QSqlQuery::setForwardOnly(true) + before calling exec(). This is an easy optimization that will speed up + the query significantly when operating on large result sets. \section2 Inserting, Updating, and Deleting Records @@ -592,7 +591,7 @@ QDataWidgetMapper operates on a specific database table, mapping items in the table on a row-by-row or column-by-column basis. As a result, - using QDataWidgetMapper with a SQL model is as simple as using it with + using QDataWidgetMapper with an SQL model is as simple as using it with any other table model. \image qdatawidgetmapper-simple.png -- cgit v1.2.3 From 17fc188aec5806167d3c6165b0ad299a8d2a6bcf Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 11 Apr 2017 09:35:52 +0200 Subject: Implement maxCharWidth() for DirectWrite engine This is used to create the bounding box in QFontEngine::properties(), which in turn is used for the FontBBox when generating PDFs. The result was that the bounding width in the output was 0 and Adobe Reader complained that the PDF was malformed. We could implement the proper bounding rect in properties() at some point, instead of assuming an origin at x = 0 for instance. The metrics for that are in the head table. But for silencing the warning in Reader, just implementing the maxCharWidth() function is sufficient. [ChangeLog][Windows][PDF] Fixed a bug in PDF output when using high-dpi scaling which was causing the display of warnings when opening the file in Adobe Reader. Task-number: QTBUG-58954 Change-Id: I2540571863d4dd0f85af533b591f75dad3f0d75b Reviewed-by: Simon Hausmann --- .../fontdatabases/windows/qwindowsfontenginedirectwrite.cpp | 12 ++++++++++-- .../fontdatabases/windows/qwindowsfontenginedirectwrite_p.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index 683b7f65ad..6f2755a05a 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -355,6 +355,13 @@ void QWindowsFontEngineDirectWrite::collectMetrics() m_faceId.filename = QFile::encodeName(filenameFromFontFile(fontFile)); fontFile->Release(); } + + QByteArray table = getSfntTable(MAKE_TAG('h', 'h', 'e', 'a')); + const int advanceWidthMaxLocation = 10; + if (table.size() >= advanceWidthMaxLocation + sizeof(quint16)) { + quint16 advanceWidthMax = qFromBigEndian(table.constData() + advanceWidthMaxLocation); + m_maxAdvanceWidth = DESIGN_TO_LOGICAL(advanceWidthMax); + } } QFixed QWindowsFontEngineDirectWrite::underlinePosition() const @@ -607,8 +614,9 @@ QFixed QWindowsFontEngineDirectWrite::xHeight() const qreal QWindowsFontEngineDirectWrite::maxCharWidth() const { - // ### - return 0; + return fontDef.styleStrategy & QFont::ForceIntegerMetrics + ? m_maxAdvanceWidth.round().toReal() + : m_maxAdvanceWidth.toReal(); } QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h index 65b16b9ba7..db4e79e44f 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite_p.h @@ -143,6 +143,7 @@ private: QFixed m_descent; QFixed m_xHeight; QFixed m_lineGap; + QFixed m_maxAdvanceWidth; FaceId m_faceId; QString m_uniqueFamilyName; }; -- cgit v1.2.3 From 5ad2e1cea1b2c08950c91174840f542806954d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 20 Mar 2017 19:31:29 +0100 Subject: Populate application fonts via font descriptors on Apple platforms Instead of registering the font via CTFontManagerRegister we just create a font descriptor for the data/URL and populate that like normal system fonts. This makes the code more similar to how we deal with other fonts, shaves off a ms during font registration due to not registering the font, and fixes an issue on iOS where CTFontManagerRegister would invalidate earlier populated system font descriptors. Task-number: QTBUG-56765 Change-Id: I002a65075b15837c9a2d22573020d4c834111837 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 71 ++++++---------------- .../fontdatabases/mac/qcoretextfontdatabase_p.h | 7 +-- 2 files changed, 22 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index ce9b61ba4c..d0b28b856b 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -199,10 +199,6 @@ static CFArrayRef availableFamilyNames() void QCoreTextFontDatabase::populateFontDatabase() { - // The caller (QFontDB) expects the db to be populate only with system fonts, so we need - // to make sure that any previously registered app fonts become invisible. - removeApplicationFonts(); - QCFType familyNames = availableFamilyNames(); const int numberOfFamilies = CFArrayGetCount(familyNames); for (int i = 0; i < numberOfFamilies; ++i) { @@ -585,21 +581,19 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo } template <> -CFArrayRef QCoreTextFontDatabaseEngineFactory::createDescriptorArrayForFont(CTFontRef font, const QString &fileName) +CFArrayRef QCoreTextFontDatabaseEngineFactory::createDescriptorArrayForDescriptor(CTFontDescriptorRef descriptor, const QString &fileName) { Q_UNUSED(fileName) CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); - QCFType descriptor = CTFontCopyFontDescriptor(font); CFArrayAppendValue(array, descriptor); return array; } #ifndef QT_NO_FREETYPE template <> -CFArrayRef QCoreTextFontDatabaseEngineFactory::createDescriptorArrayForFont(CTFontRef font, const QString &fileName) +CFArrayRef QCoreTextFontDatabaseEngineFactory::createDescriptorArrayForDescriptor(CTFontDescriptorRef descriptor, const QString &fileName) { CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); - QCFType descriptor = CTFontCopyFontDescriptor(font); // The physical font source URL (usually a local file or Qt resource) is only required for // FreeType, when using non-system fonts, and needs some hackery to attach in a format @@ -630,44 +624,36 @@ CFArrayRef QCoreTextFontDatabaseEngineFactory::createDescriptorAr QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) { QCFType fonts; - QStringList families; - CFErrorRef error = 0; if (!fontData.isEmpty()) { QByteArray* fontDataCopy = new QByteArray(fontData); QCFType dataProvider = CGDataProviderCreateWithData(fontDataCopy, fontDataCopy->constData(), fontDataCopy->size(), releaseFontData); - QCFType cgFont = CGFontCreateWithDataProvider(dataProvider); - if (cgFont) { - if (CTFontManagerRegisterGraphicsFont(cgFont, &error)) { - QCFType font = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL); - fonts = createDescriptorArrayForFont(font, fileName); - m_applicationFonts.append(QVariant::fromValue(QCFType::constructFromGet(cgFont))); - } + if (QCFType cgFont = CGFontCreateWithDataProvider(dataProvider)) { + QCFType ctFont = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL); + QCFType descriptor = CTFontCopyFontDescriptor(ctFont); + fonts = createDescriptorArrayForDescriptor(descriptor, fileName); } } else { - QCFType fontURL = CFURLCreateWithFileSystemPath(NULL, QCFString(fileName), kCFURLPOSIXPathStyle, false); - if (CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error)) { - fonts = CTFontManagerCreateFontDescriptorsFromURL(fontURL); - m_applicationFonts.append(QVariant::fromValue(QCFType::constructFromGet(fontURL))); - } + QCFType fontURL = QUrl::fromLocalFile(fileName).toCFURL(); + fonts = CTFontManagerCreateFontDescriptorsFromURL(fontURL); } - if (error) { - NSLog(@"Unable to register font: %@", error); - CFRelease(error); - } + if (!fonts) + return QStringList(); - if (fonts) { - const int numFonts = CFArrayGetCount(fonts); - for (int i = 0; i < numFonts; ++i) { - CTFontDescriptorRef fontDescriptor = CTFontDescriptorRef(CFArrayGetValueAtIndex(fonts, i)); - populateFromDescriptor(fontDescriptor); - QCFType familyName = CFStringRef(CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontFamilyNameAttribute)); - families.append(QCFString(familyName)); - } + QStringList families; + const int numFonts = CFArrayGetCount(fonts); + for (int i = 0; i < numFonts; ++i) { + CTFontDescriptorRef fontDescriptor = CTFontDescriptorRef(CFArrayGetValueAtIndex(fonts, i)); + populateFromDescriptor(fontDescriptor); + QCFType familyName = CFStringRef(CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontFamilyNameAttribute)); + families.append(QString::fromCFString(familyName)); } + // Note: We don't do font matching via CoreText for application fonts, so we don't + // need to enable font matching for them via CTFontManagerEnableFontDescriptors. + return families; } @@ -846,22 +832,5 @@ QList QCoreTextFontDatabase::standardSizes() const return ret; } -void QCoreTextFontDatabase::removeApplicationFonts() -{ - if (m_applicationFonts.isEmpty()) - return; - - for (const QVariant &font : qAsConst(m_applicationFonts)) { - CFErrorRef error; - if (font.canConvert(qMetaTypeId >())) { - CTFontManagerUnregisterGraphicsFont(font.value >(), &error); - } else if (font.canConvert(qMetaTypeId >())) { - CTFontManagerUnregisterFontsForURL(font.value >(), kCTFontManagerScopeProcess, &error); - } - } - - m_applicationFonts.clear(); -} - QT_END_NAMESPACE diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index 8edf60b5fa..11ea0bea02 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -91,13 +91,10 @@ public: private: void populateFromDescriptor(CTFontDescriptorRef font, const QString &familyName = QString()); - virtual CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fileName) = 0; + virtual CFArrayRef createDescriptorArrayForDescriptor(CTFontDescriptorRef descriptor, const QString &fileName) = 0; mutable QString defaultFontName; - void removeApplicationFonts(); - - QVector m_applicationFonts; mutable QSet m_systemFontDescriptors; mutable QHash m_themeFonts; }; @@ -112,7 +109,7 @@ public: QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override; protected: - CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fileName) override; + CFArrayRef createDescriptorArrayForDescriptor(CTFontDescriptorRef descriptor, const QString &fileName) override; }; QT_END_NAMESPACE -- cgit v1.2.3 From 9091a058bc61e297abea03edca322edcd658cc1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 28 Mar 2017 15:53:42 +0200 Subject: Android: Fix application state tracking - Make sure we don't process state changes before the platform plugin is completely created and registered. - Protect shared data with mutexes. - Don't update the application state from different threads. This was causing issues when testing run-time permission checks, when the application quickly switches state due to permission dialog being shown. In this case the states would be incorrectly delivered when the application was made active again. Change-Id: I3446eab9414ee5437cd788c27d65f808d1314aa5 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjnimain.cpp | 42 ++++++++++++++-------- src/plugins/platforms/android/androidjnimain.h | 2 -- .../android/qandroidplatformintegration.cpp | 13 ++++--- .../android/qandroidplatformintegration.h | 7 ++-- .../platforms/android/qandroidplatformwindow.cpp | 5 --- 5 files changed, 40 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index bde7457c0b..e47dd91a3e 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -82,8 +82,8 @@ static jobject m_serviceObject = nullptr; static jmethodID m_setSurfaceGeometryMethodID = nullptr; static jmethodID m_destroySurfaceMethodID = nullptr; -static bool m_activityActive = true; // defaults to true because when the platform plugin is - // initialized, QtActivity::onResume() has already been called +static int m_pendingApplicationState = -1; +static QBasicMutex m_pendingAppStateMtx; static jclass m_bitmapClass = nullptr; static jmethodID m_createBitmapMethodID = nullptr; @@ -130,13 +130,22 @@ static const char m_qtTag[] = "Qt"; static const char m_classErrorMsg[] = "Can't find class \"%s\""; static const char m_methodErrorMsg[] = "Can't find method \"%s%s\""; +static void flushPendingApplicationState(); + namespace QtAndroid { void setAndroidPlatformIntegration(QAndroidPlatformIntegration *androidPlatformIntegration) { - m_surfacesMutex.lock(); + QMutexLocker lock(&m_surfacesMutex); m_androidPlatformIntegration = androidPlatformIntegration; - m_surfacesMutex.unlock(); + + // flush the pending state if necessary. + if (m_androidPlatformIntegration) { + flushPendingApplicationState(); + } else { + QMutexLocker locker(&m_pendingAppStateMtx); + m_pendingApplicationState = -1; + } } QAndroidPlatformIntegration *androidPlatformIntegration() @@ -215,12 +224,6 @@ namespace QtAndroid m_statusBarShowing = false; } - void setApplicationActive() - { - if (m_activityActive) - QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); - } - jobject createBitmap(QImage img, JNIEnv *env) { if (!m_bitmapClass) @@ -446,6 +449,16 @@ namespace QtAndroid } // namespace QtAndroid +// Force an update of the pending application state (state set before the platform plugin was created) +static void flushPendingApplicationState() +{ + QMutexLocker locker(&m_pendingAppStateMtx); + if (m_pendingApplicationState == -1) + return; + + QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState(m_pendingApplicationState)); + m_pendingApplicationState = -1; +} static jboolean startQtAndroidPlugin(JNIEnv* /*env*/, jobject /*object*//*, jobject applicationAssetManager*/) { @@ -655,13 +668,14 @@ static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/) static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state) { - m_activityActive = (state == Qt::ApplicationActive); - - if (!m_main || !m_androidPlatformIntegration || !QGuiApplicationPrivate::platformIntegration()) { - QAndroidPlatformIntegration::setDefaultApplicationState(Qt::ApplicationState(state)); + if (!m_main || !QtAndroid::androidPlatformIntegration()) { + QMutexLocker locker(&m_pendingAppStateMtx); + m_pendingApplicationState = Qt::ApplicationState(state); return; } + flushPendingApplicationState(); + if (state == Qt::ApplicationActive) QtAndroidPrivate::handleResume(); else if (state == Qt::ApplicationInactive) diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h index 218e52ccc1..170596082d 100644 --- a/src/plugins/platforms/android/androidjnimain.h +++ b/src/plugins/platforms/android/androidjnimain.h @@ -85,8 +85,6 @@ namespace QtAndroid jobject activity(); jobject service(); - void setApplicationActive(); - void showStatusBar(); void hideStatusBar(); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index de9e27e595..44b4668585 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -80,8 +80,6 @@ int QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight = 71; Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOrientation; Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation; -Qt::ApplicationState QAndroidPlatformIntegration::m_defaultApplicationState = Qt::ApplicationActive; - bool QAndroidPlatformIntegration::m_showPasswordEnabled = false; void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteArray &resource) @@ -120,6 +118,12 @@ void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteA return 0; } +void QAndroidPlatformNativeInterface::customEvent(QEvent *event) +{ + if (event->type() == QEvent::User) + QtAndroid::setAndroidPlatformIntegration(static_cast(QGuiApplicationPrivate::platformIntegration())); +} + QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶mList) : m_touchDevice(nullptr) #ifndef QT_NO_ACCESSIBILITY @@ -147,7 +151,6 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); m_mainThread = QThread::currentThread(); - QtAndroid::setAndroidPlatformIntegration(this); m_androidFDB = new QAndroidPlatformFontDatabase(); m_androidPlatformServices = new QAndroidPlatformServices(); @@ -210,7 +213,9 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ } } - QGuiApplicationPrivate::instance()->setApplicationState(m_defaultApplicationState); + // We can't safely notify the jni bridge that we're up and running just yet, so let's postpone + // it for now. + QCoreApplication::postEvent(m_androidPlatformNativeInterface, new QEvent(QEvent::User)); } static bool needsBasicRenderloopWorkaround() diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index 2337801250..208bb705b7 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -65,6 +65,9 @@ class QAndroidPlatformNativeInterface: public QPlatformNativeInterface public: void *nativeResourceForIntegration(const QByteArray &resource) override; std::shared_ptr m_androidStyle; + +protected: + void customEvent(QEvent *event) override; }; class QAndroidPlatformIntegration : public QPlatformIntegration @@ -121,7 +124,6 @@ public: QTouchDevice *touchDevice() const { return m_touchDevice; } void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; } - static void setDefaultApplicationState(Qt::ApplicationState applicationState) { m_defaultApplicationState = applicationState; } private: EGLDisplay m_eglDisplay; @@ -140,9 +142,6 @@ private: static Qt::ScreenOrientation m_orientation; static Qt::ScreenOrientation m_nativeOrientation; - - static Qt::ApplicationState m_defaultApplicationState; - static bool m_showPasswordEnabled; QPlatformFontDatabase *m_androidFDB; diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index 97a1f30a35..424cfefc6c 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -96,11 +96,6 @@ void QAndroidPlatformWindow::setVisible(bool visible) QRect availableGeometry = screen()->availableGeometry(); if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) QPlatformWindow::setVisible(visible); - - // The Android Activity is activated before Qt is initialized, causing the application state to - // never be set to 'active'. We explicitly set this state when the first window becomes visible. - if (visible) - QtAndroid::setApplicationActive(); } void QAndroidPlatformWindow::setWindowState(Qt::WindowState state) -- cgit v1.2.3 From e893e657e5c976f96e7e627ca90531934129bf4b Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 28 Feb 2017 14:11:44 +0100 Subject: configure: fix detection of xcb extensions - Properly detect xcb-render and xkb features. a) when -qt-xcb, use bundled versions b) when -system-xcb, detect from system - Be consistent with other features (jpeg, png) in "enable"/"disable" field handling. - And move the "xkb" feature higer up in configure.json. It is an X11 extension, so keep them all together (instead of grouping it with libxkbcommon). Task-number: QTBUG-59064 Change-Id: I60f95fb37060b8abde4c611cdef178ba3795982c Reviewed-by: Oswald Buddenhagen --- src/gui/configure.json | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gui/configure.json b/src/gui/configure.json index 88c9858a34..1c4a499298 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -224,7 +224,7 @@ ] }, "xcb_syslibs": { - "label": "XCB (secondary)", + "label": "XCB (extensions)", "test": "qpa/xcb-syslibs", "sources": [ { "type": "pkgConfig", @@ -701,11 +701,11 @@ "output": [ "privateFeature" ] }, "system-xcb": { - "label": "Using system provided XCB libraries", - "enable": "input.xcb == 'system' || input.xcb == 'yes'", - "disable": "input.xcb == 'qt' || input.xcb == 'no'", + "label": "Using system-provided XCB libraries", + "enable": "input.xcb == 'system'", + "disable": "input.xcb == 'qt'", "autoDetect": "!config.darwin", - "condition": "libs.xcb && libs.xcb_syslibs", + "condition": "features.xcb && libs.xcb_syslibs", "output": [ "privateFeature" ] }, "x11-prefix": { @@ -721,8 +721,14 @@ }, "xcb-render": { "label": "XCB render", - "emitIf": "features.system-xcb", - "condition": "libs.xcb_render", + "emitIf": "features.xcb", + "condition": "!features.system-xcb || libs.xcb_render", + "output": [ "privateFeature" ] + }, + "xkb": { + "label": "XCB XKB", + "emitIf": "features.xcb", + "condition": "!features.system-xcb || libs.xcb_xkb", "output": [ "privateFeature" ] }, "xcb-xlib": { @@ -739,6 +745,7 @@ }, "xinput2": { "label": "Xinput2", + "emitIf": "features.xcb", "condition": "libs.xinput2", "output": [ "privateFeature" ] }, @@ -755,11 +762,6 @@ "condition": "libs.xkbcommon_x11", "output": [ "privateFeature" ] }, - "xkb": { - "label": "XCB XKB", - "condition": "features.system-xcb && libs.xcb_xkb", - "output": [ "privateFeature" ] - }, "xkb-config-root": { "label": "XKB config root", "emitIf": "features.xcb", -- cgit v1.2.3 From 6ef07e09024613b8df4b2dae7ffe738f5e1998ac Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 10 Apr 2017 16:44:18 +0200 Subject: Qt5DBusMacros: remove intermediate variable This has been there probably forever, likely from the time when the code was derived from upstream CMake. Since this is just copying one variable to another and the latter has a wrong name (_qt4_*) just drop it. Change-Id: Ica74f3bc9a6b0a6669d80cfc0ebafc003f5b908e Reviewed-by: Kevin Funk Reviewed-by: David Faure Reviewed-by: Oswald Buddenhagen --- src/dbus/Qt5DBusMacros.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/dbus/Qt5DBusMacros.cmake b/src/dbus/Qt5DBusMacros.cmake index 2364c6710c..ef3eb73276 100644 --- a/src/dbus/Qt5DBusMacros.cmake +++ b/src/dbus/Qt5DBusMacros.cmake @@ -92,7 +92,6 @@ function(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -optio cmake_parse_arguments(_DBUS_INTERFACE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(_customName ${_DBUS_INTERFACE_UNPARSED_ARGUMENTS}) - set(_qt4_dbus_options ${_DBUS_INTERFACE_OPTIONS}) get_filename_component(_in_file ${_header} ABSOLUTE) get_filename_component(_basename ${_header} NAME_WE) @@ -112,7 +111,7 @@ function(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -optio endif() add_custom_command(OUTPUT ${_target} - COMMAND ${Qt5DBus_QDBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target} + COMMAND ${Qt5DBus_QDBUSCPP2XML_EXECUTABLE} ${_DBUS_INTERFACE_OPTIONS} ${_in_file} -o ${_target} DEPENDS ${_in_file} VERBATIM ) endfunction() -- cgit v1.2.3 From 31273f079eb1431a3f51bef5c390a1c15cbe382c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 3 Apr 2017 19:07:43 +0200 Subject: macOS: Don't marshal app font data via URL when using FreeType font engine Font descriptors can have attached attributes of any kind, not just pre- defined constants like kCTFontURLAttribute. We take advantage of this and attach the font data that was passed into addApplicationFont() to the font descriptor, so we can read it out directly when later creating an engine for it. This removes the need to build up a URL to represent the font data, which also didn't work for the memory-font use-case. The FreeType font engine now passes the same tst_QFontDatabase tests on macOS as the native CoreText font engine. This also fixes the leak caused by CTFontCreateWithGraphicsFont never releasing the graphics font, resulting in releaseFontData never being called: http://stackoverflow.com/questions/40805382/ We're now cleaning up the font data in releaseHandle, based on the attribute set on the font descriptor. Change-Id: Iba15222ec919f989e29fd98b263d9fb182c4d710 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 101 +++++++-------------- .../fontdatabases/mac/qcoretextfontdatabase_p.h | 3 - 2 files changed, 33 insertions(+), 71 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index d0b28b856b..1862900d48 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -354,9 +354,22 @@ void QCoreTextFontDatabase::populateFromDescriptor(CTFontDescriptorRef font, con fd.pixelSize, fd.fixedPitch, fd.writingSystems, (void *) font); } +static NSString * const kQtFontDataAttribute = @"QtFontDataAttribute"; + +template +T *descriptorAttribute(CTFontDescriptorRef descriptor, CFStringRef name) +{ + return [static_cast(CTFontDescriptorCopyAttribute(descriptor, name)) autorelease]; +} + void QCoreTextFontDatabase::releaseHandle(void *handle) { - CFRelease(CTFontDescriptorRef(handle)); + CTFontDescriptorRef descriptor = static_cast(handle); + if (NSValue *fontDataValue = descriptorAttribute(descriptor, (CFStringRef)kQtFontDataAttribute)) { + QByteArray *fontData = static_cast(fontDataValue.pointerValue); + delete fontData; + } + CFRelease(descriptor); } extern CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef); @@ -391,30 +404,21 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory::fontEngine(const { CTFontDescriptorRef descriptor = static_cast(usrPtr); - QByteArray filename; - if (NSURL *url = [static_cast(CTFontDescriptorCopyAttribute(descriptor, kCTFontURLAttribute)) autorelease]) { - if ([url.scheme isEqual:@"qrc"]) - filename = ":"; - else if (!url.fileURL) - qWarning() << "QFontDatabase: Unknown scheme" << url.scheme << "in font descriptor URL"; + if (NSURL *url = descriptorAttribute(descriptor, kCTFontURLAttribute)) { + Q_ASSERT(url.fileURL); + QFontEngine::FaceId faceId; + faceId.filename = QString::fromNSString(url.path).toUtf8(); + return QFontEngineFT::create(fontDef, faceId); - filename += QString::fromNSString(url.path).toUtf8(); + } else if (NSValue *fontDataValue = descriptorAttribute(descriptor, (CFStringRef)kQtFontDataAttribute)) { + QByteArray *fontData = static_cast(fontDataValue.pointerValue); + return QFontEngineFT::create(*fontData, fontDef.pixelSize, + static_cast(fontDef.hintingPreference)); } - Q_ASSERT(!filename.isEmpty()); - - QFontEngine::FaceId faceId; - faceId.filename = filename; - return QFontEngineFT::create(fontDef, faceId); + Q_UNREACHABLE(); } #endif -static void releaseFontData(void* info, const void* data, size_t size) -{ - Q_UNUSED(data); - Q_UNUSED(size); - delete (QByteArray*)info; -} - template <> QFontEngine *QCoreTextFontDatabaseEngineFactory::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) { @@ -580,59 +584,20 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo return fallbackLists[styleLookupKey.arg(styleHint)]; } -template <> -CFArrayRef QCoreTextFontDatabaseEngineFactory::createDescriptorArrayForDescriptor(CTFontDescriptorRef descriptor, const QString &fileName) -{ - Q_UNUSED(fileName) - CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); - CFArrayAppendValue(array, descriptor); - return array; -} - -#ifndef QT_NO_FREETYPE -template <> -CFArrayRef QCoreTextFontDatabaseEngineFactory::createDescriptorArrayForDescriptor(CTFontDescriptorRef descriptor, const QString &fileName) -{ - CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); - - // The physical font source URL (usually a local file or Qt resource) is only required for - // FreeType, when using non-system fonts, and needs some hackery to attach in a format - // agreeable to OSX. - if (!fileName.isEmpty()) { - QCFType fontURL; - - if (fileName.startsWith(QLatin1String(":/"))) { - // QUrl::fromLocalFile() doesn't accept qrc pseudo-paths like ":/fonts/myfont.ttf". - // Therefore construct from QString with the qrc:// scheme -> "qrc:///fonts/myfont.ttf". - fontURL = QUrl(QStringLiteral("qrc://") + fileName.mid(1)).toCFURL(); - } else { - // At this point we hope that filename is in a format that QUrl can handle. - fontURL = QUrl::fromLocalFile(fileName).toCFURL(); - } - - QCFType attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, - &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryAddValue(attributes, kCTFontURLAttribute, fontURL); - descriptor = CTFontDescriptorCreateCopyWithAttributes(descriptor, attributes); - } - - CFArrayAppendValue(array, descriptor); - return array; -} -#endif - QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) { QCFType fonts; if (!fontData.isEmpty()) { - QByteArray* fontDataCopy = new QByteArray(fontData); - QCFType dataProvider = CGDataProviderCreateWithData(fontDataCopy, - fontDataCopy->constData(), fontDataCopy->size(), releaseFontData); - if (QCFType cgFont = CGFontCreateWithDataProvider(dataProvider)) { - QCFType ctFont = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL); - QCFType descriptor = CTFontCopyFontDescriptor(ctFont); - fonts = createDescriptorArrayForDescriptor(descriptor, fileName); + QCFType fontDataReference = fontData.toRawCFData(); + if (QCFType descriptor = CTFontManagerCreateFontDescriptorFromData(fontDataReference)) { + // There's no way to get the data back out of a font descriptor created with + // CTFontManagerCreateFontDescriptorFromData, so we attach the data manually. + NSDictionary *attributes = @{ kQtFontDataAttribute : [NSValue valueWithPointer:new QByteArray(fontData)] }; + descriptor = CTFontDescriptorCreateCopyWithAttributes(descriptor, (CFDictionaryRef)attributes); + CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); + CFArrayAppendValue(array, descriptor); + fonts = array; } } else { QCFType fontURL = QUrl::fromLocalFile(fileName).toCFURL(); diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index 11ea0bea02..a7529b7fb0 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -91,7 +91,6 @@ public: private: void populateFromDescriptor(CTFontDescriptorRef font, const QString &familyName = QString()); - virtual CFArrayRef createDescriptorArrayForDescriptor(CTFontDescriptorRef descriptor, const QString &fileName) = 0; mutable QString defaultFontName; @@ -108,8 +107,6 @@ class QCoreTextFontDatabaseEngineFactory : public QCoreTextFontDatabase public: QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) override; QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) override; -protected: - CFArrayRef createDescriptorArrayForDescriptor(CTFontDescriptorRef descriptor, const QString &fileName) override; }; QT_END_NAMESPACE -- cgit v1.2.3 From f9226217d1b653e7786f8b920f6b36bfd4bd0512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 5 Apr 2017 13:35:11 +0200 Subject: macOS: Prevent leaking font data when creating QRawFont from QByteArrays CTFontCreateWithGraphicsFont has a bug causing it to never release the graphics font, which cascades down to the data provider never being released and releaseFontData never being called. Instead of relying on a callback to release the byte array font data, we attach the font data to the engine's lifetime. Note that we are still leaking the CoreFoundation types. Change-Id: I6eda4212638ccc9439b90e004222272d204c707a Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 33 ++++--------------- .../fontdatabases/mac/qfontengine_coretext.mm | 37 ++++++++++++++++++++++ .../fontdatabases/mac/qfontengine_coretext_p.h | 2 ++ 3 files changed, 45 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 1862900d48..3b9a456be0 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -419,37 +419,16 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory::fontEngine(const } #endif -template <> -QFontEngine *QCoreTextFontDatabaseEngineFactory::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) +template +QFontEngine *QCoreTextFontDatabaseEngineFactory::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) { - Q_UNUSED(hintingPreference); - - QByteArray* fontDataCopy = new QByteArray(fontData); - QCFType dataProvider = CGDataProviderCreateWithData(fontDataCopy, - fontDataCopy->constData(), fontDataCopy->size(), releaseFontData); - - CGFontRef cgFont = CGFontCreateWithDataProvider(dataProvider); - - QFontEngine *fontEngine = NULL; - if (cgFont == NULL) { - qWarning("QCoreTextFontDatabase::fontEngine: CGFontCreateWithDataProvider failed"); - } else { - QFontDef def; - def.pixelSize = pixelSize; - def.pointSize = pixelSize * 72.0 / qt_defaultDpi(); - fontEngine = new QCoreTextFontEngine(cgFont, def); - CFRelease(cgFont); - } - - return fontEngine; + return T::create(fontData, pixelSize, hintingPreference); } +// Explicitly instantiate so that we don't need the plugin to involve FreeType +template class QCoreTextFontDatabaseEngineFactory; #ifndef QT_NO_FREETYPE -template <> -QFontEngine *QCoreTextFontDatabaseEngineFactory::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) -{ - return QFontEngineFT::create(fontData, pixelSize, hintingPreference); -} +template class QCoreTextFontDatabaseEngineFactory; #endif QFont::StyleHint styleHintFromNSString(NSString *style) diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index c8ae342f16..49a6049c4b 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -177,6 +177,43 @@ CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef) return transform; } +// Keeps font data alive until engine is disposed +class QCoreTextRawFontEngine : public QCoreTextFontEngine +{ +public: + QCoreTextRawFontEngine(CGFontRef font, const QFontDef &def, const QByteArray &fontData) + : QCoreTextFontEngine(font, def) + , m_fontData(fontData) + {} + QByteArray m_fontData; +}; + +QCoreTextFontEngine *QCoreTextFontEngine::create(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) +{ + Q_UNUSED(hintingPreference); + + QCFType fontDataReference = fontData.toRawCFData(); + QCFType dataProvider = CGDataProviderCreateWithCFData(fontDataReference); + + // Note: CTFontCreateWithGraphicsFont (which we call from the QCoreTextFontEngine + // constructor) has a bug causing it to retain the CGFontRef but never release it. + // The result is that we are leaking the CGFont, CGDataProvider, and CGData, but + // as the CGData is created from the raw QByteArray data, which we deref in the + // subclass above during destruction, we're at least not leaking the font data, + // (unless CoreText copies it internally). http://stackoverflow.com/questions/40805382/ + QCFType cgFont = CGFontCreateWithDataProvider(dataProvider); + + if (!cgFont) { + qWarning("QCoreTextFontEngine::create: CGFontCreateWithDataProvider failed"); + return nullptr; + } + + QFontDef def; + def.pixelSize = pixelSize; + def.pointSize = pixelSize * 72.0 / qt_defaultDpi(); + return new QCoreTextRawFontEngine(cgFont, def, fontData); +} + QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def) : QFontEngine(Mac) { diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index 0074790e43..2986f0aaec 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -123,6 +123,8 @@ public: static int antialiasingThreshold; static QFontEngine::GlyphFormat defaultGlyphFormat; + + static QCoreTextFontEngine *create(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference); private: void init(); QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, bool colorful, const QTransform &m); -- cgit v1.2.3 From 1cd8c6f48e73b7fa12be0831c1218bc1767c4a81 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 11 Apr 2017 10:24:00 +0200 Subject: Make networkAccessibility() return the actual state of the network If networkAccessibility() was queried when the networkAccessibleChanged signal was emitted then it would report the wrong state and in some instances it would incorrectly report NotAccessible. This ensures that it is reflecting what the signal would have been emitted with. Change-Id: Ib0a7ef9e9ec42c9007340020fd535c8ad36caa49 Reviewed-by: Timur Pocheptsov --- src/network/access/qnetworkaccessmanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 018586f9dc..d898f93403 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1045,7 +1045,7 @@ QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccess { Q_D(const QNetworkAccessManager); - if (d->networkConfiguration.state().testFlag(QNetworkConfiguration::Undefined)) + if (d->customNetworkConfiguration && d->networkConfiguration.state().testFlag(QNetworkConfiguration::Undefined)) return UnknownAccessibility; if (d->networkSessionRequired) { @@ -1841,6 +1841,7 @@ void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession } else if (state == QNetworkSession::Connected || state == QNetworkSession::Roaming) { reallyOnline = true; } + online = reallyOnline; if (!reallyOnline) { if (state != QNetworkSession::Connected && state != QNetworkSession::Roaming) { @@ -1856,7 +1857,6 @@ void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession emit q->networkAccessibleChanged(networkAccessible); } } - online = reallyOnline; if (online && (state != QNetworkSession::Connected && state != QNetworkSession::Roaming)) { _q_networkSessionClosed(); createSession(q->configuration()); -- cgit v1.2.3 From cd5c8e78c70cbc68109e43720da6e515124bb9ab Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Tue, 11 Apr 2017 09:11:31 -0700 Subject: QProcess: fix Unix build This fixes a regression introduced in ff19ebcc Task-number: QTBUG-60046 Change-Id: I47c357433b25f07011a7a3a64d3150591785b206 Reviewed-by: Ulf Hermann --- src/corelib/io/qprocess_unix.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 795229419c..b822417ddf 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -121,6 +121,10 @@ QT_BEGIN_NAMESPACE #if !defined(Q_OS_DARWIN) +QT_BEGIN_INCLUDE_NAMESPACE +extern char **environ; +QT_END_INCLUDE_NAMESPACE + QProcessEnvironment QProcessEnvironment::systemEnvironment() { QProcessEnvironment env; -- cgit v1.2.3 From e45516ea0d41f215cddf1a51efe15998c74817a9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 11 Apr 2017 14:38:47 -0700 Subject: QSysInfo: Bring back suppression of ICC warning #1478 Turns out that different versions of ICC use different warning numbers. The Linux and Windows compilers emit 1786, but the macOS one emits 1478. Don't ask me why. Change-Id: I523b0abacd5148b2bf08fffd14b475a4c4d89ba1 Reviewed-by: Jake Petroules --- src/corelib/global/qsysinfo.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index ff0a784ace..f443ab4b93 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -213,6 +213,7 @@ public: QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") +QT_WARNING_DISABLE_INTEL(1478) QT_WARNING_DISABLE_INTEL(1786) QT_WARNING_DISABLE_MSVC(4996) #if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) -- cgit v1.2.3 From cdc5f47aeba94ba083a81dc681a09a351809e528 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 Apr 2017 21:11:12 -0700 Subject: Restore compatibility with Qt 5.7.0 and 5.6.1 QSysInfo::productType() returned "osx" for all versions of macOS, even 10.12. Change 3e2bde35786 was incorrect. [ChangeLog][Important Behavior Changes] QSysInfo::productType() and QFileSelector behavior on macOS was restored to match what Qt used to return in version 5.7.0 and earlier. The behavior found in Qt 5.6.2, 5.7.1 and 5.8.0 is removed. [ChangeLog][Future Compatibility Notice] The identifiers that QSysInfo::productType() and QFileSelector will use to identify macOS systems will change in Qt 6.0 to match the Apple naming guidelines which will be current then. Task-number: QTBUG-59849 Change-Id: Ib0e40a7a3ebc44329f23fffd14b2b39392210c4f Reviewed-by: Jake Petroules --- src/corelib/global/qglobal.cpp | 20 ++++++++++++-------- src/corelib/io/qfileselector.cpp | 10 +++++----- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 6b3cb502e5..9a779305d2 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2652,12 +2652,14 @@ QString QSysInfo::kernelVersion() to determine the distribution name and returns that. If determining the distribution name failed, it returns "unknown". - \b{Darwin, \macos, iOS, tvOS, and watchOS note}: this function returns - "macos" for \macos systems, "ios" for iOS systems, "tvos" for tvOS systems, - "watchos" for watchOS systems, and "darwin" in case the system could not - be determined. + \b{\macos note}: this function returns "osx" for all \macos systems, + regardless of Apple naming convention. The returned string will be updated + for Qt 6. Note that this function erroneously returned "macos" for \macos + 10.12 in Qt versions 5.6.2, 5.7.1, and 5.8.0. - \b{OS X note}: this function returns "osx" for versions of \macos prior to 10.12. + \b{Darwin, iOS, tvOS, and watchOS note}: this function returns "ios" for + iOS systems, "tvos" for tvOS systems, "watchos" for watchOS systems, and + "darwin" in case the system could not be determined. \b{FreeBSD note}: this function returns "debian" for Debian/kFreeBSD and "unknown" otherwise. @@ -2692,10 +2694,12 @@ QString QSysInfo::productType() #elif defined(Q_OS_WATCHOS) return QStringLiteral("watchos"); #elif defined(Q_OS_MACOS) - const QAppleOperatingSystemVersion version = qt_apple_os_version(); - if (version.major == 10 && version.minor < 12) - return QStringLiteral("osx"); + // ### Qt6: remove fallback +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return QStringLiteral("macos"); +# else + return QStringLiteral("osx"); +# endif #elif defined(Q_OS_DARWIN) return QStringLiteral("darwin"); diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index 920281cef7..22995db07d 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -366,6 +366,7 @@ void QFileSelectorPrivate::updateSelectors() QStringList QFileSelectorPrivate::platformSelectors() { // similar, but not identical to QSysInfo::osType + // ### Qt6: remove macOS fallbacks to "mac" and the future compatibility QStringList ret; #if defined(Q_OS_WIN) // can't fall back to QSysInfo because we need both "winphone" and "winrt" for the Windows Phone case @@ -387,12 +388,11 @@ QStringList QFileSelectorPrivate::platformSelectors() # endif # endif QString productName = QSysInfo::productType(); -# ifdef Q_OS_MACOS - if (productName != QLatin1String("osx")) - ret << QStringLiteral("osx"); // compatibility -# endif if (productName != QLatin1String("unknown")) - ret << productName; // "opensuse", "fedora", "macos", "ios", "android" + ret << productName; // "opensuse", "fedora", "osx", "ios", "android" +# if defined(Q_OS_MACOS) + ret << QStringLiteral("macos"); // future compatibility +# endif #endif return ret; } -- cgit v1.2.3 From 11ed95ac9c12ee2b20b5c6f6be68d0b6387c0e70 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 30 Mar 2017 19:13:58 +0200 Subject: Improve QStringBuilder docs - Mention you can build QByteArrays, too - Nicer list of types that can be used, separate for QByteArray and QString Change-Id: Ia91445f0cb4872bab12a55f4812c283e9c38dba4 Reviewed-by: Edward Welbourne Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qstringbuilder.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index de12de19cb..70152a9202 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE \reentrant \since 4.6 - \brief The QStringBuilder class is a template class that provides a facility to build up QStrings from smaller chunks. + \brief The QStringBuilder class is a template class that provides a facility to build up QStrings and QByteArrays from smaller chunks. \ingroup tools \ingroup shared @@ -58,22 +58,34 @@ QT_BEGIN_NAMESPACE To build a QString by multiple concatenations, QString::operator+() - is typically used. This causes \e{n - 1} reallocations when building - a string from \e{n} chunks. + is typically used. This causes \e{n - 1} allocations when building + a string from \e{n} chunks. The same is true for QByteArray. QStringBuilder uses expression templates to collect the individual chunks, compute the total size, allocate the required amount of - memory for the final QString object, and copy the chunks into the + memory for the final string object, and copy the chunks into the allocated memory. The QStringBuilder class is not to be used explicitly in user code. Instances of the class are created as return values of the - operator%() function, acting on objects of type QString, - QLatin1String, QStringRef, QChar, QCharRef, - QLatin1Char, and \c char. + operator%() function, acting on objects of the following types: + + For building QStrings: + + \li QString, QStringRef, + \li QChar, QCharRef, QLatin1Char, + \li QLatin1String, + \li QByteArray, \c char, \c{const char[]}. + + The types in the last list point are only available when + QT_NO_CAST_FROM_ASCII is not defined. + + For building QByteArrays: + + \li QByteArray, \c char, \c{const char[]}. Concatenating strings with operator%() generally yields better - performance then using \c QString::operator+() on the same chunks + performance than using \c QString::operator+() on the same chunks if there are three or more of them, and performs equally well in other cases. -- cgit v1.2.3 From bdd5a67e6543aa4159ab4aa4b466baa453b622aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Mon, 9 May 2016 20:01:36 +0200 Subject: QtWidgets: Don't open submenus when mouse is moving between actions Don't set the current action during closing submenu when mouse moved more than one action in the menu to the top or to the bottom. Task-number: QTBUG-53215 Change-Id: I2383363bc48f644df046198662dfa4d080fe3f1d Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qmenu.cpp | 10 +++++++--- src/widgets/widgets/qmenu_p.h | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 1925b58326..6da56c926c 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -632,6 +632,7 @@ void QMenuSloppyState::reset() m_enabled = false; m_first_mouse = true; m_init_guard = false; + m_use_reset_action = true; m_uni_dir_discarded_count = 0; m_time.stop(); m_reset_action = Q_NULLPTR; @@ -684,6 +685,7 @@ void QMenuSloppyState::setSubMenuPopup(const QRect &actionRect, QAction *resetAc { m_enabled = true; m_init_guard = true; + m_use_reset_action = true; m_time.stop(); m_action_rect = actionRect; m_sub_menu = subMenu; @@ -744,10 +746,12 @@ void QMenuSloppyState::timeout() if (m_sub_menu) menu_priv->hideMenu(m_sub_menu); - if (reallyHasMouse) - menu_priv->setCurrentAction(m_reset_action,0); - else + if (reallyHasMouse) { + if (m_use_reset_action) + menu_priv->setCurrentAction(m_reset_action, 0); + } else { menu_priv->setCurrentAction(Q_NULLPTR, 0); + } } //return the top causedPopup.widget that is not a QMenu diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 898fa3161b..0bce269831 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -95,6 +95,7 @@ public: , m_select_other_actions(false) , m_first_mouse(true) , m_init_guard(false) + , m_use_reset_action(true) , m_uni_dir_discarded_count(0) , m_uni_dir_fail_at_count(0) , m_timeout(0) @@ -182,9 +183,17 @@ public: QSetValueOnDestroy setFirstMouse(m_first_mouse, false); QSetValueOnDestroy setPreviousPoint(m_previous_point, mousePos); - if (resetAction && resetAction->isSeparator()) + if (resetAction && resetAction->isSeparator()) { m_reset_action = Q_NULLPTR; - else { + m_use_reset_action = true; + } else if (m_reset_action != resetAction) { + if (m_use_reset_action && resetAction) { + const QList actions = m_menu->actions(); + const int resetIdx = actions.indexOf(resetAction); + const int originIdx = actions.indexOf(m_origin_action); + if (resetIdx > -1 && originIdx > -1 && qAbs(resetIdx - originIdx) > 1) + m_use_reset_action = false; + } m_reset_action = resetAction; } @@ -249,6 +258,7 @@ private: bool m_init_guard; bool m_discard_state_when_entering_parent; bool m_dont_start_time_on_leave; + bool m_use_reset_action; short m_uni_dir_discarded_count; short m_uni_dir_fail_at_count; short m_timeout; -- cgit v1.2.3 From 59d4cbca0b232814b736b7543ddecd5e5db40c29 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 12 Apr 2017 09:35:52 +0200 Subject: QWindowsFontEngineDirectWrite: Fix build with MinGW In member function 'void tn::QWindowsFontEngineDirectWrite::collectMetrics()': windows\qwindowsfontenginedirectwrite.cpp:361:22: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] if (table.size() >= advanceWidthMaxLocation + sizeof(quint16)) { ^ Amends 17fc188aec5806167d3c6165b0ad299a8d2a6bcf. Task-number: QTBUG-58954 Change-Id: Ice2ff135d411b55d32290069b3c85ca0b5ea09af Reviewed-by: Simon Hausmann --- .../fontdatabases/windows/qwindowsfontenginedirectwrite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index 6f2755a05a..f07e711048 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -358,7 +358,7 @@ void QWindowsFontEngineDirectWrite::collectMetrics() QByteArray table = getSfntTable(MAKE_TAG('h', 'h', 'e', 'a')); const int advanceWidthMaxLocation = 10; - if (table.size() >= advanceWidthMaxLocation + sizeof(quint16)) { + if (table.size() >= advanceWidthMaxLocation + int(sizeof(quint16))) { quint16 advanceWidthMax = qFromBigEndian(table.constData() + advanceWidthMaxLocation); m_maxAdvanceWidth = DESIGN_TO_LOGICAL(advanceWidthMax); } -- cgit v1.2.3 From 7f29367c09d069958e0e9fb539ee88df04877b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 10 Apr 2017 21:07:11 +0200 Subject: Prevent QWindow transient parent loop Clients may wrongly set the transient parent to the window itself, causing endless loop when e.g. looking for the top level parent. Change-Id: Ib23cae3a5576320435ae9b76dd618d1e5ae08b5d Reviewed-by: Shawn Rutledge --- src/gui/kernel/qwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index d44bfabc04..c7afcce874 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1279,6 +1279,10 @@ void QWindow::setTransientParent(QWindow *parent) qWarning() << parent << "must be a top level window."; return; } + if (parent == this) { + qWarning() << "transient parent" << parent << "can not be same as window"; + return; + } d->transientParent = parent; -- cgit v1.2.3 From b727f11c2e4e8d4dd9dbd512f34ce7f95fd077fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 17 Jan 2017 15:49:07 +0100 Subject: QFontconfigDatabase: properly parse desktop environment variable $XDG_CURRENT_DESKTOP is defined as a colon-separated list of desktop strings, thus we can't check for equality, but split it and check if it contains the desktop environments we care about. Change-Id: Ia9ab0f28654a3e1a68b918794a079f3974f85642 Reviewed-by: Shawn Rutledge Reviewed-by: Dmitry Shachnev --- .../fontdatabases/fontconfig/qfontconfigdatabase.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 2c5ce3e87d..98dce03ae6 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -900,7 +900,13 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef bool forcedAntialiasSetting = !antialias; const QPlatformServices *services = QGuiApplicationPrivate::platformIntegration()->services(); - bool useXftConf = (services && (services->desktopEnvironment() == "GNOME" || services->desktopEnvironment() == "UNITY")); + bool useXftConf = false; + + if (services) { + const QList desktopEnv = services->desktopEnvironment().split(':'); + useXftConf = desktopEnv.contains("GNOME") || desktopEnv.contains("UNITY"); + } + if (useXftConf && !forcedAntialiasSetting) { void *antialiasResource = QGuiApplication::platformNativeInterface()->nativeResourceForScreen("antialiasingEnabled", -- cgit v1.2.3 From feaaca456b1b9f5f6ba84f0aa3cb7e93dfb862cf Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 12 Apr 2017 14:12:10 +0100 Subject: QLocale: do not test for Q_OS_MAC before including qglobal.h Found by clazy. Change-Id: I66b6698c309720891db83626e18c5e1baca19091 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index c183224c82..c23c84534f 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -38,13 +38,13 @@ ** ****************************************************************************/ +#include "qglobal.h" + #if !defined(QWS) && defined(Q_OS_MAC) # include "private/qcore_mac_p.h" # include #endif -#include "qglobal.h" - #include "qplatformdefs.h" #include "qdatastream.h" -- cgit v1.2.3 From 98e0cb0a28845fd6b808c25d2e049f8da1f9867c Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Thu, 19 Jan 2017 11:36:59 +0100 Subject: Doc: updated QSyntaxHighlighter documentation and use QRegularExpression The documentation of QSyntaxHighlighter still uses the deprecated QRegExp class. This patch updates the code samples as well as cleanup some typos. Change-Id: I87b525fddb560b7c5bb38f96d9aaceadb594f76c Reviewed-by: Sze Howe Koh --- src/gui/text/qsyntaxhighlighter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 8834afc80e..fcda17605f 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -292,7 +292,7 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block) /*! Constructs a QSyntaxHighlighter with the given \a parent. - If the parent is a QTextEdit, it installs the syntaxhighlighter on the + If the parent is a QTextEdit, it installs the syntax highlighter on the parents document. The specified QTextEdit also becomes the owner of the QSyntaxHighlighter. */ -- cgit v1.2.3 From e7443b88fcc110ab187de09443118f087c513776 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 11 Apr 2017 17:32:18 -0700 Subject: bootstrap: Remove redundant occurrence of qcore_foundation.mm Already added in the "mac" clause. Change-Id: I272882347cb65ef32e5aae7b1eee9f15cede6fcb Reviewed-by: Jake Petroules Reviewed-by: Oswald Buddenhagen --- src/tools/bootstrap/bootstrap.pro | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 507b5260cd..521dd5f0f2 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -120,7 +120,6 @@ mac { macx { OBJECTIVE_SOURCES += \ - ../../corelib/kernel/qcore_foundation.mm \ ../../corelib/io/qstandardpaths_mac.mm } else:unix { SOURCES += \ -- cgit v1.2.3 From fbcdf6d7532d62e4e11deda1b6e6aa8f4b9aebaa Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Wed, 12 Apr 2017 17:08:18 -0700 Subject: Be more explicit about the supported platforms for OpenGL ES 2 The OpenGLES framework is only supported on iOS and tvOS, and does not exist on macOS and watchOS. Change-Id: I643d3bdac522b67a8d945648dfcc8f1780ab0d7f Reviewed-by: Gabriel de Dietrich --- src/gui/opengl/qopengl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopengl.h b/src/gui/opengl/qopengl.h index a76da20910..b5df68a3aa 100644 --- a/src/gui/opengl/qopengl.h +++ b/src/gui/opengl/qopengl.h @@ -49,7 +49,7 @@ # include #endif -// Note: Mac OSX is a "controlled platform" for OpenGL ABI so we +// Note: Apple is a "controlled platform" for OpenGL ABI so we // use the system provided headers there. Controlled means that the // headers always match the actual driver implementation so there // is no possibility of drivers exposing additional functionality @@ -64,7 +64,7 @@ // which the system headers do not. #if defined(QT_OPENGL_ES_2) -# if defined(Q_OS_MAC) // iOS +# if defined(Q_OS_IOS) || defined(Q_OS_TVOS) # if defined(QT_OPENGL_ES_3) # include # include @@ -81,7 +81,7 @@ */ typedef void* GLeglImageOES; -# else // "uncontrolled" ES2 platforms +# elif !defined(Q_OS_DARWIN) // "uncontrolled" ES2 platforms // In "es2" builds (QT_OPENGL_ES_2) additional defines indicate GLES 3.0 or // higher is available *at build time*. In this case include the corresponding -- cgit v1.2.3 From eca6f5492c4f32ad4e1df25ab923401dc5980c76 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 12 Apr 2017 09:47:20 +0200 Subject: Windows QPA: Move initialization of resources out of the Qt namespace Q_INIT_RESOURCE() should not be within the Qt namespace; the namespace is appended to the resource function. Task-number: QTBUG-60118 Change-Id: I05203c3196ccdcffaf27658bcd7f3ec1c25f22d9 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsintegration.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 316f93e3ac..31062b681d 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -88,6 +88,11 @@ #include "qwindowsopengltester.h" +static inline void initOpenGlBlacklistResources() +{ + Q_INIT_RESOURCE(openglblacklists); +} + QT_BEGIN_NAMESPACE /*! @@ -210,7 +215,7 @@ static inline unsigned parseOptions(const QStringList ¶mList, QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mList) { - Q_INIT_RESOURCE(openglblacklists); + initOpenGlBlacklistResources(); static bool dpiAwarenessSet = false; int tabletAbsoluteRange = -1; -- cgit v1.2.3 From 5662234afaf23d88e1f3fa4bee2a59b61bd0c267 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 14 Apr 2017 12:39:20 +0200 Subject: QMatrix4x4: fix aliasing problem in operator*= When multiplying a QMatrix4x4 by itself, we were clobbering the very matrix we read from. Employ read-caching to avoid this aliasing problem. [ChangeLog][QtGui][QMatrix4x4] operator*=() now calculates the correct result even if the RHS and LHS are the same object. Change-Id: I8534d56cfdd62c336577125127f05173fcec2873 Reviewed-by: Sean Harmer --- src/gui/math3d/qmatrix4x4.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index aca685920e..4db96d07c0 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -423,8 +423,9 @@ inline QMatrix4x4& QMatrix4x4::operator-=(const QMatrix4x4& other) return *this; } -inline QMatrix4x4& QMatrix4x4::operator*=(const QMatrix4x4& other) +inline QMatrix4x4& QMatrix4x4::operator*=(const QMatrix4x4& o) { + const QMatrix4x4 other = o; // prevent aliasing when &o == this ### Qt 6: take o by value flagBits |= other.flagBits; if (flagBits < Rotation2D) { -- cgit v1.2.3 From e1c8451ffeeaa82f29aa2519addfa377f678ed9e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 9 Apr 2017 08:41:51 +0200 Subject: =?UTF-8?q?QVariant:=20implement=20QByteArray=20=E2=86=94=20QUuid?= =?UTF-8?q?=20conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems like an obvious omission. [ChangeLog][QtCore][QVariant] Can now convert QUuid to and from QByteArray, not just QString. Change-Id: Ib56ae86ca0c27adaf1e095b6b85e64fe64ea8d18 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index bca3ac9582..e636c6fe52 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -649,6 +649,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QVariant::Bool: *ba = QByteArray(d->data.b ? "true" : "false"); break; + case QVariant::Uuid: + *ba = v_cast(d)->toByteArray(); + break; default: #ifndef QT_NO_QOBJECT { @@ -916,6 +919,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) case QVariant::String: *static_cast(result) = QUuid(*v_cast(d)); break; + case QVariant::ByteArray: + *static_cast(result) = QUuid(*v_cast(d)); + break; default: return false; } @@ -2527,7 +2533,7 @@ QRegularExpression QVariant::toRegularExpression() const \since 5.0 Returns the variant as a QUuid if the variant has type() - \l QMetaType::QUuid or \l QMetaType::QString; + \l QMetaType::QUuid, \l QMetaType::QByteArray or \l QMetaType::QString; otherwise returns a default-constructed QUuid. \sa canConvert(), convert() @@ -2875,7 +2881,8 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, /*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool - | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong, + | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong + | 1 << QVariant::Uuid, /*QBitArray*/ 0, @@ -2911,7 +2918,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*QEasingCurve*/ 0, -/*QUuid*/ 1 << QVariant::String +/*QUuid*/ 1 << QVariant::String | 1 << QVariant::ByteArray, }; static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix); @@ -2966,7 +2973,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \l QMetaType::UInt, \l QMetaType::ULongLong \row \li \l QMetaType::QByteArray \li \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, - \l QMetaType::UInt, \l QMetaType::ULongLong + \l QMetaType::UInt, \l QMetaType::ULongLong, \l QMetaType::QUuid \row \li \l QMetaType::QChar \li \l QMetaType::Bool, \l QMetaType::Int, \l QMetaType::UInt, \l QMetaType::LongLong, \l QMetaType::ULongLong \row \li \l QMetaType::QColor \li \l QMetaType::QString @@ -3006,7 +3013,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) \row \li \l QMetaType::ULongLong \li \l QMetaType::Bool, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt - \row \li \l QMetaType::QUuid \li \l QMetaType::QString + \row \li \l QMetaType::QUuid \li \l QMetaType::QByteArray, \l QMetaType::QString \endtable A QVariant containing a pointer to a type derived from QObject will also return true for this -- cgit v1.2.3 From eea585ad0bfb92947ae2d77f3bc6662121cec9a9 Mon Sep 17 00:00:00 2001 From: Dongmei Wang Date: Wed, 1 Feb 2017 20:43:00 -0800 Subject: QMenu: Fix margins related display issues Currently the contents margins and the menu paddings are not considered for calculating the menu size, the positions and the size of tear-off bar, scrollers and the positions of the menu items when scrolling the menu, which results in the following problems when valid contents margins and/or menu paddings are set: - The tear off area is displayed in a wrong position. The mouse events are not handled correctly in the tear off area. For example, when you click in the tear off area, the menu should be torn off but nothing happens - For a multi-column menu, the menu width is not calculated correctly - For a scrollable menu, - the menu width is not calculated correctly - the menu items are not displayed in correct positions - the scrollers are not displayed in correct positions - menu items are displayed on the area of borders and margins when scrolling the menu - the last menu item is not displayed above the bottom of the content area when scrolling the menu to the end. The changes are to fix the problems above. Change-Id: I7931e1088dff0029f2d4825e2aa34b4e32fdccd9 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qmenu.cpp | 78 +++++++++++++++++++++++++++++++------------ src/widgets/widgets/qmenu_p.h | 1 + 2 files changed, 58 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 2b10ae7261..f08f573391 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -267,9 +267,6 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const int lastVisibleAction = getLastVisibleAction(); - int max_column_width = 0, - dh = screen.height(), - y = 0; QStyle *style = q->style(); QStyleOption opt; opt.init(q); @@ -279,6 +276,10 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q); const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0; + const int base_y = vmargin + fw + topmargin + (scroll ? scroll->scrollOffset : 0) + tearoffHeight; + int max_column_width = 0; + int dh = screen.height(); + int y = base_y; //for compatibility now - will have to refactor this away tabWidth = 0; @@ -356,11 +357,12 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const max_column_width = qMax(max_column_width, sz.width()); //wrapping if (!scroll && - y+sz.height()+vmargin > dh - (deskFw * 2)) { + y + sz.height() + vmargin + bottommargin + fw > dh - (deskFw * 2)) { ncols++; - y = vmargin; + y = base_y; + } else { + y += sz.height(); } - y += sz.height(); //update the item actionRects[i] = QRect(0, 0, sz.width(), sz.height()); } @@ -372,9 +374,6 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const max_column_width = qMax(min_column_width, max_column_width); //calculate position - const int base_y = vmargin + fw + topmargin + - (scroll ? scroll->scrollOffset : 0) + - tearoffHeight; int x = hmargin + fw + leftmargin; y = base_y; @@ -383,7 +382,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const if (rect.isNull()) continue; if (!scroll && - y+rect.height() > dh - deskFw * 2) { + y + rect.height() + vmargin + bottommargin + fw > dh - deskFw * 2) { x += max_column_width + hmargin; y = base_y; } @@ -761,7 +760,7 @@ QWidget *QMenuPrivate::topCausedWidget() const QAction *QMenuPrivate::actionAt(QPoint p) const { - if (!q_func()->rect().contains(p)) //sanity check + if (!rect().contains(p)) //sanity check return 0; for(int i = 0; i < actionRects.count(); i++) { @@ -855,6 +854,19 @@ void QMenuPrivate::drawTearOff(QPainter *painter, const QRect &rect) q->style()->drawControl(QStyle::CE_MenuTearoff, &menuOpt, painter, q); } +QRect QMenuPrivate::rect() const +{ + Q_Q(const QMenu); + QStyle *style = q->style(); + QStyleOption opt(0); + opt.init(q); + const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q); + const int vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q); + const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); + return (q->rect().adjusted(hmargin + fw + leftmargin, vmargin + fw + topmargin, + -(hmargin + fw + rightmargin), -(vmargin + fw + bottommargin))); +} + QMenuPrivate::ScrollerTearOffItem::ScrollerTearOffItem(QMenuPrivate::ScrollerTearOffItem::Type type, QMenuPrivate *mPrivate, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), menuPrivate(mPrivate), scrollType(type) { @@ -989,7 +1001,9 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc } if (!(newScrollFlags & QMenuScroller::ScrollDown) && (scroll->scrollFlags & QMenuScroller::ScrollDown)) { - newOffset = q->height() - (saccum - newOffset) - fw*2 - vmargin; //last item at bottom + newOffset = q->height() - (saccum - newOffset) - fw*2 - vmargin - topmargin - bottommargin; //last item at bottom + if (tearoff) + newOffset -= q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q); } if (!(newScrollFlags & QMenuScroller::ScrollUp) && (scroll->scrollFlags & QMenuScroller::ScrollUp)) { @@ -1141,15 +1155,23 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) { Q_Q(QMenu); QPoint pos = q->mapFromGlobal(e->globalPos()); + + QStyle *style = q->style(); + QStyleOption opt(0); + opt.init(q); + const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q); + const int vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q); + const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q); + if (scroll && !activeMenu) { //let the scroller "steal" the event bool isScroll = false; if (pos.x() >= 0 && pos.x() < q->width()) { - for(int dir = QMenuScroller::ScrollUp; dir <= QMenuScroller::ScrollDown; dir = dir << 1) { + for (int dir = QMenuScroller::ScrollUp; dir <= QMenuScroller::ScrollDown; dir = dir << 1) { if (scroll->scrollFlags & dir) { if (dir == QMenuScroller::ScrollUp) - isScroll = (pos.y() <= scrollerHeight()); + isScroll = (pos.y() <= scrollerHeight() + fw + vmargin + topmargin); else if (dir == QMenuScroller::ScrollDown) - isScroll = (pos.y() >= q->height() - scrollerHeight()); + isScroll = (pos.y() >= q->height() - scrollerHeight() - fw - vmargin - bottommargin); if (isScroll) { scroll->scrollDirection = dir; break; @@ -1166,7 +1188,8 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) } if (tearoff) { //let the tear off thingie "steal" the event.. - QRect tearRect(0, 0, q->width(), q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q)); + QRect tearRect(leftmargin + hmargin + fw, topmargin + vmargin + fw, q->width() - fw * 2 - hmargin * 2 -leftmargin - rightmargin, + q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q)); if (scroll && scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) tearRect.translate(0, scrollerHeight()); q->update(tearRect); @@ -2615,21 +2638,28 @@ void QMenu::paintEvent(QPaintEvent *e) //calculate the scroll up / down rect const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); + const int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin,0, this); + const int vmargin = style()->pixelMetric(QStyle::PM_MenuVMargin, 0, this); + QRect scrollUpRect, scrollDownRect; + const int leftmargin = fw + hmargin + d->leftmargin; + const int topmargin = fw + vmargin + d->topmargin; + const int bottommargin = fw + vmargin + d->bottommargin; + const int contentWidth = width() - (fw + hmargin) * 2 - d->leftmargin - d->rightmargin; if (d->scroll) { if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) - scrollUpRect.setRect(fw, fw, width() - (fw * 2), d->scrollerHeight()); + scrollUpRect.setRect(leftmargin, topmargin, contentWidth, d->scrollerHeight()); if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown) - scrollDownRect.setRect(fw, height() - d->scrollerHeight() - fw, width() - (fw * 2), - d->scrollerHeight()); + scrollDownRect.setRect(leftmargin, height() - d->scrollerHeight() - bottommargin, + contentWidth, d->scrollerHeight()); } //calculate the tear off rect QRect tearOffRect; if (d->tearoff) { - tearOffRect.setRect(fw, fw, width() - (fw * 2), - style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); + tearOffRect.setRect(leftmargin, topmargin, contentWidth, + style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); if (d->scroll && d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) tearOffRect.translate(0, d->scrollerHeight()); } @@ -2646,6 +2676,12 @@ void QMenu::paintEvent(QPaintEvent *e) emptyArea -= QRegion(actionRect); QRect adjustedActionRect = actionRect; + if (!scrollUpTearOffRect.isEmpty() && adjustedActionRect.bottom() <= scrollUpTearOffRect.top()) + continue; + + if (!scrollDownRect.isEmpty() && adjustedActionRect.top() >= scrollDownRect.bottom()) + continue; + if (adjustedActionRect.intersects(scrollUpTearOffRect)) { if (adjustedActionRect.bottom() <= scrollUpTearOffRect.bottom()) continue; diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 898fa3161b..a160a2c7d4 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -463,6 +463,7 @@ public: void drawScroller(QPainter *painter, ScrollerTearOffItem::Type type, const QRect &rect); void drawTearOff(QPainter *painter, const QRect &rect); + QRect rect() const; }; #endif // QT_NO_MENU -- cgit v1.2.3 From ae6ef2e3ec2174b2253fd04e1d69b949d3130067 Mon Sep 17 00:00:00 2001 From: Dongmei Wang Date: Thu, 17 Nov 2016 14:00:30 -0800 Subject: QMenu: Fix torn-off menu display crash issue When tearing off either a non-scrollable multi-colume menu or a scrollable menu, displaying the torn-off menu crashes. The root cause is when the torn-off menu is created, the tear-off menu's style, margins and other attributes are not set to it. The patch is to ensure the torn-off menu has the same attributes as the tear-off menu does and set the torn-off menu with a correct menu size. Task-number: QTBUG-24815 Change-Id: Icea45f149ea8792671af4a62e62cad6ee01a1f95 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qmenu.cpp | 53 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index f08f573391..995a08e310 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -84,18 +84,38 @@ class QTornOffMenu : public QMenu Q_OBJECT class QTornOffMenuPrivate : public QMenuPrivate { - Q_DECLARE_PUBLIC(QMenu) + Q_DECLARE_PUBLIC(QTornOffMenu) public: - QTornOffMenuPrivate(QMenu *p) : causedMenu(p) { + QTornOffMenuPrivate(QMenu *p) : causedMenu(p), initialized(false) { tornoff = 1; causedPopup.widget = 0; - causedPopup.action = ((QTornOffMenu*)p)->d_func()->causedPopup.action; - causedStack = ((QTornOffMenu*)p)->d_func()->calcCausedStack(); + causedPopup.action = p->d_func()->causedPopup.action; + causedStack = p->d_func()->calcCausedStack(); + } + + void setMenuSize(const QSize &menuSize) { + Q_Q(QTornOffMenu); + QSize size = menuSize; + const QPoint p = (!initialized) ? causedMenu->pos() : q->pos(); + QRect screen = popupGeometry(QApplication::desktop()->screenNumber(p)); + const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q); + const int titleBarHeight = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, q); + if (scroll && (size.height() > screen.height() - titleBarHeight || size.width() > screen.width())) { + const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); + const int hmargin = q->style()->pixelMetric(QStyle::PM_MenuHMargin, 0, q); + scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown); + size.setWidth(qMin(actionRects.at(getLastVisibleAction()).right() + fw + hmargin + rightmargin + 1, screen.width())); + size.setHeight(screen.height() - desktopFrame * 2 - titleBarHeight); + } + q->setFixedSize(size); } + QVector > calcCausedStack() const Q_DECL_OVERRIDE { return causedStack; } QPointer causedMenu; QVector > causedStack; + bool initialized; }; + public: QTornOffMenu(QMenu *p) : QMenu(*(new QTornOffMenuPrivate(p))) { @@ -109,11 +129,20 @@ public: setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true); setWindowTitle(p->windowTitle()); setEnabled(p->isEnabled()); + setStyleSheet(p->styleSheet()); + if (style() != p->style()) + setStyle(p->style()); + int leftMargin, topMargin, rightMargin, bottomMargin; + p->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); + setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin); + setLayoutDirection(p->layoutDirection()); //QObject::connect(this, SIGNAL(triggered(QAction*)), this, SLOT(onTrigger(QAction*))); //QObject::connect(this, SIGNAL(hovered(QAction*)), this, SLOT(onHovered(QAction*))); QList items = p->actions(); for(int i = 0; i < items.count(); i++) addAction(items.at(i)); + d->setMenuSize(sizeHint()); + d->initialized = true; } void syncWithMenu(QMenu *menu, QActionEvent *act) { @@ -127,12 +156,17 @@ public: } void actionEvent(QActionEvent *e) Q_DECL_OVERRIDE { + Q_D(QTornOffMenu); QMenu::actionEvent(e); - setFixedSize(sizeHint()); + if (d->initialized) { + d->setMenuSize(sizeHint()); + } } + public slots: void onTrigger(QAction *action) { d_func()->activateAction(action, QAction::Trigger, false); } void onHovered(QAction *action) { d_func()->activateAction(action, QAction::Hover, false); } + private: Q_DECLARE_PRIVATE(QTornOffMenu) friend class QMenuPrivate; @@ -369,9 +403,11 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const } max_column_width += tabWidth; //finally add in the tab width - const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); - const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); - max_column_width = qMax(min_column_width, max_column_width); + if (!tornoff || (tornoff && scroll)) { // exclude non-scrollable tear-off menu since the tear-off menu has a fixed size + const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width(); + const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin)); + max_column_width = qMax(min_column_width, max_column_width); + } //calculate position int x = hmargin + fw + leftmargin; @@ -3512,7 +3548,6 @@ void QMenu::actionEvent(QActionEvent *e) } if (isVisible()) { - d->updateActionRects(); resize(sizeHint()); update(); } -- cgit v1.2.3 From d5d31c64a43093519fc7a22dd5f4c1c440e6953f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 11 Apr 2017 11:51:06 -0700 Subject: QSplitter::replaceWidget(): Add geometry related remark The late geometry update on the widget has been confusing some of our users. Change-Id: I7f2600322be0a0c54fac3beb42065413a0693f74 Reviewed-by: Friedemann Kleint Reviewed-by: Marc Mutz --- src/widgets/widgets/qsplitter.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index e92347c65c..1676c188a6 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -1145,6 +1145,10 @@ void QSplitter::insertWidget(int index, QWidget *widget) \note The splitter takes ownership of \a widget and sets the parent of the replaced widget to null. + \note Because \a widget gets \l{QWidget::setParent()}{reparented} into the splitter, + its \l{QWidget::}{geometry} may not be set right away, but only after \a widget will + receive the appropriate events. + \sa insertWidget(), indexOf() */ QWidget *QSplitter::replaceWidget(int index, QWidget *widget) -- cgit v1.2.3 From 89c8dd30a12bbe44f4661a1b4dd5aec079e41cae Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 13 Apr 2017 15:54:15 -0700 Subject: qfloat16: Fix GCC warning about use of old-style cast _mm_cvtps_ph is usually defined as a macro: qfloat16.h:122:37: error: use of old-style cast [-Werror=old-style-cast] Change-Id: Icd0e0d4b27cb4e5eb892fffd14b516ec47826c0c Reviewed-by: Ville Voutilainen Reviewed-by: Marc Mutz --- src/corelib/global/qfloat16.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 05b88e0e92..3b54719f4f 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -115,6 +115,7 @@ inline int qIntCast(qfloat16 f) Q_DECL_NOTHROW QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wc99-extensions") +QT_WARNING_DISABLE_GCC("-Wold-style-cast") inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW { #if defined(QT_COMPILER_SUPPORTS_F16C) && (defined(__F16C__) || defined(__AVX2__)) -- cgit v1.2.3 From 2814744a739dfab123448f92e2009c34a82976a3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 15 Apr 2017 15:56:47 -0700 Subject: Update the Clang usual versions for Apple's build Change-Id: Id69a70a52573241e1b6a05bd62a3fd01a8e78550 Reviewed-by: Jake Petroules --- src/corelib/global/qcompilerdetection.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index fcfe020509..3ceb4edab1 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -172,7 +172,11 @@ /* Clang also masquerades as GCC */ # if defined(__apple_build_version__) # /* http://en.wikipedia.org/wiki/Xcode#Toolchain_Versions */ -# if __apple_build_version__ >= 7000053 +# if __apple_build_version__ >= 8020041 +# define Q_CC_CLANG 309 +# elif __apple_build_version__ >= 8000038 +# define Q_CC_CLANG 308 +# elif __apple_build_version__ >= 7000053 # define Q_CC_CLANG 306 # elif __apple_build_version__ >= 6000051 # define Q_CC_CLANG 305 -- cgit v1.2.3 From 3bea9450e90a6c8db1554faa5b467186e63b31a0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 31 Oct 2016 16:07:53 -0700 Subject: Update the Clang support for SIMD code generation Clang 3.8 has support for __attribute__((target(xxx))) and its SIMD headers can be included unconditionally. Change-Id: Ic15b7ff417c8412893e5fffd14b5b42b950b48d7 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qsimd_p.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index d5d887598e..28253b3ae9 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -166,10 +166,11 @@ # define __MIPS_DSPR2__ # endif #elif (defined(Q_CC_INTEL) || defined(Q_CC_MSVC) \ - || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && (__GNUC__-0) * 100 + (__GNUC_MINOR__-0) >= 409)) \ + || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && Q_CC_GNU >= 409) \ + || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 308)) \ && !defined(QT_BOOTSTRAPPED) # define QT_COMPILER_SUPPORTS_SIMD_ALWAYS -# define QT_COMPILER_SUPPORTS_HERE(x) (__ ## x ## __) || QT_COMPILER_SUPPORTS(x) +# define QT_COMPILER_SUPPORTS_HERE(x) ((__ ## x ## __) || QT_COMPILER_SUPPORTS(x)) # if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) /* GCC requires attributes for a function */ # define QT_FUNCTION_TARGET(x) __attribute__((__target__(QT_FUNCTION_TARGET_STRING_ ## x))) -- cgit v1.2.3 From 34d2fd14979198dc0fcc07f73581ece9540c4b72 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 16 Apr 2017 15:28:59 -0700 Subject: Fix build with libdrm >= 2.4.78 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drmEventContext has grown by one pointer, so the build fails with an error about a member without initialization. qeglfskmsgbmdevice.cpp:147:5: error: missing initializer for member ‘_drmEventContext::page_flip_handler2’ [-Werror=missing-field-initializers] Change-Id: I0e1a09998253489388abfffd14b6014b1ddc90e1 Reviewed-by: Simon Hausmann --- .../eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp | 10 +++++----- src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp index 2040d6bc0e..5f85e4b0b0 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp @@ -140,11 +140,11 @@ void QEglFSKmsGbmDevice::destroyGlobalCursor() void QEglFSKmsGbmDevice::handleDrmEvent() { - drmEventContext drmEvent = { - DRM_EVENT_CONTEXT_VERSION, - Q_NULLPTR, // vblank handler - pageFlipHandler // page flip handler - }; + drmEventContext drmEvent; + memset(&drmEvent, 0, sizeof(drmEvent)); + drmEvent.version = DRM_EVENT_CONTEXT_VERSION; + drmEvent.vblank_handler = nullptr; + drmEvent.page_flip_handler = pageFlipHandler; drmHandleEvent(fd(), &drmEvent); } diff --git a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp index 2ca251c4af..c9fbb8281c 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp @@ -312,11 +312,11 @@ void QLinuxFbDevice::swapBuffers(Output *output) const int fbIdx = output->backFb; while (output->backFb == fbIdx) { - drmEventContext drmEvent = { - DRM_EVENT_CONTEXT_VERSION, - nullptr, - pageFlipHandler - }; + drmEventContext drmEvent; + memset(&drmEvent, 0, sizeof(drmEvent)); + drmEvent.version = DRM_EVENT_CONTEXT_VERSION; + drmEvent.vblank_handler = nullptr; + drmEvent.page_flip_handler = pageFlipHandler; // Blocks until there is something to read on the drm fd // and calls back pageFlipHandler once the flip completes. drmHandleEvent(fd(), &drmEvent); -- cgit v1.2.3 From d1210281e41008ce2e3510aa5cfb3ebea1c57734 Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Mon, 17 Apr 2017 00:35:38 +0300 Subject: Fix undefined behavior in QSharedPointer::create() Initialize a deleter for a new object, created by QSharedPointer::create(), only after the object is actually constructed. [ChangeLog][QtCore][QSharedPointer] Fixed undefined behavior when creating an object with QSharedPointer::create() and its conscructor throws an exception. Task-number: QTBUG-49824 Change-Id: I07f77a78ff468d9b45b8ef133278e8cdd96a0647 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qsharedpointer_impl.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 5738413bfb..373fc3a662 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -260,6 +260,7 @@ namespace QtSharedPointer { internalSafetyCheckRemove(self); deleter(self); } + static void noDeleter(ExternalRefCountData *) { } static inline ExternalRefCountData *create(T **ptr, DestroyerFn destroy) { @@ -433,11 +434,13 @@ public: # else typename Private::DestroyerFn destroy = &Private::deleter; # endif + typename Private::DestroyerFn noDestroy = &Private::noDeleter; QSharedPointer result(Qt::Uninitialized); - result.d = Private::create(&result.value, destroy); + result.d = Private::create(&result.value, noDestroy); // now initialize the data new (result.data()) T(std::forward(arguments)...); + result.d->destroyer = destroy; result.d->setQObjectShared(result.value, true); # ifdef QT_SHAREDPOINTER_TRACK_POINTERS internalSafetyCheckAdd(result.d, result.value); -- cgit v1.2.3 From 285789781cd2893302edfc004d8fc07fc06b1148 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 16 Apr 2017 20:29:39 -0700 Subject: icc: thread_local in macOS is working since 10.7 Change-Id: I0e1a09998253489388abfffd14b611b1403a0c9f Reviewed-by: Jake Petroules --- src/corelib/global/qcompilerdetection.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 3ceb4edab1..5497b9e14a 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -632,10 +632,7 @@ # define Q_COMPILER_ALIGNAS # define Q_COMPILER_ALIGNOF # define Q_COMPILER_INHERITING_CONSTRUCTORS -# ifndef Q_OS_OSX -// C++11 thread_local is broken on OS X (Clang doesn't support it either) -# define Q_COMPILER_THREAD_LOCAL -# endif +# define Q_COMPILER_THREAD_LOCAL # define Q_COMPILER_UDL # endif # ifdef _MSC_VER -- cgit v1.2.3 From bc5454d2c41873349ea32c42aca8fc794cba442e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 7 Apr 2017 10:08:37 +0200 Subject: Fix build error with -no-feature-slider Change-Id: Ia74aeefdba3ac6b831aeeaff40600e30d90183d8 Reviewed-by: Oswald Buddenhagen Reviewed-by: Tasuku Suzuki Reviewed-by: Lars Knoll --- src/widgets/styles/qfusionstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index c874b12e45..123aa351cd 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1956,10 +1956,10 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption #if QT_CONFIG(spinbox) || QT_CONFIG(slider) QColor buttonColor = d->buttonColor(option->palette); + QColor gradientStopColor = buttonColor; #endif #if QT_CONFIG(slider) QColor gradientStartColor = buttonColor.lighter(118); - QColor gradientStopColor = buttonColor; #endif QColor outline = d->outline(option->palette); -- cgit v1.2.3 From 46976eea1890a0094da421a6dc4ac1276cfccff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 3 Mar 2017 14:20:42 +0100 Subject: Add debug operators for font database structs for easier debugging Change-Id: Ice1b27ff93de2d369dc6b66c72a64eb05da5639c Reviewed-by: Simon Hausmann --- src/gui/text/qplatformfontdatabase.cpp | 21 +++++++++++++++++++++ src/gui/text/qplatformfontdatabase.h | 7 +++++++ .../fontdatabases/mac/qcoretextfontdatabase.mm | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+) (limited to 'src') diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index 599b18ac05..4ad826e87b 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -201,6 +202,26 @@ QSupportedWritingSystems &QSupportedWritingSystems::operator=(const QSupportedWr return *this; } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QSupportedWritingSystems &sws) +{ + QMetaObject mo = QFontDatabase::staticMetaObject; + QMetaEnum me = mo.enumerator(mo.indexOfEnumerator("WritingSystem")); + + QDebugStateSaver saver(debug); + debug.nospace() << "QSupportedWritingSystems("; + int i = sws.d->vector.indexOf(true); + while (i > 0) { + debug << me.valueToKey(i); + i = sws.d->vector.indexOf(true, i + 1); + if (i > 0) + debug << ", "; + } + debug << ")"; + return debug; +} +#endif + /*! Destroys the supported writing systems object. */ diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index 2d99183ca3..2ca783f0fd 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -84,11 +84,18 @@ private: friend Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &); friend Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); +#ifndef QT_NO_DEBUG_STREAM + friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &); +#endif }; Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &); Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &); +#ifndef QT_NO_DEBUG_STREAM +Q_GUI_EXPORT QDebug operator<<(QDebug, const QSupportedWritingSystems &); +#endif + class QFontRequestPrivate; class QFontEngineMulti; diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 3b9a456be0..d89a81be6b 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -251,6 +251,24 @@ struct FontDescription { QSupportedWritingSystems writingSystems; }; +#ifndef QT_NO_DEBUG_STREAM +Q_DECL_UNUSED static inline QDebug operator<<(QDebug debug, const FontDescription &fd) +{ + QDebugStateSaver saver(debug); + return debug.nospace() << "FontDescription(" + << "familyName=" << QString(fd.familyName) + << ", styleName=" << QString(fd.styleName) + << ", foundry=" << fd.foundryName + << ", weight=" << fd.weight + << ", style=" << fd.style + << ", stretch=" << fd.stretch + << ", pixelSize=" << fd.pixelSize + << ", fixedPitch=" << fd.fixedPitch + << ", writingSystems=" << fd.writingSystems + << ")"; +} +#endif + static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd) { QCFType styles = (CFDictionaryRef) CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute); -- cgit v1.2.3 From 28ea26e574a9142b6ccdb645dbf2e5fecffd1fcd Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Fri, 7 Apr 2017 14:41:00 +0200 Subject: Doc: rephrase parameter description to avoid qdoc error message Change-Id: I79d446289b4450d2fcce097cf46d2cf7b6d969da Reviewed-by: Venugopal Shivashankar --- src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc index 898b1bbb29..9061690681 100644 --- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc +++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc @@ -168,10 +168,10 @@ \fn bool QWindowsWindowFunctions::isTabletMode() This is a convenience function that can be used directly instead of resolving - the function pointer. The function can be used to query whether Windows 10 - operates in \e{Tablet Mode}. In this mode, Windows forces all application - main windows to open in maximized state. Applications should then avoid - resizing windows or restoring geometries to non-maximized states. + the function pointer. Returns true if Windows 10 operates in \e{Tablet Mode}. + In this mode, Windows forces all application main windows to open in maximized + state. Applications should then avoid resizing windows or restoring geometries + to non-maximized states. \sa QWidget::showMaximized(), QWidget::saveGeometry(), QWidget::restoreGeometry() \since 5.9 -- cgit v1.2.3 From f26be29ea8572c747a42ffe55df68dded21f1ecd Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Mon, 10 Apr 2017 13:39:21 +0200 Subject: Doc: add missing specs about parameters qopengltexture.cpp:3476: warning: Undocumented parameter 'layerCount' in QOpenGLTexture::setCompressedData() and QOpenGLTexture::setData() qimage.cpp:2127: warning: Undocumented parameter 'format' in QImage::reinterpretAsFormat() Change-Id: I17feb2256a29f3bb722d2de3a83b390abff85a35 Reviewed-by: Sean Harmer --- src/gui/image/qimage.cpp | 2 +- src/gui/opengl/qopengltexture.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index c1ea053204..23b05fa874 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2127,7 +2127,7 @@ QImage QImage::convertToFormat(Format format, const QVector &colorTable, Q /*! \since 5.9 - Changes the format of the image without changing the data. Only + Changes the \a format of the image without changing the data. Only works between formats of the same depth. Returns \c true if successful. diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 0831bfe706..766d4a327a 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -3302,6 +3302,9 @@ void QOpenGLTexture::setData(int mipLevel, int layer, CubeMapFace cubeFace, /*! \since 5.9 \overload + + Parameter \a layerCount is the number of layers in a texture array + that are being uploaded/populated by this call. */ void QOpenGLTexture::setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions * const options) { @@ -3476,6 +3479,9 @@ void QOpenGLTexture::setCompressedData(int mipLevel, int layer, CubeMapFace cube /*! \since 5.9 \overload + + Parameter \a layerCount is the number of layers in a texture array + that are being uploaded/populated by this call. */ void QOpenGLTexture::setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, int dataSize, const void *data, const QOpenGLPixelTransferOptions * const options) { -- cgit v1.2.3 From db2de20c59137eab15fac9592c001a4d234c82d4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 Apr 2017 14:21:33 +0200 Subject: QGraphicsColorizeEffect: Fix for high DPI scaling Preserve the device pixel ratio. Task-number: QTBUG-60026 Change-Id: I91a1bda6ce4defd064ec7edfcea40ff192a9068f Reviewed-by: Shawn Rutledge --- src/widgets/effects/qpixmapfilter.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp index 1ff4f8e88a..2a069d7529 100644 --- a/src/widgets/effects/qpixmapfilter.cpp +++ b/src/widgets/effects/qpixmapfilter.cpp @@ -1111,6 +1111,7 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); destImage = QImage(rect.size(), srcImage.format()); } + destImage.setDevicePixelRatio(src.devicePixelRatioF()); // do colorizing QPainter destPainter(&destImage); -- cgit v1.2.3 From 84fb8c5ec909fa29512236aed3a77f595a2ac891 Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Tue, 18 Apr 2017 13:21:26 +0200 Subject: Doc: Remove broken link to QWindowSystemInterface::registerTouchDevice() Mention that it is a private function. Also mention using QTest::createTouchDevice() for adding simulated touch screens to autotests. Task-number: QTBUG-26647 Change-Id: I08c12225768e76b1b9e3fc0fda00af86d44ca766 Reviewed-by: Shawn Rutledge Reviewed-by: Bo Thorsen Reviewed-by: Rainer Keller --- src/gui/doc/qtgui.qdocconf | 3 ++- src/gui/kernel/qtouchdevice.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf index 94574a314c..bac93af775 100644 --- a/src/gui/doc/qtgui.qdocconf +++ b/src/gui/doc/qtgui.qdocconf @@ -39,7 +39,8 @@ depends += \ qtquick \ qtwidgets \ qtdoc \ - qmake + qmake \ + qttestlib headerdirs += .. diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp index 97cc8d179d..0f13412fb1 100644 --- a/src/gui/kernel/qtouchdevice.cpp +++ b/src/gui/kernel/qtouchdevice.cpp @@ -215,7 +215,10 @@ static void cleanupDevicesList() /*! Returns a list of all registered devices. - \note The returned list cannot be used to add new devices. Use QWindowSystemInterface::registerTouchDevice() instead. + \note The returned list cannot be used to add new devices. To add a simulated + touch screen for an autotest, QTest::createTouchDevice() can be used. + To add real touch screens to QPA plugins, the private + \c QWindowSystemInterface::registerTouchDevice() function can be used. */ QList QTouchDevice::devices() { -- cgit v1.2.3 From 8b62673d9f0cf8aea126b3cd2f52686f013d7fe1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 Apr 2017 15:02:08 +0200 Subject: QGraphicsDropShadowEffect: Fix for high DPI scaling Preserve the device pixel ratio. Task-number: QTBUG-60026 Change-Id: Ie818c582fe2c7b11ceb347b39cfbf7ea49361021 Reviewed-by: Shawn Rutledge --- src/widgets/effects/qpixmapfilter.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp index 2a069d7529..bb949fcebf 100644 --- a/src/widgets/effects/qpixmapfilter.cpp +++ b/src/widgets/effects/qpixmapfilter.cpp @@ -1316,6 +1316,7 @@ void QPixmapDropShadowFilter::draw(QPainter *p, return; QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied); + tmp.setDevicePixelRatio(px.devicePixelRatioF()); tmp.fill(0); QPainter tmpPainter(&tmp); tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); @@ -1324,6 +1325,7 @@ void QPixmapDropShadowFilter::draw(QPainter *p, // blur the alpha channel QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied); + blurred.setDevicePixelRatio(px.devicePixelRatioF()); blurred.fill(0); QPainter blurPainter(&blurred); qt_blurImage(&blurPainter, tmp, d->radius, false, true); -- cgit v1.2.3 From fc2f0fb39008f95133f6fd24662fe92195431808 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 11 Apr 2017 12:13:51 +0200 Subject: Doc: add missing doc for parameters qhstspolicy.cpp:105: warning: Undocumented parameter 'flags' in QHstsPolicy::QHstsPolicy() qhstspolicy.cpp:105: warning: No such parameter 'includeSubDomains' in QHstsPolicy::QHstsPolicy() qnetworkaccessmanager.cpp:732: warning: Undocumented parameter 'knownHosts' in QNetworkAccessManager::addStrictTransportSecurityHosts() Change-Id: I24217d328df12febab30e19e2abd351e87007959 Reviewed-by: Frederik Gladhorn --- src/network/access/qhstspolicy.cpp | 8 ++++---- src/network/access/qnetworkaccessmanager.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/network/access/qhstspolicy.cpp b/src/network/access/qhstspolicy.cpp index 0ea9f3f046..ab4695480b 100644 --- a/src/network/access/qhstspolicy.cpp +++ b/src/network/access/qhstspolicy.cpp @@ -103,11 +103,11 @@ QHstsPolicy::QHstsPolicy() : d(new QHstsPolicyPrivate) } /*! - Constructs QHstsPolicy with \a expiry (in UTC); \a includeSubDomains parameter - defines if this policy must also include subdomains, \a host data is interpreted - according to \a mode. + Constructs QHstsPolicy with \a expiry (in UTC): + - \a host data is interpreted according to \a mode; + - \a flags selects options to apply to this policy. - \sa QUrl::setHost(), QUrl::ParsingMode + \sa QUrl::setHost(), QUrl::ParsingMode, QHstsPolicy::PolicyFlag */ QHstsPolicy::QHstsPolicy(const QDateTime &expiry, PolicyFlags flags, const QString &host, QUrl::ParsingMode mode) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index d898f93403..d57acc2f6b 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -739,7 +739,7 @@ bool QNetworkAccessManager::isStrictTransportSecurityEnabled() const \note While processing HTTP responses, QNetworkAccessManager can also update the HSTS cache, removing or updating exitsting policies or introducing new - known hosts. The current implementation thus is server-driven, client code + \a knownHosts. The current implementation thus is server-driven, client code can provide QNetworkAccessManager with previously known or discovered policies, but this information can be overridden by "Strict-Transport-Security" response headers. -- cgit v1.2.3 From 9595622e366fcbef6bcc3a2ee08597959e3e2bd2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 Apr 2017 14:47:46 +0200 Subject: QGraphicsBlurEffect: Fix for high DPI scaling Preserve the device pixel ratio in the various helper functions and when drawing. Task-number: QTBUG-60026 Change-Id: Ieac9360b00044b6aedd0d3e1ad6e3b16d436f20f Reviewed-by: Allan Sandfeld Jensen --- src/widgets/effects/qpixmapfilter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp index bb949fcebf..999e551af4 100644 --- a/src/widgets/effects/qpixmapfilter.cpp +++ b/src/widgets/effects/qpixmapfilter.cpp @@ -719,6 +719,7 @@ void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transp } QImage temp(img.height(), img.width(), img.format()); + temp.setDevicePixelRatio(img.devicePixelRatioF()); if (transposed >= 0) { if (img.depth() == 8) { qt_memrotate270(reinterpret_cast(img.bits()), @@ -780,6 +781,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) if (source.format() == QImage::Format_Indexed8 || source.format() == QImage::Format_Grayscale8) { // assumes grayscale QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); + dest.setDevicePixelRatio(source.devicePixelRatioF()); const uchar *src = reinterpret_cast(const_cast(srcImage).bits()); int sx = srcImage.bytesPerLine(); @@ -801,6 +803,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) return dest; } else if (source.format() == QImage::Format_ARGB8565_Premultiplied) { QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); + dest.setDevicePixelRatio(source.devicePixelRatioF()); const uchar *src = reinterpret_cast(const_cast(srcImage).bits()); int sx = srcImage.bytesPerLine(); @@ -837,6 +840,7 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) } QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); + dest.setDevicePixelRatio(source.devicePixelRatioF()); const quint32 *src = reinterpret_cast(const_cast(srcImage).bits()); int sx = srcImage.bytesPerLine() >> 2; @@ -881,7 +885,7 @@ Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, if (p) { p->scale(scale, scale); p->setRenderHint(QPainter::SmoothPixmapTransform); - p->drawImage(QRect(0, 0, blurImage.width(), blurImage.height()), blurImage); + p->drawImage(QRect(QPoint(0, 0), blurImage.size() / blurImage.devicePixelRatioF()), blurImage); } } -- cgit v1.2.3 From 47cc9e23a313d67a4a3107242f205d2473842021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 14 Apr 2017 15:13:28 +0200 Subject: Initialize QLoggingRegistry rules on first use, not qApp construction Allows categorized logging before QCoreApplication has been created, which otherwise would silently fail to output anything because the category would never be enabled, despite QT_LOGGING_RULES being set. Change-Id: Ia733105c5b6f28e22af511ced5271e45782da12b Reviewed-by: Thiago Macieira --- src/corelib/io/qloggingregistry.cpp | 1 + src/corelib/io/qloggingregistry_p.h | 3 +-- src/corelib/kernel/qcoreapplication.cpp | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 47fb1fb6b8..9a5c923323 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -255,6 +255,7 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) QLoggingRegistry::QLoggingRegistry() : categoryFilter(defaultCategoryFilter) { + init(); } static bool qtLoggingDebug() diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 69fc6ea4ec..768f3b4a91 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -113,8 +113,6 @@ class Q_AUTOTEST_EXPORT QLoggingRegistry public: QLoggingRegistry(); - void init(); - void registerCategory(QLoggingCategory *category, QtMsgType enableForLevel); void unregisterCategory(QLoggingCategory *category); @@ -126,6 +124,7 @@ public: static QLoggingRegistry *instance(); private: + void init(); void updateRules(); static void defaultCategoryFilter(QLoggingCategory *category); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e4b1562b8b..0216baa6c3 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -771,8 +771,6 @@ void QCoreApplicationPrivate::init() if (!coreappdata()->applicationVersionSet) coreappdata()->applicationVersion = appVersion(); - QLoggingRegistry::instance()->init(); - #if QT_CONFIG(library) // Reset the lib paths, so that they will be recomputed, taking the availability of argv[0] // into account. If necessary, recompute right away and replay the manual changes on top of the -- cgit v1.2.3 From c5dafb177fc66600defe4dc398edcf6d4ba0c4d9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 Apr 2017 16:45:12 +0200 Subject: Add debug output for QScrollPrepareEvent and QScrollEvent Change-Id: If283cecbefdf20c80ce00f689003f6a0ed9fe42b Reviewed-by: Shawn Rutledge --- src/gui/kernel/qevent.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ac9edc8eb0..2777e408c1 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4090,6 +4090,20 @@ QDebug operator<<(QDebug dbg, const QEvent *e) } dbg << ')'; break; + case QEvent::ScrollPrepare: { + const QScrollPrepareEvent *se = static_cast(e); + dbg << "QScrollPrepareEvent(viewportSize=" << se->viewportSize() + << ", contentPosRange=" << se->contentPosRange() + << ", contentPos=" << se->contentPos() << ')'; + } + break; + case QEvent::Scroll: { + const QScrollEvent *se = static_cast(e); + dbg << "QScrollEvent(contentPos=" << se->contentPos() + << ", overshootDistance=" << se->overshootDistance() + << ", scrollState=" << se->scrollState() << ')'; + } + break; default: dbg << eventClassName(type) << '('; QtDebugUtils::formatQEnum(dbg, type); -- cgit v1.2.3 From 2381332b0ddaec46c009e54907961a4c7043baf0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 13 Apr 2017 15:17:58 +0200 Subject: Doc: Hide QPA classes Mark QPlatformGraphicsBuffer and QSystemTrayIcon as internal. Change-Id: I39e5b4f635fca21ab0544cd840a113514b6b1e99 Reviewed-by: Laszlo Agocs --- src/gui/kernel/qplatformgraphicsbuffer.cpp | 2 ++ src/gui/kernel/qplatformsystemtrayicon.cpp | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qplatformgraphicsbuffer.cpp b/src/gui/kernel/qplatformgraphicsbuffer.cpp index 8080cb91ad..d42231e958 100644 --- a/src/gui/kernel/qplatformgraphicsbuffer.cpp +++ b/src/gui/kernel/qplatformgraphicsbuffer.cpp @@ -63,6 +63,8 @@ QT_BEGIN_NAMESPACE QPlatformGraphicsBuffer is intended to be created by using platform specific APIs available from QtPlatformHeaders, or there might be accessor functions similar to the accessor function that QPlatformBackingstore has. + + \internal */ /*! diff --git a/src/gui/kernel/qplatformsystemtrayicon.cpp b/src/gui/kernel/qplatformsystemtrayicon.cpp index 973b998059..5481997b3c 100644 --- a/src/gui/kernel/qplatformsystemtrayicon.cpp +++ b/src/gui/kernel/qplatformsystemtrayicon.cpp @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE \inmodule QtGui \brief The QPlatformSystemTrayIcon class abstracts the system tray icon and interaction. + \internal \sa QSystemTrayIcon */ @@ -82,16 +83,10 @@ QT_BEGIN_NAMESPACE \sa activated() */ -/*! - \internal - */ QPlatformSystemTrayIcon::QPlatformSystemTrayIcon() { } -/*! - \internal - */ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon() { } -- cgit v1.2.3 From dde83fdeebe83ad2a9e052ff94f8a325a64f8f38 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Wed, 19 Apr 2017 07:29:02 +0200 Subject: Fix warnings for -no-feature-texthtmlparser Change-Id: Ie757e4ecb9ced14bd809f56d2d3d09274fc3bc39 Reviewed-by: Paul Olav Tvete --- src/widgets/widgets/qtextedit.cpp | 2 ++ src/widgets/widgets/qwidgettextcontrol.cpp | 1 + 2 files changed, 3 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 66bf2919eb..1abc9bef8e 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -2578,6 +2578,8 @@ void QTextEdit::setText(const QString &text) if (format == Qt::RichText) setHtml(text); else +#else + Q_UNUSED(format); #endif setPlainText(text); } diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 714f8bfda8..815cc8736b 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -3116,6 +3116,7 @@ void QWidgetTextControlPrivate::append(const QString &text, Qt::TextFormat forma tmp.insertText(text); } #else + Q_UNUSED(format); tmp.insertText(text); #endif // QT_NO_TEXTHTMLPARSER if (!cursor.hasSelection()) -- cgit v1.2.3 From 45f7d35f7b03e3b5fd0687e344d6a757cd4516ec Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Wed, 19 Apr 2017 08:56:27 +0200 Subject: Fix warning for -no-feature-gestures Change-Id: Iaadc4e27ee2a75a8c053de4438ef74daaa48ee64 Reviewed-by: Paul Olav Tvete --- src/widgets/graphicsview/qgraphicsscene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index e6726285d9..35f6298a8a 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -1225,15 +1225,15 @@ bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event) */ bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event) { +#if QT_CONFIG(gestures) if (QGraphicsObject *object = item->toGraphicsObject()) { -#ifndef QT_NO_GESTURES QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager; if (gestureManager) { if (gestureManager->filterEvent(object, event)) return true; } -#endif // QT_NO_GESTURES } +#endif // QT_CONFIG(gestures) if (filterEvent(item, event)) return false; -- cgit v1.2.3 From b3066656e550077426bd2ad2e9c7e0ec4343cecd Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Wed, 19 Apr 2017 09:08:00 +0200 Subject: Fix warning for -no-feature-graphicseffect Change-Id: I0be9e4293dfcef3c144f4e998ea071336c4d56d3 Reviewed-by: Paul Olav Tvete --- src/widgets/graphicsview/qgraphicsitem.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index f2b8b66fed..3ce9c835db 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -2981,6 +2981,7 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectI return brect; #else //QT_NO_GRAPHICSEFFECT + Q_UNUSED(topMostEffectItem); return q_ptr->boundingRect(); #endif //QT_NO_GRAPHICSEFFECT -- cgit v1.2.3 From 59d9ee0aa450c47fd266744d72da7ef61c027553 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Wed, 19 Apr 2017 09:22:25 +0200 Subject: Fix build for -no-feature-cssparser Change-Id: I78b66e8a98458736c69c4955390a98f8889968ea Reviewed-by: Paul Olav Tvete --- src/widgets/widgets/qmenu.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index cf3fc9a9f6..98dc6d0a11 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -129,7 +129,9 @@ public: setAttribute(Qt::WA_X11NetWmWindowTypeMenu, true); setWindowTitle(p->windowTitle()); setEnabled(p->isEnabled()); +#if QT_CONFIG(cssparser) setStyleSheet(p->styleSheet()); +#endif if (style() != p->style()) setStyle(p->style()); int leftMargin, topMargin, rightMargin, bottomMargin; -- cgit v1.2.3 From 254f35ce98bebd8f4446fec66bb50f2126b61c28 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 5 Apr 2017 15:35:38 +0200 Subject: QNetworkReplyHttpImpl - check 'isOpen' twice A signal emitted after the first 'isOpen' check on QNetworkReply can trigger a slot that aborts/closes our reply. So before we can append any data to reply's buffer, we have to re-check that we're still open. Task-number: QTBUG-59909 Change-Id: I781d5a4fd5fc30d485af63f45cf36c254378af64 Reviewed-by: Edward Welbourne Reviewed-by: Alex Trotsenko Reviewed-by: Timur Pocheptsov --- src/network/access/qnetworkreplyhttpimpl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index bdb23ede1d..fec3b0a100 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1883,6 +1883,12 @@ void QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead() totalSize.isNull() ? Q_INT64_C(-1) : totalSize.toLongLong()); } } + + // A signal we've emitted might be handled by a slot that aborts, + // so we need to check for that and bail out if it's happened: + if (!q->isOpen()) + return; + // If there are still bytes available in the cacheLoadDevice then the user did not read // in response to the readyRead() signal. This means we have to load from the cacheLoadDevice // and buffer that stuff. This is needed to be able to properly emit finished() later. -- cgit v1.2.3 From 288bfb0bbd778fdfa6ac9fdcdc1afc19ec13aeaf Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Tue, 18 Apr 2017 10:19:12 +0200 Subject: QLineEdit: Make the clear button always the leftmost button QLineEditIconButton currently draws a fully transparent pixmap in its paintEvent() function, when the line edit is empty. This does not work when there is another trailing QAction that is visible even when the line edit has no text, as reported in QTBUG-59957. To fix this issue, make sure the clear button is always the leftmost button. Task-number: QTBUG-59957 Change-Id: I8a4f96aae07856aa0e1053ebb338ba9bdf052a16 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qlineedit_p.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 7c5ba79cb6..e1c7a4e280 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -533,6 +533,17 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE return nullptr; #endif } + + // QTBUG-59957: clear button should be the leftmost action. + if (!before && !(flags & SideWidgetClearButton) && position == QLineEdit::TrailingPosition) { + for (const SideWidgetEntry &e : trailingSideWidgets) { + if (e.flags & SideWidgetClearButton) { + before = e.action; + break; + } + } + } + // If there is a 'before' action, it takes preference // There's a bug in GHS compiler that causes internal error on the following code. -- cgit v1.2.3 From ee3ac3a3bfb4c4a0802f6530f61995297c573646 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 12 Apr 2017 16:38:40 +0200 Subject: Fix PNGs saved from QImage transform of 8-bit images Fixes two separate errors. QImage::transform was incorrectly adding colors to the color-table of the returned image when the converted image would not be indexed, and qpnghandler was looking at non-empty color- table instead of color format. Task-number: QTBUG-43708 Change-Id: Ife14b6428ca65ac7d3a0b36a89a73e56d64586b4 Reviewed-by: Eirik Aavitsland --- src/gui/image/qimage.cpp | 2 +- src/gui/image/qpnghandler.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 23b05fa874..9696584f36 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4671,7 +4671,7 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode } // initizialize the data - if (d->format == QImage::Format_Indexed8) { + if (target_format == QImage::Format_Indexed8) { if (dImage.d->colortable.size() < 256) { // colors are left in the color table, so pick that one as transparent dImage.d->colortable.append(0x0); diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 1d19c165fc..9506a95506 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -830,7 +830,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, volatile int quality_in, c int color_type = 0; - if (image.colorCount()) { + if (image.format() <= QImage::Format_Indexed8) { if (image.isGrayscale()) color_type = PNG_COLOR_TYPE_GRAY; else -- cgit v1.2.3 From ad0249cc793772a342bf6ced40fb44cd52b2b0e6 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 18 Apr 2017 12:47:21 +0200 Subject: winrt: Fix QKeyEvent::isAutoRepeat CorePhysicalKeyStatus::KeyStatus does not give the information we are after so we have to keep track of "auto repeat" state of the keys ourself. Task-number: QTBUG-59232 Change-Id: I22aa185780e5fa1f7f3c23c2deb2a0dde0c4a582 Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index edfcf038d7..3a4c3b871c 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -101,22 +101,26 @@ QT_BEGIN_NAMESPACE struct KeyInfo { KeyInfo() : virtualKey(0) + , isAutoRepeat(false) { } KeyInfo(const QString &text, quint32 virtualKey) : text(text) , virtualKey(virtualKey) + , isAutoRepeat(false) { } KeyInfo(quint32 virtualKey) : virtualKey(virtualKey) + , isAutoRepeat(false) { } QString text; quint32 virtualKey; + bool isAutoRepeat; }; static inline Qt::ScreenOrientations qtOrientationsFromNative(DisplayOrientations native) @@ -971,6 +975,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind if (!shouldAutoRepeat(key)) return S_OK; + d->activeKeys[key].isAutoRepeat = true; // If the key was pressed before trigger a key release before the next key press QWindowSystemInterface::handleExtendedKeyEvent( topWindow(), @@ -981,7 +986,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind virtualKey, 0, QString(), - status.WasKeyDown, + d->activeKeys.value(key).isAutoRepeat, !status.RepeatCount ? 1 : status.RepeatCount, false); } else { @@ -1001,7 +1006,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind virtualKey, 0, QString(), - status.WasKeyDown, + d->activeKeys.value(key).isAutoRepeat, !status.RepeatCount ? 1 : status.RepeatCount, false); return S_OK; @@ -1051,20 +1056,19 @@ HRESULT QWinRTScreen::onCharacterReceived(ICoreWindow *, ICharacterReceivedEvent const Qt::KeyboardModifiers modifiers = keyboardModifiers(); const Qt::Key key = qKeyFromCode(keyCode, modifiers); const QString text = QChar(keyCode); - const quint32 virtualKey = d->activeKeys.value(key).virtualKey; + const KeyInfo info = d->activeKeys.value(key); QWindowSystemInterface::handleExtendedKeyEvent( topWindow(), QEvent::KeyPress, key, modifiers, !status.ScanCode ? -1 : status.ScanCode, - virtualKey, + info.virtualKey, 0, text, - status.WasKeyDown, + info.isAutoRepeat, !status.RepeatCount ? 1 : status.RepeatCount, false); - d->activeKeys.insert(key, KeyInfo(text, virtualKey)); return S_OK; } -- cgit v1.2.3 From 32b92b9e21a7a684fa9c23b881cda5b913699574 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 19 Apr 2017 08:29:36 +0200 Subject: winrt: Fix keyboard modifier states CoreWindow::GetAsyncKeyState returns flags and not enums so checking equality does not give the needed result. As seen in qwindowskeymapper.cpp key events that only contain a modifier key should not have the key itself as a modifier when calling handleExtendedKeyEvent. With the current approach the modifier states are the same as on desktop Windows. Task-number: QTBUG-58750 Change-Id: Ie0f3e1d3e8294e1a6b41c9223a7a5153306579f6 Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 37 +++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 3a4c3b871c..7ac4bdac6c 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -685,21 +685,26 @@ Qt::KeyboardModifiers QWinRTScreen::keyboardModifiers() const Qt::KeyboardModifiers mods; CoreVirtualKeyStates mod; - d->coreWindow->GetAsyncKeyState(VirtualKey_Shift, &mod); - if (mod == CoreVirtualKeyStates_Down) + HRESULT hr = d->coreWindow->GetAsyncKeyState(VirtualKey_Shift, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::ShiftModifier; - d->coreWindow->GetAsyncKeyState(VirtualKey_Menu, &mod); - if (mod == CoreVirtualKeyStates_Down) + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_Menu, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::AltModifier; - d->coreWindow->GetAsyncKeyState(VirtualKey_Control, &mod); - if (mod == CoreVirtualKeyStates_Down) + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_Control, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::ControlModifier; - d->coreWindow->GetAsyncKeyState(VirtualKey_LeftWindows, &mod); - if (mod == CoreVirtualKeyStates_Down) { + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_LeftWindows, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) { mods |= Qt::MetaModifier; } else { - d->coreWindow->GetAsyncKeyState(VirtualKey_RightWindows, &mod); - if (mod == CoreVirtualKeyStates_Down) + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_RightWindows, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::MetaModifier; } return mods; @@ -997,11 +1002,21 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind if (key == Qt::Key_unknown || (key >= Qt::Key_Space && key <= Qt::Key_ydiaeresis)) return S_OK; + Qt::KeyboardModifiers modifiers = keyboardModifiers(); + // If the key actually pressed is a modifier key, then we remove its modifier key from the + // state, since a modifier-key can't have itself as a modifier (see qwindowskeymapper.cpp) + if (key == Qt::Key_Control) + modifiers = modifiers ^ Qt::ControlModifier; + else if (key == Qt::Key_Shift) + modifiers = modifiers ^ Qt::ShiftModifier; + else if (key == Qt::Key_Alt) + modifiers = modifiers ^ Qt::AltModifier; + QWindowSystemInterface::handleExtendedKeyEvent( topWindow(), QEvent::KeyPress, key, - keyboardModifiers(), + modifiers, !status.ScanCode ? -1 : status.ScanCode, virtualKey, 0, -- cgit v1.2.3 From 30d825f5f21265468d2aedc1bb5d6796ddaa5f3f Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 11 Apr 2017 14:07:28 +0200 Subject: Doc: Fix link errors qimage.cpp:2127: warning: Can't link to 'isDetached()' qmatrix4x4.cpp:1933: warning: Can't link to 'operator()()' Change-Id: I93a2ead9650faf139040173f8d3b24cfa1e730ae Reviewed-by: Martin Smith --- src/gui/image/qimage.cpp | 2 +- src/gui/math3d/qmatrix4x4.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 9696584f36..fffd7a1ac2 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1071,7 +1071,7 @@ QImage::operator QVariant() const Nothing is done if there is just a single reference. - \sa copy(), isDetached(), {Implicit Data Sharing} + \sa copy(), {QImage::isDetached()}{isDetached()}, {Implicit Data Sharing} */ void QImage::detach() { diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index b6381e1d8f..6b18e1ab03 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1940,7 +1940,7 @@ QMatrix4x4 QMatrix4x4::orthonormalInverse() const Normally the QMatrix4x4 class keeps track of this special type internally as operations are performed. However, if the matrix is modified - directly with operator()() or data(), then QMatrix4x4 will lose track of + directly with {QLoggingCategory::operator()}{operator()()} or data(), then QMatrix4x4 will lose track of the special type and will revert to the safest but least efficient operations thereafter. @@ -1948,7 +1948,7 @@ QMatrix4x4 QMatrix4x4::orthonormalInverse() const the programmer can force QMatrix4x4 to recover the special type if the elements appear to conform to one of the known optimized types. - \sa operator()(), data(), translate() + \sa {QLoggingCategory::operator()}{operator()()}, data(), translate() */ void QMatrix4x4::optimize() { -- cgit v1.2.3 From f368cd88687643d565763602721cae6e9602e34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 27 Mar 2017 18:49:10 +0200 Subject: macOS: Initialize window geometry early on, instead of when creating NSWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't need to defer to NSWindow creation before determining the initial window geometry, and we don't need to redetermine each time we re-create an NSWindow for a QCocoaWindow. Change-Id: Ie13380830b44e96670ff16513f29deef5f5ae313 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index e9bcaa8f41..b453da818f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -491,7 +491,9 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw, WId nativeHandle) "QT_MAC_WANTS_LAYER"); [m_view setWantsLayer:enable]; } - setGeometry(tlw->geometry()); + + setGeometry(initialGeometry(window(), windowGeometry(), defaultWindowWidth, defaultWindowHeight)); + recreateWindowIfNeeded(); tlw->setGeometry(geometry()); if (tlw->isTopLevel()) @@ -1721,7 +1723,7 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBeChildNSWindow, bool sh { QMacAutoReleasePool pool; - QRect rect = initialGeometry(window(), windowGeometry(), defaultWindowWidth, defaultWindowHeight); + QRect rect = geometry(); QScreen *targetScreen = nullptr; for (QScreen *screen : QGuiApplication::screens()) { -- cgit v1.2.3 From cdb7e81572df726486fc0bdc648f732b797c7f84 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 18 Apr 2017 16:52:19 +0200 Subject: Fix UB in QLayout::childEvent We can't just static_cast a child to QLayout, because the child might not be a QLayout, and even if it was, we might be called from the QObject destructor so we would not be a layout anymore. Instead we can just qobject_cast the deleted object to a QLayout and remove it from the layout with removeItem. This would not take in account the case where we would be called because the QLayout gets destroyed, so we handle this case from ~QLayout by removing ourself from the parent. Note that the comment in ~QLayout was wrong, as the layout gets destroyed explicitly from ~QWidget, not from ~QObject. Change-Id: I49c6f17a76f207b9d750b6e5d987469498b96b31 Reviewed-by: Marc Mutz --- src/widgets/kernel/qlayout.cpp | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index f88ed350c7..129c12885a 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -641,21 +641,11 @@ void QLayout::childEvent(QChildEvent *e) if (!d->enabled) return; - if (e->type() == QEvent::ChildRemoved) { - QChildEvent *c = (QChildEvent*)e; - int i = 0; - - QLayoutItem *item; - while ((item = itemAt(i))) { - if (item == static_cast(c->child())) { - takeAt(i); - invalidate(); - break; - } else { - ++i; - } - } - } + if (e->type() != QEvent::ChildRemoved) + return; + + if (QLayout *childLayout = qobject_cast(e->child())) + removeItem(childLayout); } /*! @@ -766,13 +756,10 @@ QSize QLayout::totalMaximumSize() const QLayout::~QLayout() { Q_D(QLayout); - /* - This function may be called during the QObject destructor, - when the parent no longer is a QWidget. - */ - if (d->topLevel && parent() && parent()->isWidgetType() && - ((QWidget*)parent())->layout() == this) - ((QWidget*)parent())->d_func()->layout = 0; + if (d->topLevel && parent() && parent()->isWidgetType() && parentWidget()->layout() == this) + parentWidget()->d_func()->layout = 0; + else if (QLayout *parentLayout = qobject_cast(parent())) + parentLayout->removeItem(this); } -- cgit v1.2.3 From 97850b952ca754ce8822a6f9e84af39311c0ea53 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 18 Apr 2017 16:28:17 +0200 Subject: Fix UB in QWidgetEffectSourcePrivate::detach Delete the QGraphicsEffect from the QWidget destructor instead of from the QWidgetPrivate destructor. The destructor of QGraphicsEffect still access methods of the QWidget, but the QObjectPrivate being destroyed from ~QObject, the pointer is no longer a QWidget. Fix warning with UB sanitizer in tst_QWidget::setGraphicsEffect qwidget_p.h:900:23: runtime error: member call on address 0x000001d822c0 which does not point to an object of type 'QWidget' 0x000001d822c0: note: object is of type 'QObject' 00 00 00 00 b0 46 5f 40 e5 7f 00 00 00 23 d8 01 00 00 00 00 f0 e6 00 44 e5 7f 00 00 00 00 74 47 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QObject' #0 0x7fe54767db76 in QWidgetEffectSourcePrivate::detach() #1 0x7fe548f29815 in QGraphicsEffect::~QGraphicsEffect() #2 0x7fe548f2a1b7 in QGraphicsBlurEffect::~QGraphicsBlurEffect() #3 0x7fe548f2a208 in QGraphicsBlurEffect::~QGraphicsBlurEffect() #4 0x7fe5475cd463 in QWidgetPrivate::~QWidgetPrivate() #5 0x7fe5475ce62c in QWidgetPrivate::~QWidgetPrivate() #6 0x7fe5400d0dda in QObject::~QObject() #7 0x7fe54763d411 in QWidget::~QWidget() #8 0x7fe54763d7f4 in QWidget::~QWidget() #9 0x4cc309 in QScopedPointerDeleter::cleanup(QWidget*) #10 0x4cc309 in QScopedPointer >::reset(QWidget*) #11 0x4cc309 in tst_QWidget::setGraphicsEffect() Change-Id: I19c049e979cfce2adda908af8336cb4adac8f6c4 Reviewed-by: Marc Mutz --- src/widgets/kernel/qwidget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index bd67e0be32..7a83e0b517 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -341,10 +341,6 @@ QWidgetPrivate::~QWidgetPrivate() if (extra) deleteExtra(); - -#ifndef QT_NO_GRAPHICSEFFECT - delete graphicsEffect; -#endif //QT_NO_GRAPHICSEFFECT } /*! @@ -1718,6 +1714,10 @@ QWidget::~QWidget() } QT_CATCH(const std::exception&) { // if this fails we can't do anything about it but at least we are not allowed to throw. } + +#if QT_CONFIG(graphicseffect) + delete d->graphicsEffect; +#endif } int QWidgetPrivate::instanceCounter = 0; // Current number of widget instances -- cgit v1.2.3 From 924b02aecbce4843ff9d0a7d1d15f1eb154f5d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 19 Apr 2017 15:54:47 +0200 Subject: Revert "Initialize QLoggingRegistry rules on first use, not qApp construction" This reverts commit 47cc9e23a313d67a4a3107242f205d2473842021. We use QCoreApplication::applicationDirPath in the logging initialization to find a possible qtlogging.ini file. Because QCoreApplication::applicationDirPath requires a QCoreApplication instance this leads to a qWarning, which in turn leads to a recursive call to the logging initialization, and in turn to a recursive mutex deadlock. Task-number: QTCREATORBUG-18031 Change-Id: Ic75e1e8c062eb647991725378489bf87c9648cca Reviewed-by: Friedemann Kleint --- src/corelib/io/qloggingregistry.cpp | 1 - src/corelib/io/qloggingregistry_p.h | 3 ++- src/corelib/kernel/qcoreapplication.cpp | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 9a5c923323..47fb1fb6b8 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -255,7 +255,6 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) QLoggingRegistry::QLoggingRegistry() : categoryFilter(defaultCategoryFilter) { - init(); } static bool qtLoggingDebug() diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 768f3b4a91..69fc6ea4ec 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -113,6 +113,8 @@ class Q_AUTOTEST_EXPORT QLoggingRegistry public: QLoggingRegistry(); + void init(); + void registerCategory(QLoggingCategory *category, QtMsgType enableForLevel); void unregisterCategory(QLoggingCategory *category); @@ -124,7 +126,6 @@ public: static QLoggingRegistry *instance(); private: - void init(); void updateRules(); static void defaultCategoryFilter(QLoggingCategory *category); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 0216baa6c3..e4b1562b8b 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -771,6 +771,8 @@ void QCoreApplicationPrivate::init() if (!coreappdata()->applicationVersionSet) coreappdata()->applicationVersion = appVersion(); + QLoggingRegistry::instance()->init(); + #if QT_CONFIG(library) // Reset the lib paths, so that they will be recomputed, taking the availability of argv[0] // into account. If necessary, recompute right away and replay the manual changes on top of the -- cgit v1.2.3 From e70e8dd6a93e6680471536f613fa41824231d02c Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 12 Apr 2017 14:19:31 +0100 Subject: qgrayraster: use a cast to void to mark a variable as unused Do not use a self-assignment, as that may trigger compiler warnings. Casting to void is also what Q_UNUSED is doing these days, but we can't use it here because qgrayraster.c does not include qglobal.h. Remove a 15-years old comment related to the self assignment. Found by clazy. Change-Id: I8cc92b7a1b0b5fb13824959740243e17606ec753 Reviewed-by: Thiago Macieira --- src/gui/painting/qgrayraster.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c index dae1c06bec..4a135e25d8 100644 --- a/src/gui/painting/qgrayraster.c +++ b/src/gui/painting/qgrayraster.c @@ -167,11 +167,7 @@ #include #include - /* This macro is used to indicate that a function parameter is unused. */ - /* Its purpose is simply to reduce compiler warnings. Note also that */ - /* simply defining it as `(void)x' doesn't avoid warnings with certain */ - /* ANSI compilers (e.g. LCC). */ -#define QT_FT_UNUSED( x ) (x) = (x) +#define QT_FT_UNUSED( x ) (void) x /* Disable the tracing mechanism for simplicity -- developers can */ /* activate it easily by redefining these two macros. */ -- cgit v1.2.3 From 47c9b66a8b4cf95983e7bca772a40983d52fc6d6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 16 Apr 2017 10:51:15 -0700 Subject: Disable precompiled headers for small modules Creating a precompiled header exclusively for a one- or two-file module is wasteful. The time that it takes to build the precompiled source is on the same order as a regular compilation, so enabling precompiled headers for those modules just makes the build slower. Also make it possible to override the precompiled header by just setting PRECOMPILED_HEADER to empty. Change-Id: I0e1a09998253489388abfffd14b5f221288c4826 Reviewed-by: Oswald Buddenhagen --- src/platformsupport/accessibility/accessibility.pro | 1 - src/platformsupport/cglconvenience/cglconvenience.pro | 1 - src/platformsupport/clipboard/clipboard.pro | 1 - src/platformsupport/devicediscovery/devicediscovery.pro | 1 - src/platformsupport/glxconvenience/glxconvenience.pro | 1 - src/platformsupport/graphics/graphics.pro | 1 - src/platformsupport/kmsconvenience/kmsconvenience.pro | 1 - src/platformsupport/platformcompositor/platformcompositor.pro | 1 - src/platformsupport/themes/themes.pro | 1 - 9 files changed, 9 deletions(-) (limited to 'src') diff --git a/src/platformsupport/accessibility/accessibility.pro b/src/platformsupport/accessibility/accessibility.pro index 5004dc8cbe..1806d75630 100644 --- a/src/platformsupport/accessibility/accessibility.pro +++ b/src/platformsupport/accessibility/accessibility.pro @@ -5,7 +5,6 @@ QT = core-private gui-private CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h HEADERS += \ qaccessiblebridgeutils_p.h diff --git a/src/platformsupport/cglconvenience/cglconvenience.pro b/src/platformsupport/cglconvenience/cglconvenience.pro index 0422a844aa..89d1fc4643 100644 --- a/src/platformsupport/cglconvenience/cglconvenience.pro +++ b/src/platformsupport/cglconvenience/cglconvenience.pro @@ -5,7 +5,6 @@ QT = core-private gui CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h HEADERS += \ cglconvenience_p.h diff --git a/src/platformsupport/clipboard/clipboard.pro b/src/platformsupport/clipboard/clipboard.pro index 336d81fe46..def2a061a0 100644 --- a/src/platformsupport/clipboard/clipboard.pro +++ b/src/platformsupport/clipboard/clipboard.pro @@ -5,7 +5,6 @@ QT = core-private gui CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h HEADERS += qmacmime_p.h SOURCES += qmacmime.mm diff --git a/src/platformsupport/devicediscovery/devicediscovery.pro b/src/platformsupport/devicediscovery/devicediscovery.pro index b429b8b97e..881ec4d41e 100644 --- a/src/platformsupport/devicediscovery/devicediscovery.pro +++ b/src/platformsupport/devicediscovery/devicediscovery.pro @@ -6,7 +6,6 @@ QT_FOR_CONFIG += gui-private CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h HEADERS += qdevicediscovery_p.h diff --git a/src/platformsupport/glxconvenience/glxconvenience.pro b/src/platformsupport/glxconvenience/glxconvenience.pro index 41c96d8f0d..58fa9fc479 100644 --- a/src/platformsupport/glxconvenience/glxconvenience.pro +++ b/src/platformsupport/glxconvenience/glxconvenience.pro @@ -5,7 +5,6 @@ QT = core-private gui-private CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h LIBS_PRIVATE += $$QMAKE_LIBS_X11 diff --git a/src/platformsupport/graphics/graphics.pro b/src/platformsupport/graphics/graphics.pro index 878fca7f49..9886ee0332 100644 --- a/src/platformsupport/graphics/graphics.pro +++ b/src/platformsupport/graphics/graphics.pro @@ -5,7 +5,6 @@ QT = core-private gui-private CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h HEADERS += $$PWD/qrasterbackingstore_p.h SOURCES += $$PWD/qrasterbackingstore.cpp diff --git a/src/platformsupport/kmsconvenience/kmsconvenience.pro b/src/platformsupport/kmsconvenience/kmsconvenience.pro index d0ff0d4efb..5ea2e3f208 100644 --- a/src/platformsupport/kmsconvenience/kmsconvenience.pro +++ b/src/platformsupport/kmsconvenience/kmsconvenience.pro @@ -5,7 +5,6 @@ QT = core-private gui-private CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h HEADERS += qkmsdevice_p.h diff --git a/src/platformsupport/platformcompositor/platformcompositor.pro b/src/platformsupport/platformcompositor/platformcompositor.pro index 633e71fb9d..81c31571d0 100644 --- a/src/platformsupport/platformcompositor/platformcompositor.pro +++ b/src/platformsupport/platformcompositor/platformcompositor.pro @@ -5,7 +5,6 @@ QT = core-private gui-private CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h SOURCES += \ qopenglcompositor.cpp \ diff --git a/src/platformsupport/themes/themes.pro b/src/platformsupport/themes/themes.pro index 2aeb1f89ad..aeed4d2f47 100644 --- a/src/platformsupport/themes/themes.pro +++ b/src/platformsupport/themes/themes.pro @@ -5,7 +5,6 @@ QT = core-private gui-private CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h unix:!darwin: \ include($$PWD/genericunix/genericunix.pri) -- cgit v1.2.3 From 870964895baadd013570d626d9e8ebc9d57fee94 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Apr 2017 15:30:44 -0700 Subject: Don't disable Q_REQUIRED_RESULT with Clang and ICC They're not affected by the GCC bug noted in the comment. Change-Id: I7814054a102a407d876ffffd14b69e8a8e2527f1 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qbytearray.h | 2 +- src/corelib/tools/qstring.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 06a50e5990..a0e5c5478b 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -243,7 +243,7 @@ public: void chop(int n); #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) -# if defined(Q_CC_GNU) +# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 # pragma push_macro("Q_REQUIRED_RESULT") # undef Q_REQUIRED_RESULT diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 1bd436c387..09a3bcb521 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -383,7 +383,7 @@ public: QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) -# if defined(Q_CC_GNU) +# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 # pragma push_macro("Q_REQUIRED_RESULT") # undef Q_REQUIRED_RESULT -- cgit v1.2.3 From 3dcc075f4a5efce348a6fa00cf5a0adef97b1089 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Apr 2017 16:22:46 -0700 Subject: Move Q_REQUIRED_RESULT to its correct position That's before the return type or static, inline, constexpr or such keywords (if any). Perl Script: s/^(\s+)(.*) Q_REQUIRED_RESULT(;)?(\s*\/\/.*)?$/\1Q_REQUIRED_RESULT \2\3\4/ Change-Id: I7814054a102a407d876ffffd14b6a16182f159e2 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qfloat16.h | 16 +-- src/corelib/global/qglobal.h | 18 +-- src/corelib/io/qurl.h | 4 +- src/corelib/thread/qthreadpool.h | 2 +- src/corelib/tools/qarraydata.h | 14 +-- src/corelib/tools/qarraydatapointer.h | 2 +- src/corelib/tools/qbytearray.h | 56 ++++----- src/corelib/tools/qdatetime.h | 20 ++-- src/corelib/tools/qline.h | 18 +-- src/corelib/tools/qpoint.h | 6 +- src/corelib/tools/qrect.h | 46 ++++---- src/corelib/tools/qsize.h | 26 ++--- src/corelib/tools/qstring.h | 202 ++++++++++++++++----------------- src/corelib/tools/qtimezoneprivate_p.h | 4 +- src/corelib/tools/qversionnumber.h | 28 ++--- src/gui/image/qimage.h | 8 +- src/gui/math3d/qgenericmatrix.h | 2 +- src/gui/math3d/qquaternion.h | 6 +- src/gui/math3d/qvector2d.h | 2 +- src/gui/math3d/qvector4d.h | 2 +- src/gui/painting/qcolor.h | 10 +- src/gui/painting/qmatrix.h | 2 +- src/gui/painting/qpainterpath.h | 16 +-- src/gui/painting/qpolygon.h | 18 +-- src/gui/painting/qregion.h | 28 ++--- src/gui/painting/qtransform.h | 6 +- src/network/ssl/qsslellipticcurve.h | 4 +- src/widgets/kernel/qsizepolicy.h | 3 +- 28 files changed, 281 insertions(+), 288 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 3b54719f4f..b0272c51c3 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -81,18 +81,18 @@ private: Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE); -Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h -Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h -Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h +Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h +Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h +Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h // The remainder of these utility functions complement qglobal.h -inline Q_REQUIRED_RESULT int qRound(qfloat16 d) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline int qRound(qfloat16 d) Q_DECL_NOTHROW { return qRound(static_cast(d)); } -inline Q_REQUIRED_RESULT qint64 qRound64(qfloat16 d) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline qint64 qRound64(qfloat16 d) Q_DECL_NOTHROW { return qRound64(static_cast(d)); } -inline Q_REQUIRED_RESULT bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOTHROW { float f1 = static_cast(p1); float f2 = static_cast(p2); @@ -105,7 +105,7 @@ inline Q_REQUIRED_RESULT bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOT return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2))); } -inline Q_REQUIRED_RESULT bool qIsNull(qfloat16 f) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qIsNull(qfloat16 f) Q_DECL_NOTHROW { return (f.b16 & static_cast(0x7fff)) == 0; } @@ -247,7 +247,7 @@ QT_WARNING_POP /*! \internal */ -inline Q_REQUIRED_RESULT bool qFuzzyIsNull(qfloat16 f) Q_DECL_NOTHROW +Q_REQUIRED_RESULT inline bool qFuzzyIsNull(qfloat16 f) Q_DECL_NOTHROW { return qAbs(static_cast(f)) <= 0.001f; } diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 9ac29acd16..d4d20fd54a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -770,26 +770,22 @@ typedef void (*QFunctionPointer)(); # define Q_UNIMPLEMENTED() qWarning("Unimplemented code.") #endif -Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) Q_REQUIRED_RESULT Q_DECL_UNUSED; -Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(double p1, double p2) { return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2))); } -Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) Q_REQUIRED_RESULT Q_DECL_UNUSED; -Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(float p1, float p2) { return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2))); } -Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) Q_REQUIRED_RESULT Q_DECL_UNUSED; -Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(double d) { return qAbs(d) <= 0.000000000001; } -Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) Q_REQUIRED_RESULT Q_DECL_UNUSED; -Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) +Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(float f) { return qAbs(f) <= 0.00001f; } @@ -799,8 +795,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) check whether the actual value is 0 or close to 0, but whether it is binary 0, disregarding sign. */ -static inline bool qIsNull(double d) Q_REQUIRED_RESULT Q_DECL_UNUSED; -static inline bool qIsNull(double d) +Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(double d) { union U { double d; @@ -816,8 +811,7 @@ static inline bool qIsNull(double d) check whether the actual value is 0 or close to 0, but whether it is binary 0, disregarding sign. */ -static inline bool qIsNull(float f) Q_REQUIRED_RESULT Q_DECL_UNUSED; -static inline bool qIsNull(float f) +Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(float f) { union U { float f; diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index c16825a033..0bb8707ff9 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -196,7 +196,7 @@ public: QString url(FormattingOptions options = FormattingOptions(PrettyDecoded)) const; QString toString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const; QString toDisplayString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const; - QUrl adjusted(FormattingOptions options) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QUrl adjusted(FormattingOptions options) const; QByteArray toEncoded(FormattingOptions options = FullyEncoded) const; static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode); @@ -255,7 +255,7 @@ public: QString fragment(ComponentFormattingOptions options = PrettyDecoded) const; void setFragment(const QString &fragment, ParsingMode mode = TolerantMode); - QUrl resolved(const QUrl &relative) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QUrl resolved(const QUrl &relative) const; bool isRelative() const; bool isParentOf(const QUrl &url) const; diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h index 74a8c28fc8..09b7f96f48 100644 --- a/src/corelib/thread/qthreadpool.h +++ b/src/corelib/thread/qthreadpool.h @@ -88,7 +88,7 @@ public: QT_DEPRECATED_X("use tryTake(), but note the different deletion rules") void cancel(QRunnable *runnable); #endif - bool tryTake(QRunnable *runnable) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT bool tryTake(QRunnable *runnable); }; QT_END_NAMESPACE diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index bc20932cca..88f0cfb0ea 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -112,12 +112,10 @@ struct Q_CORE_EXPORT QArrayData return result; } - static QArrayData *allocate(size_t objectSize, size_t alignment, - size_t capacity, AllocationOptions options = Default) - Q_DECL_NOTHROW Q_REQUIRED_RESULT; - static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, - size_t newCapacity, AllocationOptions newOptions = Default) - Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QArrayData *allocate(size_t objectSize, size_t alignment, + size_t capacity, AllocationOptions options = Default) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, + size_t newCapacity, AllocationOptions newOptions = Default) Q_DECL_NOTHROW; static void deallocate(QArrayData *data, size_t objectSize, size_t alignment) Q_DECL_NOTHROW; @@ -217,8 +215,8 @@ struct QTypedArrayData class AlignmentDummy { QArrayData header; T data; }; - static QTypedArrayData *allocate(size_t capacity, - AllocationOptions options = Default) Q_REQUIRED_RESULT + Q_REQUIRED_RESULT static QTypedArrayData *allocate(size_t capacity, + AllocationOptions options = Default) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast(QArrayData::allocate(sizeof(T), diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index b97dde5a61..51cfa6e849 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -174,7 +174,7 @@ public: } private: - Data *clone(QArrayData::AllocationOptions options) const Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Data *clone(QArrayData::AllocationOptions options) const { Data *x = Data::allocate(d->detachCapacity(d->size), options); Q_CHECK_PTR(x); diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index a0e5c5478b..03bb9b5747 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -227,9 +227,9 @@ public: int count(const char *a) const; int count(const QByteArray &a) const; - QByteArray left(int len) const Q_REQUIRED_RESULT; - QByteArray right(int len) const Q_REQUIRED_RESULT; - QByteArray mid(int index, int len = -1) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray left(int len) const; + Q_REQUIRED_RESULT QByteArray right(int len) const; + Q_REQUIRED_RESULT QByteArray mid(int index, int len = -1) const; bool startsWith(const QByteArray &a) const; bool startsWith(char c) const; @@ -250,34 +250,34 @@ public: # define Q_REQUIRED_RESULT # define Q_REQUIRED_RESULT_pushed # endif - Q_ALWAYS_INLINE QByteArray toLower() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toLower() const & { return toLower_helper(*this); } - Q_ALWAYS_INLINE QByteArray toLower() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toLower() && { return toLower_helper(*this); } - Q_ALWAYS_INLINE QByteArray toUpper() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toUpper() const & { return toUpper_helper(*this); } - Q_ALWAYS_INLINE QByteArray toUpper() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toUpper() && { return toUpper_helper(*this); } - Q_ALWAYS_INLINE QByteArray trimmed() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray trimmed() const & { return trimmed_helper(*this); } - Q_ALWAYS_INLINE QByteArray trimmed() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray trimmed() && { return trimmed_helper(*this); } - Q_ALWAYS_INLINE QByteArray simplified() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray simplified() const & { return simplified_helper(*this); } - Q_ALWAYS_INLINE QByteArray simplified() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray simplified() && { return simplified_helper(*this); } # ifdef Q_REQUIRED_RESULT_pushed # pragma pop_macro("Q_REQUIRED_RESULT") # endif #else - QByteArray toLower() const Q_REQUIRED_RESULT; - QByteArray toUpper() const Q_REQUIRED_RESULT; - QByteArray trimmed() const Q_REQUIRED_RESULT; - QByteArray simplified() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray toLower() const; + Q_REQUIRED_RESULT QByteArray toUpper() const; + Q_REQUIRED_RESULT QByteArray trimmed() const; + Q_REQUIRED_RESULT QByteArray simplified() const; #endif - QByteArray leftJustified(int width, char fill = ' ', bool truncate = false) const Q_REQUIRED_RESULT; - QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray leftJustified(int width, char fill = ' ', bool truncate = false) const; + Q_REQUIRED_RESULT QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const; QByteArray &prepend(char c); QByteArray &prepend(int count, char c); @@ -312,7 +312,7 @@ public: QList split(char sep) const; - QByteArray repeated(int times) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray repeated(int times) const; #ifndef QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARN QByteArray &append(const QString &s); @@ -362,16 +362,16 @@ public: QByteArray &setNum(double, char f = 'g', int prec = 6); QByteArray &setRawData(const char *a, uint n); // ### Qt 6: use an int - static QByteArray number(int, int base = 10) Q_REQUIRED_RESULT; - static QByteArray number(uint, int base = 10) Q_REQUIRED_RESULT; - static QByteArray number(qlonglong, int base = 10) Q_REQUIRED_RESULT; - static QByteArray number(qulonglong, int base = 10) Q_REQUIRED_RESULT; - static QByteArray number(double, char f = 'g', int prec = 6) Q_REQUIRED_RESULT; - static QByteArray fromRawData(const char *, int size) Q_REQUIRED_RESULT; - static QByteArray fromBase64(const QByteArray &base64, Base64Options options) Q_REQUIRED_RESULT; - static QByteArray fromBase64(const QByteArray &base64) Q_REQUIRED_RESULT; // ### Qt6 merge with previous - static QByteArray fromHex(const QByteArray &hexEncoded) Q_REQUIRED_RESULT; - static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%') Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QByteArray number(int, int base = 10); + Q_REQUIRED_RESULT static QByteArray number(uint, int base = 10); + Q_REQUIRED_RESULT static QByteArray number(qlonglong, int base = 10); + Q_REQUIRED_RESULT static QByteArray number(qulonglong, int base = 10); + Q_REQUIRED_RESULT static QByteArray number(double, char f = 'g', int prec = 6); + Q_REQUIRED_RESULT static QByteArray fromRawData(const char *, int size); + Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64, Base64Options options); + Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64); // ### Qt6 merge with previous + Q_REQUIRED_RESULT static QByteArray fromHex(const QByteArray &hexEncoded); + Q_REQUIRED_RESULT static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%'); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) static QByteArray fromCFData(CFDataRef data); diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index c7f14ed40a..2518dc7301 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -103,9 +103,9 @@ QT_DEPRECATED inline bool setYMD(int y, int m, int d) #endif // < Qt 6 void getDate(int *year, int *month, int *day) const; - QDate addDays(qint64 days) const Q_REQUIRED_RESULT; - QDate addMonths(int months) const Q_REQUIRED_RESULT; - QDate addYears(int years) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QDate addDays(qint64 days) const; + Q_REQUIRED_RESULT QDate addMonths(int months) const; + Q_REQUIRED_RESULT QDate addYears(int years) const; qint64 daysTo(const QDate &) const; Q_DECL_CONSTEXPR bool operator==(const QDate &other) const { return jd == other.jd; } @@ -166,9 +166,9 @@ public: #endif bool setHMS(int h, int m, int s, int ms = 0); - QTime addSecs(int secs) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QTime addSecs(int secs) const; int secsTo(const QTime &) const; - QTime addMSecs(int ms) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QTime addMSecs(int ms) const; int msecsTo(const QTime &) const; Q_DECL_CONSTEXPR bool operator==(const QTime &other) const { return mds == other.mds; } @@ -297,11 +297,11 @@ public: QString toString(Qt::DateFormat f = Qt::TextDate) const; QString toString(const QString &format) const; #endif - QDateTime addDays(qint64 days) const Q_REQUIRED_RESULT; - QDateTime addMonths(int months) const Q_REQUIRED_RESULT; - QDateTime addYears(int years) const Q_REQUIRED_RESULT; - QDateTime addSecs(qint64 secs) const Q_REQUIRED_RESULT; - QDateTime addMSecs(qint64 msecs) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QDateTime addDays(qint64 days) const; + Q_REQUIRED_RESULT QDateTime addMonths(int months) const; + Q_REQUIRED_RESULT QDateTime addYears(int years) const; + Q_REQUIRED_RESULT QDateTime addSecs(qint64 secs) const; + Q_REQUIRED_RESULT QDateTime addMSecs(qint64 msecs) const; QDateTime toTimeSpec(Qt::TimeSpec spec) const; inline QDateTime toLocalTime() const { return toTimeSpec(Qt::LocalTime); } diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h index 5b5ca3b4c8..6361c1af9f 100644 --- a/src/corelib/tools/qline.h +++ b/src/corelib/tools/qline.h @@ -73,10 +73,10 @@ public: inline void translate(const QPoint &p); inline void translate(int dx, int dy); - Q_DECL_CONSTEXPR inline QLine translated(const QPoint &p) const Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QLine translated(int dx, int dy) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLine translated(const QPoint &p) const; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLine translated(int dx, int dy) const; - Q_DECL_CONSTEXPR inline QPoint center() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QPoint center() const; inline void setP1(const QPoint &p1); inline void setP2(const QPoint &p2); @@ -221,7 +221,7 @@ public: Q_DECL_CONSTEXPR inline QLineF(qreal x1, qreal y1, qreal x2, qreal y2); Q_DECL_CONSTEXPR inline QLineF(const QLine &line) : pt1(line.p1()), pt2(line.p2()) { } - static QLineF fromPolar(qreal length, qreal angle) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QLineF fromPolar(qreal length, qreal angle); Q_DECL_CONSTEXPR bool isNull() const; @@ -245,8 +245,8 @@ public: qreal angleTo(const QLineF &l) const; - QLineF unitVector() const Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QLineF normalVector() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QLineF unitVector() const; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF normalVector() const; // ### Qt 6: rename intersects() or intersection() and rename IntersectType IntersectionType IntersectType intersect(const QLineF &l, QPointF *intersectionPoint) const; @@ -257,10 +257,10 @@ public: inline void translate(const QPointF &p); inline void translate(qreal dx, qreal dy); - Q_DECL_CONSTEXPR inline QLineF translated(const QPointF &p) const Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QLineF translated(qreal dx, qreal dy) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF translated(const QPointF &p) const; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF translated(qreal dx, qreal dy) const; - Q_DECL_CONSTEXPR inline QPointF center() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QPointF center() const; inline void setP1(const QPointF &p1); inline void setP2(const QPointF &p2); diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index 7b1004897a..0f3e0c3517 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -94,7 +94,7 @@ public: friend Q_DECL_CONSTEXPR inline const QPoint operator/(const QPoint &, qreal); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW; #endif private: @@ -256,8 +256,8 @@ public: Q_DECL_CONSTEXPR QPoint toPoint() const; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW Q_REQUIRED_RESULT; - CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW; #endif private: diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 4030cccbd5..19ff87b420 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -70,7 +70,7 @@ public: Q_DECL_CONSTEXPR inline int top() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int right() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int bottom() const Q_DECL_NOTHROW; - QRect normalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QRect normalized() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int x() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int y() const Q_DECL_NOTHROW; @@ -104,9 +104,9 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void translate(int dx, int dy) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPoint &p) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QRect transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect transposed() const Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void moveTo(int x, int t) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPoint &p) Q_DECL_NOTHROW; @@ -118,7 +118,7 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void getCoords(int *x1, int *y1, int *x2, int *y2) const; Q_DECL_RELAXED_CONSTEXPR inline void adjust(int x1, int y1, int x2, int y2) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline QSize size() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline int width() const Q_DECL_NOTHROW; @@ -136,8 +136,8 @@ public: bool contains(const QPoint &p, bool proper=false) const Q_DECL_NOTHROW; inline bool contains(int x, int y) const Q_DECL_NOTHROW; inline bool contains(int x, int y, bool proper) const Q_DECL_NOTHROW; - inline QRect united(const QRect &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - inline QRect intersected(const QRect &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT inline QRect united(const QRect &other) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT inline QRect intersected(const QRect &other) const Q_DECL_NOTHROW; bool intersects(const QRect &r) const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const Q_DECL_NOTHROW; @@ -146,15 +146,15 @@ public: Q_DECL_RELAXED_CONSTEXPR inline QRect &operator-=(const QMargins &margins) Q_DECL_NOTHROW; #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED QRect unite(const QRect &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return united(r); } - QT_DEPRECATED QRect intersect(const QRect &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return intersected(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRect unite(const QRect &r) const Q_DECL_NOTHROW { return united(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRect intersect(const QRect &r) const Q_DECL_NOTHROW { return intersected(r); } #endif friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW; friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW; #endif private: @@ -520,7 +520,7 @@ public: Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW; - QRectF normalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QRectF normalized() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline qreal left() const Q_DECL_NOTHROW { return xp; } Q_DECL_CONSTEXPR inline qreal top() const Q_DECL_NOTHROW { return yp; } @@ -560,10 +560,10 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void translate(qreal dx, qreal dy) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPointF &p) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRectF transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF transposed() const Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void moveTo(qreal x, qreal y) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPointF &p) Q_DECL_NOTHROW; @@ -575,7 +575,7 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const; Q_DECL_RELAXED_CONSTEXPR inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline QSizeF size() const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline qreal width() const Q_DECL_NOTHROW; @@ -592,8 +592,8 @@ public: bool contains(const QRectF &r) const Q_DECL_NOTHROW; bool contains(const QPointF &p) const Q_DECL_NOTHROW; inline bool contains(qreal x, qreal y) const Q_DECL_NOTHROW; - inline QRectF united(const QRectF &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - inline QRectF intersected(const QRectF &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT inline QRectF united(const QRectF &other) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT inline QRectF intersected(const QRectF &other) const Q_DECL_NOTHROW; bool intersects(const QRectF &r) const Q_DECL_NOTHROW; Q_DECL_CONSTEXPR inline QRectF marginsAdded(const QMarginsF &margins) const Q_DECL_NOTHROW; @@ -602,19 +602,19 @@ public: Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator-=(const QMarginsF &margins) Q_DECL_NOTHROW; #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED QRectF unite(const QRectF &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return united(r); } - QT_DEPRECATED QRectF intersect(const QRectF &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return intersected(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRectF unite(const QRectF &r) const Q_DECL_NOTHROW { return united(r); } + Q_REQUIRED_RESULT QT_DEPRECATED QRectF intersect(const QRectF &r) const Q_DECL_NOTHROW { return intersected(r); } #endif friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) Q_DECL_NOTHROW; friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - QRect toAlignedRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QRect toAlignedRect() const Q_DECL_NOTHROW; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW Q_REQUIRED_RESULT; - CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW; #endif private: diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h index cd5f8adbf5..bb29dca7c4 100644 --- a/src/corelib/tools/qsize.h +++ b/src/corelib/tools/qsize.h @@ -64,15 +64,15 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) Q_DECL_NOTHROW; void transpose() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW; inline void scale(int w, int h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; inline void scale(const QSize &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline int &rwidth() Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline int &rheight() Q_DECL_NOTHROW; @@ -91,7 +91,7 @@ public: friend inline const QSize operator/(const QSize &, qreal); #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW; #endif private: @@ -228,15 +228,15 @@ public: Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) Q_DECL_NOTHROW; void transpose() Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW; inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; inline void scale(const QSizeF &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW; - QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW; - Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline qreal &rwidth() Q_DECL_NOTHROW; Q_DECL_RELAXED_CONSTEXPR inline qreal &rheight() Q_DECL_NOTHROW; @@ -257,8 +257,8 @@ public: Q_DECL_CONSTEXPR inline QSize toSize() const Q_DECL_NOTHROW; #if defined(Q_OS_DARWIN) || defined(Q_QDOC) - static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW Q_REQUIRED_RESULT; - CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW; #endif private: diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 09a3bcb521..f81a58813d 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -261,47 +261,47 @@ public: const QChar operator[](uint i) const; QCharRef operator[](uint i); - QString arg(qlonglong a, int fieldwidth=0, int base=10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(qulonglong a, int fieldwidth=0, int base=10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(long a, int fieldwidth=0, int base=10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(ulong a, int fieldwidth=0, int base=10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(int a, int fieldWidth = 0, int base = 10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(uint a, int fieldWidth = 0, int base = 10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(short a, int fieldWidth = 0, int base = 10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(ushort a, int fieldWidth = 0, int base = 10, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(char a, int fieldWidth = 0, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(QChar a, int fieldWidth = 0, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(const QString &a, int fieldWidth = 0, - QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, - const QString &a4) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, - const QString &a4, const QString &a5) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, - const QString &a4, const QString &a5, const QString &a6) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, + Q_REQUIRED_RESULT QString arg(qlonglong a, int fieldwidth=0, int base=10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(qulonglong a, int fieldwidth=0, int base=10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(long a, int fieldwidth=0, int base=10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(ulong a, int fieldwidth=0, int base=10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(int a, int fieldWidth = 0, int base = 10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(uint a, int fieldWidth = 0, int base = 10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(short a, int fieldWidth = 0, int base = 10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(ushort a, int fieldWidth = 0, int base = 10, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(char a, int fieldWidth = 0, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(QChar a, int fieldWidth = 0, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(const QString &a, int fieldWidth = 0, + QChar fillChar = QLatin1Char(' ')) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a4) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a4, const QString &a5) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a4, const QString &a5, const QString &a6) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, - const QString &a7) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a7) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, - const QString &a7, const QString &a8) const Q_REQUIRED_RESULT; - QString arg(const QString &a1, const QString &a2, const QString &a3, + const QString &a7, const QString &a8) const; + Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, - const QString &a7, const QString &a8, const QString &a9) const Q_REQUIRED_RESULT; + const QString &a7, const QString &a8, const QString &a9) const; QString &vsprintf(const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(2, 0); QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); @@ -363,12 +363,12 @@ public: #ifndef QT_NO_REGULAREXPRESSION QString section(const QRegularExpression &re, int start, int end = -1, SectionFlags flags = SectionDefault) const; #endif - QString left(int n) const Q_REQUIRED_RESULT; - QString right(int n) const Q_REQUIRED_RESULT; - QString mid(int position, int n = -1) const Q_REQUIRED_RESULT; - QStringRef leftRef(int n) const Q_REQUIRED_RESULT; - QStringRef rightRef(int n) const Q_REQUIRED_RESULT; - QStringRef midRef(int position, int n = -1) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString left(int n) const; + Q_REQUIRED_RESULT QString right(int n) const; + Q_REQUIRED_RESULT QString mid(int position, int n = -1) const; + Q_REQUIRED_RESULT QStringRef leftRef(int n) const; + Q_REQUIRED_RESULT QStringRef rightRef(int n) const; + Q_REQUIRED_RESULT QStringRef midRef(int position, int n = -1) const; bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -379,8 +379,8 @@ public: bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; - QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; - QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const; + Q_REQUIRED_RESULT QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const; #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) # if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) @@ -390,37 +390,37 @@ public: # define Q_REQUIRED_RESULT # define Q_REQUIRED_RESULT_pushed # endif - Q_ALWAYS_INLINE QString toLower() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toLower() const & { return toLower_helper(*this); } - Q_ALWAYS_INLINE QString toLower() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toLower() && { return toLower_helper(*this); } - Q_ALWAYS_INLINE QString toUpper() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toUpper() const & { return toUpper_helper(*this); } - Q_ALWAYS_INLINE QString toUpper() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toUpper() && { return toUpper_helper(*this); } - Q_ALWAYS_INLINE QString toCaseFolded() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toCaseFolded() const & { return toCaseFolded_helper(*this); } - Q_ALWAYS_INLINE QString toCaseFolded() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toCaseFolded() && { return toCaseFolded_helper(*this); } - Q_ALWAYS_INLINE QString trimmed() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString trimmed() const & { return trimmed_helper(*this); } - Q_ALWAYS_INLINE QString trimmed() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString trimmed() && { return trimmed_helper(*this); } - Q_ALWAYS_INLINE QString simplified() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString simplified() const & { return simplified_helper(*this); } - Q_ALWAYS_INLINE QString simplified() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString simplified() && { return simplified_helper(*this); } # ifdef Q_REQUIRED_RESULT_pushed # pragma pop_macro("Q_REQUIRED_RESULT") # endif #else - QString toLower() const Q_REQUIRED_RESULT; - QString toUpper() const Q_REQUIRED_RESULT; - QString toCaseFolded() const Q_REQUIRED_RESULT; - QString trimmed() const Q_REQUIRED_RESULT; - QString simplified() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString toLower() const; + Q_REQUIRED_RESULT QString toUpper() const; + Q_REQUIRED_RESULT QString toCaseFolded() const; + Q_REQUIRED_RESULT QString trimmed() const; + Q_REQUIRED_RESULT QString simplified() const; #endif - QString toHtmlEscaped() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString toHtmlEscaped() const; QString &insert(int i, QChar c); QString &insert(int i, const QChar *uc, int len); @@ -479,21 +479,21 @@ public: enum SplitBehavior { KeepEmptyParts, SkipEmptyParts }; - QStringList split(const QString &sep, SplitBehavior behavior = KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; - QVector splitRef(const QString &sep, SplitBehavior behavior = KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; - QStringList split(QChar sep, SplitBehavior behavior = KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; - QVector splitRef(QChar sep, SplitBehavior behavior = KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringList split(const QString &sep, SplitBehavior behavior = KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + Q_REQUIRED_RESULT QVector splitRef(const QString &sep, SplitBehavior behavior = KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + Q_REQUIRED_RESULT QStringList split(QChar sep, SplitBehavior behavior = KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + Q_REQUIRED_RESULT QVector splitRef(QChar sep, SplitBehavior behavior = KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #ifndef QT_NO_REGEXP - QStringList split(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT; - QVector splitRef(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringList split(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const; + Q_REQUIRED_RESULT QVector splitRef(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const; #endif #ifndef QT_NO_REGULAREXPRESSION - QStringList split(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT; - QVector splitRef(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringList split(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const; + Q_REQUIRED_RESULT QVector splitRef(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const; #endif enum NormalizationForm { NormalizationForm_D, @@ -501,31 +501,31 @@ public: NormalizationForm_KD, NormalizationForm_KC }; - QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const; - QString repeated(int times) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QString repeated(int times) const; const ushort *utf16() const; #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) - QByteArray toLatin1() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toLatin1() const & { return toLatin1_helper(*this); } - QByteArray toLatin1() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toLatin1() && { return toLatin1_helper_inplace(*this); } - QByteArray toUtf8() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toUtf8() const & { return toUtf8_helper(*this); } - QByteArray toUtf8() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toUtf8() && { return toUtf8_helper(*this); } - QByteArray toLocal8Bit() const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toLocal8Bit() const & { return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); } - QByteArray toLocal8Bit() && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toLocal8Bit() && { return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); } #else - QByteArray toLatin1() const Q_REQUIRED_RESULT; - QByteArray toUtf8() const Q_REQUIRED_RESULT; - QByteArray toLocal8Bit() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray toLatin1() const; + Q_REQUIRED_RESULT QByteArray toUtf8() const; + Q_REQUIRED_RESULT QByteArray toLocal8Bit() const; #endif - QVector toUcs4() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QVector toUcs4() const; // note - this are all inline so we can benefit from strlen() compile time optimizations static inline QString fromLatin1(const char *str, int size = -1) @@ -563,12 +563,12 @@ public: { return fromLatin1(str, size); } QT_DEPRECATED static inline QString fromAscii(const QByteArray &str) { return fromLatin1(str); } - QByteArray toAscii() const Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QByteArray toAscii() const { return toLatin1(); } #endif inline int toWCharArray(wchar_t *array) const; - static inline QString fromWCharArray(const wchar_t *string, int size = -1) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT static inline QString fromWCharArray(const wchar_t *string, int size = -1); QString &setRawData(const QChar *unicode, int size); QString &setUnicode(const QChar *unicode, int size); @@ -1425,14 +1425,14 @@ public: int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; - QVector split(const QString &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; - QVector split(QChar sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, - Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QVector split(const QString &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + Q_REQUIRED_RESULT QVector split(QChar sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; - QStringRef left(int n) const Q_REQUIRED_RESULT; - QStringRef right(int n) const Q_REQUIRED_RESULT; - QStringRef mid(int pos, int n = -1) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringRef left(int n) const; + Q_REQUIRED_RESULT QStringRef right(int n) const; + Q_REQUIRED_RESULT QStringRef mid(int pos, int n = -1) const; void truncate(int pos) Q_DECL_NOTHROW { m_size = qBound(0, pos, m_size); } void chop(int n) Q_DECL_NOTHROW @@ -1478,13 +1478,13 @@ public: inline const_reverse_iterator crend() const { return rend(); } #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED QByteArray toAscii() const Q_REQUIRED_RESULT + Q_REQUIRED_RESULT QT_DEPRECATED QByteArray toAscii() const { return toLatin1(); } #endif - QByteArray toLatin1() const Q_REQUIRED_RESULT; - QByteArray toUtf8() const Q_REQUIRED_RESULT; - QByteArray toLocal8Bit() const Q_REQUIRED_RESULT; - QVector toUcs4() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QByteArray toLatin1() const; + Q_REQUIRED_RESULT QByteArray toUtf8() const; + Q_REQUIRED_RESULT QByteArray toLocal8Bit() const; + Q_REQUIRED_RESULT QVector toUcs4() const; inline void clear() { m_string = Q_NULLPTR; m_position = m_size = 0; } QString toString() const; @@ -1526,7 +1526,7 @@ public: static int localeAwareCompare(const QStringRef &s1, const QString &s2); static int localeAwareCompare(const QStringRef &s1, const QStringRef &s2); - QStringRef trimmed() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QStringRef trimmed() const; short toShort(bool *ok = Q_NULLPTR, int base = 10) const; ushort toUShort(bool *ok = Q_NULLPTR, int base = 10) const; int toInt(bool *ok = Q_NULLPTR, int base = 10) const; diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h index 0038908160..74b79dce16 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/tools/qtimezoneprivate_p.h @@ -154,12 +154,12 @@ public: QLocale::Country country); // returns "UTC" QString and QByteArray - static inline QString utcQString() Q_REQUIRED_RESULT + Q_REQUIRED_RESULT static inline QString utcQString() { return QStringLiteral("UTC"); } - static inline QByteArray utcQByteArray() Q_REQUIRED_RESULT + Q_REQUIRED_RESULT static inline QByteArray utcQByteArray() { return QByteArrayLiteral("UTC"); } diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index 2aaa6201f7..d3cf743a67 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -248,39 +248,39 @@ public: inline explicit QVersionNumber(int maj, int min, int mic) { m_segments.setSegments(3, maj, min, mic); } - inline bool isNull() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline bool isNull() const Q_DECL_NOTHROW { return segmentCount() == 0; } - inline bool isNormalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline bool isNormalized() const Q_DECL_NOTHROW { return isNull() || segmentAt(segmentCount() - 1) != 0; } - inline int majorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int majorVersion() const Q_DECL_NOTHROW { return segmentAt(0); } - inline int minorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int minorVersion() const Q_DECL_NOTHROW { return segmentAt(1); } - inline int microVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int microVersion() const Q_DECL_NOTHROW { return segmentAt(2); } - Q_CORE_EXPORT QVersionNumber normalized() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT QVersionNumber normalized() const; - Q_CORE_EXPORT QVector segments() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT QVector segments() const; - inline int segmentAt(int index) const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int segmentAt(int index) const Q_DECL_NOTHROW { return (m_segments.size() > index) ? m_segments.at(index) : 0; } - inline int segmentCount() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + Q_REQUIRED_RESULT inline int segmentCount() const Q_DECL_NOTHROW { return m_segments.size(); } - Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW; - Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW; - Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2); - Q_CORE_EXPORT QString toString() const Q_REQUIRED_RESULT; - Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = Q_NULLPTR) Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const; + Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = Q_NULLPTR); private: #ifndef QT_NO_DATASTREAM diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 204e7a54b2..225ef3d2e8 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -179,9 +179,9 @@ public: Format format() const; #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QIMAGE_COMPAT_CPP) - Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const & Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const & { return convertToFormat_helper(f, flags); } - Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) && Q_REQUIRED_RESULT + Q_REQUIRED_RESULT Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) && { if (convertToFormat_inplace(f, flags)) return std::move(*this); @@ -189,9 +189,9 @@ public: return convertToFormat_helper(f, flags); } #else - QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const; #endif - QImage convertToFormat(Format f, const QVector &colorTable, Qt::ImageConversionFlags flags = Qt::AutoColor) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QImage convertToFormat(Format f, const QVector &colorTable, Qt::ImageConversionFlags flags = Qt::AutoColor) const; bool reinterpretAsFormat(Format f); int width() const; diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h index 9a1ab54124..6a2a9e5bae 100644 --- a/src/gui/math3d/qgenericmatrix.h +++ b/src/gui/math3d/qgenericmatrix.h @@ -64,7 +64,7 @@ public: void fill(T value); - QGenericMatrix transposed() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QGenericMatrix transposed() const; QGenericMatrix& operator+=(const QGenericMatrix& other); QGenericMatrix& operator-=(const QGenericMatrix& other); diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index eff427117f..7f7f89db4d 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -90,14 +90,14 @@ public: float length() const; float lengthSquared() const; - QQuaternion normalized() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QQuaternion normalized() const; void normalize(); inline QQuaternion inverted() const; - QQuaternion conjugated() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QQuaternion conjugated() const; #if QT_DEPRECATED_SINCE(5, 5) - QT_DEPRECATED QQuaternion conjugate() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QT_DEPRECATED QQuaternion conjugate() const; #endif QVector3D rotatedVector(const QVector3D& vector) const; diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index bdb56c9c1f..5e0394b998 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -82,7 +82,7 @@ public: float length() const; float lengthSquared() const; //In Qt 6 convert to inline and constexpr - QVector2D normalized() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QVector2D normalized() const; void normalize(); float distanceToPoint(const QVector2D &point) const; diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index f63b2f141b..be373aa806 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -88,7 +88,7 @@ public: float length() const; float lengthSquared() const; //In Qt 6 convert to inline and constexpr - QVector4D normalized() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QVector4D normalized() const; void normalize(); QVector4D &operator+=(const QVector4D &vector); diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index 22fcbcb2a8..83a93e25ea 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -191,7 +191,7 @@ public: QColor toCmyk() const Q_DECL_NOTHROW; QColor toHsl() const Q_DECL_NOTHROW; - QColor convertTo(Spec colorSpec) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QColor convertTo(Spec colorSpec) const Q_DECL_NOTHROW; static QColor fromRgb(QRgb rgb) Q_DECL_NOTHROW; static QColor fromRgba(QRgb rgba) Q_DECL_NOTHROW; @@ -211,10 +211,10 @@ public: static QColor fromHsl(int h, int s, int l, int a = 255); static QColor fromHslF(qreal h, qreal s, qreal l, qreal a = 1.0); - QColor light(int f = 150) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - QColor lighter(int f = 150) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - QColor dark(int f = 200) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; - QColor darker(int f = 200) const Q_DECL_NOTHROW Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QColor light(int f = 150) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QColor lighter(int f = 150) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QColor dark(int f = 200) const Q_DECL_NOTHROW; + Q_REQUIRED_RESULT QColor darker(int f = 200) const Q_DECL_NOTHROW; bool operator==(const QColor &c) const Q_DECL_NOTHROW; bool operator!=(const QColor &c) const Q_DECL_NOTHROW; diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index 76bf61671c..15e0ab5be1 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -108,7 +108,7 @@ public: bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); } qreal determinant() const { return _m11*_m22 - _m12*_m21; } - QMatrix inverted(bool *invertible = Q_NULLPTR) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QMatrix inverted(bool *invertible = Q_NULLPTR) const; bool operator==(const QMatrix &) const; bool operator!=(const QMatrix &) const; diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index 131fcde8cc..db39c1c5a0 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -154,8 +154,8 @@ public: void translate(qreal dx, qreal dy); inline void translate(const QPointF &offset); - QPainterPath translated(qreal dx, qreal dy) const Q_REQUIRED_RESULT; - inline QPainterPath translated(const QPointF &offset) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QPainterPath translated(qreal dx, qreal dy) const; + Q_REQUIRED_RESULT inline QPainterPath translated(const QPointF &offset) const; QRectF boundingRect() const; QRectF controlPointRect() const; @@ -165,7 +165,7 @@ public: bool isEmpty() const; - QPainterPath toReversed() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QPainterPath toReversed() const; QList toSubpathPolygons(const QMatrix &matrix = QMatrix()) const; QList toFillPolygons(const QMatrix &matrix = QMatrix()) const; QPolygonF toFillPolygon(const QMatrix &matrix = QMatrix()) const; @@ -185,12 +185,12 @@ public: bool intersects(const QPainterPath &p) const; bool contains(const QPainterPath &p) const; - QPainterPath united(const QPainterPath &r) const Q_REQUIRED_RESULT; - QPainterPath intersected(const QPainterPath &r) const Q_REQUIRED_RESULT; - QPainterPath subtracted(const QPainterPath &r) const Q_REQUIRED_RESULT; - QPainterPath subtractedInverted(const QPainterPath &r) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QPainterPath united(const QPainterPath &r) const; + Q_REQUIRED_RESULT QPainterPath intersected(const QPainterPath &r) const; + Q_REQUIRED_RESULT QPainterPath subtracted(const QPainterPath &r) const; + Q_REQUIRED_RESULT QPainterPath subtractedInverted(const QPainterPath &r) const; - QPainterPath simplified() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QPainterPath simplified() const; bool operator==(const QPainterPath &other) const; bool operator!=(const QPainterPath &other) const; diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h index c57802e84e..f192e8d10b 100644 --- a/src/gui/painting/qpolygon.h +++ b/src/gui/painting/qpolygon.h @@ -78,8 +78,8 @@ public: void translate(int dx, int dy); void translate(const QPoint &offset); - QPolygon translated(int dx, int dy) const Q_REQUIRED_RESULT; - inline QPolygon translated(const QPoint &offset) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QPolygon translated(int dx, int dy) const; + Q_REQUIRED_RESULT inline QPolygon translated(const QPoint &offset) const; QRect boundingRect() const; @@ -95,9 +95,9 @@ public: bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const; - QPolygon united(const QPolygon &r) const Q_REQUIRED_RESULT; - QPolygon intersected(const QPolygon &r) const Q_REQUIRED_RESULT; - QPolygon subtracted(const QPolygon &r) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QPolygon united(const QPolygon &r) const; + Q_REQUIRED_RESULT QPolygon intersected(const QPolygon &r) const; + Q_REQUIRED_RESULT QPolygon subtracted(const QPolygon &r) const; }; Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QPolygon) @@ -162,7 +162,7 @@ public: void translate(const QPointF &offset); inline QPolygonF translated(qreal dx, qreal dy) const; - QPolygonF translated(const QPointF &offset) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QPolygonF translated(const QPointF &offset) const; QPolygon toPolygon() const; @@ -172,9 +172,9 @@ public: bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const; - QPolygonF united(const QPolygonF &r) const Q_REQUIRED_RESULT; - QPolygonF intersected(const QPolygonF &r) const Q_REQUIRED_RESULT; - QPolygonF subtracted(const QPolygonF &r) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QPolygonF united(const QPolygonF &r) const; + Q_REQUIRED_RESULT QPolygonF intersected(const QPolygonF &r) const; + Q_REQUIRED_RESULT QPolygonF subtracted(const QPolygonF &r) const; }; Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QPolygonF) diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 4f0a071da8..8dd7649447 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -99,23 +99,23 @@ public: void translate(int dx, int dy); inline void translate(const QPoint &p) { translate(p.x(), p.y()); } - QRegion translated(int dx, int dy) const Q_REQUIRED_RESULT; - inline QRegion translated(const QPoint &p) const Q_REQUIRED_RESULT { return translated(p.x(), p.y()); } + Q_REQUIRED_RESULT QRegion translated(int dx, int dy) const; + Q_REQUIRED_RESULT inline QRegion translated(const QPoint &p) const { return translated(p.x(), p.y()); } - QRegion united(const QRegion &r) const Q_REQUIRED_RESULT; - QRegion united(const QRect &r) const Q_REQUIRED_RESULT; - QRegion intersected(const QRegion &r) const Q_REQUIRED_RESULT; - QRegion intersected(const QRect &r) const Q_REQUIRED_RESULT; - QRegion subtracted(const QRegion &r) const Q_REQUIRED_RESULT; - QRegion xored(const QRegion &r) const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QRegion united(const QRegion &r) const; + Q_REQUIRED_RESULT QRegion united(const QRect &r) const; + Q_REQUIRED_RESULT QRegion intersected(const QRegion &r) const; + Q_REQUIRED_RESULT QRegion intersected(const QRect &r) const; + Q_REQUIRED_RESULT QRegion subtracted(const QRegion &r) const; + Q_REQUIRED_RESULT QRegion xored(const QRegion &r) const; #if QT_DEPRECATED_SINCE(5, 0) - inline QT_DEPRECATED QRegion unite(const QRegion &r) const Q_REQUIRED_RESULT { return united(r); } - inline QT_DEPRECATED QRegion unite(const QRect &r) const Q_REQUIRED_RESULT { return united(r); } - inline QT_DEPRECATED QRegion intersect(const QRegion &r) const Q_REQUIRED_RESULT { return intersected(r); } - inline QT_DEPRECATED QRegion intersect(const QRect &r) const Q_REQUIRED_RESULT { return intersected(r); } - inline QT_DEPRECATED QRegion subtract(const QRegion &r) const Q_REQUIRED_RESULT { return subtracted(r); } - inline QT_DEPRECATED QRegion eor(const QRegion &r) const Q_REQUIRED_RESULT { return xored(r); } + Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion unite(const QRegion &r) const { return united(r); } + Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion unite(const QRect &r) const { return united(r); } + Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion intersect(const QRegion &r) const { return intersected(r); } + Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion intersect(const QRect &r) const { return intersected(r); } + Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion subtract(const QRegion &r) const { return subtracted(r); } + Q_REQUIRED_RESULT inline QT_DEPRECATED QRegion eor(const QRegion &r) const { return xored(r); } #endif bool intersects(const QRegion &r) const; diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index 5ca1d46982..06ae611861 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -116,9 +116,9 @@ public: qreal m21, qreal m22, qreal m23, qreal m31, qreal m32, qreal m33); - QTransform inverted(bool *invertible = Q_NULLPTR) const Q_REQUIRED_RESULT; - QTransform adjoint() const Q_REQUIRED_RESULT; - QTransform transposed() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT QTransform inverted(bool *invertible = Q_NULLPTR) const; + Q_REQUIRED_RESULT QTransform adjoint() const; + Q_REQUIRED_RESULT QTransform transposed() const; QTransform &translate(qreal dx, qreal dy); QTransform &scale(qreal sx, qreal sy); diff --git a/src/network/ssl/qsslellipticcurve.h b/src/network/ssl/qsslellipticcurve.h index 0e7cc60e31..231566063e 100644 --- a/src/network/ssl/qsslellipticcurve.h +++ b/src/network/ssl/qsslellipticcurve.h @@ -64,8 +64,8 @@ public: Q_NETWORK_EXPORT static QSslEllipticCurve fromShortName(const QString &name); Q_NETWORK_EXPORT static QSslEllipticCurve fromLongName(const QString &name); - Q_NETWORK_EXPORT QString shortName() const Q_REQUIRED_RESULT; - Q_NETWORK_EXPORT QString longName() const Q_REQUIRED_RESULT; + Q_REQUIRED_RESULT Q_NETWORK_EXPORT QString shortName() const; + Q_REQUIRED_RESULT Q_NETWORK_EXPORT QString longName() const; Q_DECL_CONSTEXPR bool isValid() const Q_DECL_NOTHROW { diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 6cb4e147e9..dba742dec5 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -159,10 +159,11 @@ public: Q_DECL_RELAXED_CONSTEXPR void setRetainSizeWhenHidden(bool retainSize) Q_DECL_NOTHROW { bits.retainSizeWhenHidden = retainSize; } Q_DECL_RELAXED_CONSTEXPR void transpose() Q_DECL_NOTHROW { *this = transposed(); } + Q_REQUIRED_RESULT #ifndef Q_QDOC QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT #endif - QSizePolicy transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + QSizePolicy transposed() const Q_DECL_NOTHROW { return QSizePolicy(bits.transposed()); } -- cgit v1.2.3 From 126c4eae84fee0e5bc4e9c6db167d92e87b7f612 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 30 Mar 2017 19:49:32 +0200 Subject: Split Q_COMPILER_UNICODE_STRINGS: add Q_STDLIB_UNICODE_STRINGS Since commit bf2160e72cd8840a8e604438cbdc807483ac980a, we can rely on charNN_t support in all compilers except MSVC 2013, and since that commit, we use (in 5.10, not 5.9, yet) !defined(Q_OS_WIN) || defined(Q_COMPILER_UNICODE_STRINGS) when we only need charNN_t, the type, as opposed to its library support (u16string, char_traits, ...). This patch splits the Q_C_UNICODE_STRINGS macro into two, adding Q_STDLIB_UNICODE_STRINGS for when we need std::uNNstring, leaving Q_C_UNICODE_STRINGS for when we need just charNN_t support. In QDebug, when constructing a QChar out of a char16_t, cast to ushort first, since QChar(char16_t) was only officially introduced in Qt 5.10. [ChangeLog][Potentially Source-Incompatible Changes] The internal Q_COMPILER_UNICODE_STRINGS macro is now defined if the compiler supports charNN_t, even if the standard library does not. To check for availability of std::uNNstring, use the new Q_STDLIB_UNICODE_STRINGS macro. Change-Id: I8f210fd7f1799fe21faf54506475a759b1f76a59 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 7 ++++++- src/corelib/io/qdebug.h | 2 +- src/corelib/tools/qstring.h | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 5497b9e14a..5fc7ac9c7e 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -994,6 +994,10 @@ # endif /* __cplusplus */ #endif /* Q_CC_MSVC */ +#ifdef Q_COMPILER_UNICODE_STRINGS +# define Q_STDLIB_UNICODE_STRINGS +#endif + #ifdef __cplusplus # include # if defined(Q_OS_QNX) @@ -1016,8 +1020,9 @@ # undef Q_COMPILER_INITIALIZER_LISTS # undef Q_COMPILER_RVALUE_REFS # undef Q_COMPILER_REF_QUALIFIERS -# undef Q_COMPILER_UNICODE_STRINGS # undef Q_COMPILER_NOEXCEPT +// Disable C++11 library features: +# undef Q_STDLIB_UNICODE_STRINGS # endif // !_HAS_CPP0X # if !defined(_HAS_NULLPTR_T) || !_HAS_NULLPTR_T # undef Q_COMPILER_NULLPTR diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 61059dd694..186722b69b 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -139,7 +139,7 @@ public: inline QDebug &operator<<(signed short t) { stream->ts << t; return maybeSpace(); } inline QDebug &operator<<(unsigned short t) { stream->ts << t; return maybeSpace(); } #ifdef Q_COMPILER_UNICODE_STRINGS - inline QDebug &operator<<(char16_t t) { return *this << QChar(t); } + inline QDebug &operator<<(char16_t t) { return *this << QChar(ushort(t)); } inline QDebug &operator<<(char32_t t) { putUcs4(t); return maybeSpace(); } #endif inline QDebug &operator<<(signed int t) { stream->ts << t; return maybeSpace(); } diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index f81a58813d..109b68c544 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -756,7 +756,7 @@ public: static inline QString fromStdWString(const std::wstring &s); inline std::wstring toStdWString() const; -#if defined(Q_COMPILER_UNICODE_STRINGS) || defined(Q_QDOC) +#if defined(Q_STDLIB_UNICODE_STRINGS) || defined(Q_QDOC) static inline QString fromStdU16String(const std::u16string &s); inline std::u16string toStdU16String() const; static inline QString fromStdU32String(const std::u32string &s); @@ -1339,7 +1339,7 @@ inline std::wstring QString::toStdWString() const inline QString QString::fromStdWString(const std::wstring &s) { return fromWCharArray(s.data(), int(s.size())); } -#if defined(Q_COMPILER_UNICODE_STRINGS) +#if defined(Q_STDLIB_UNICODE_STRINGS) inline QString QString::fromStdU16String(const std::u16string &s) { return fromUtf16(s.data(), int(s.size())); } -- cgit v1.2.3