diff options
98 files changed, 772 insertions, 419 deletions
diff --git a/config.tests/arch/arch.cpp b/config.tests/arch/arch.cpp index f99c5ca118..bb3efec177 100644 --- a/config.tests/arch/arch.cpp +++ b/config.tests/arch/arch.cpp @@ -284,8 +284,12 @@ const char msg2[] = "==Qt=magic=Qt== Sub-architecture:" #endif ""; +extern const char msg3[]; +const char msg3[] = "==Qt=magic=Qt== Build-ABI:" ARCH_FULL; + int main() { puts(msg); puts(msg2); + puts(msg3); } diff --git a/config.tests/unix/pcre2/pcre2.cpp b/config.tests/unix/pcre2/pcre2.cpp index 48130f97c4..9c94d29999 100644 --- a/config.tests/unix/pcre2/pcre2.cpp +++ b/config.tests/unix/pcre2/pcre2.cpp @@ -37,9 +37,11 @@ ** ****************************************************************************/ +#define PCRE2_CODE_UNIT_WIDTH 16 + #include <pcre2.h> -#if (PCRE2_MAJOR < 10) || ((PCRE2_MAJOR == 10) && (PCRE_MINOR < 20)) +#if (PCRE2_MAJOR < 10) || ((PCRE2_MAJOR == 10) && (PCRE2_MINOR < 20)) #error This PCRE version is not supported #endif diff --git a/configure.pri b/configure.pri index 42f3247a59..c422c73650 100644 --- a/configure.pri +++ b/configure.pri @@ -258,15 +258,18 @@ defineTest(qtConfTest_architecture) { arch_magic = ".*==Qt=magic=Qt== Architecture:([^\\0]*).*" subarch_magic = ".*==Qt=magic=Qt== Sub-architecture:([^\\0]*).*" + buildabi_magic = ".*==Qt=magic=Qt== Build-ABI:([^\\0]*).*" - !contains(content, $$arch_magic)|!contains(content, $$subarch_magic): \ + !contains(content, $$arch_magic)|!contains(content, $$subarch_magic)|!contains(content, $$buildabi_magic): \ error("$$eval($${1}.label) detection binary does not contain expected data.") $${1}.arch = $$replace(content, $$arch_magic, "\\1") $${1}.subarch = $$replace(content, $$subarch_magic, "\\1") $${1}.subarch = $$split($${1}.subarch, " ") + $${1}.buildabi = $$replace(content, $$buildabi_magic, "\\1") export($${1}.arch) export($${1}.subarch) + export($${1}.buildabi) qtLog("Detected architecture: $$eval($${1}.arch) ($$eval($${1}.subarch))") $${1}.cache += arch subarch @@ -869,9 +872,11 @@ defineTest(qtConfOutput_shared) { defineTest(qtConfOutput_architecture) { arch = $$qtConfEvaluate("tests.architecture.arch") + buildabi = $$qtConfEvaluate("tests.architecture.buildabi") $$qtConfEvaluate("features.cross_compile") { host_arch = $$qtConfEvaluate("tests.host_architecture.arch") + host_buildabi = $$qtConfEvaluate("tests.host_architecture.buildabi") privatePro = \ "host_build {" \ @@ -883,15 +888,18 @@ defineTest(qtConfOutput_architecture) { "host_build {" \ " QT_ARCH = $$host_arch" \ " QT_TARGET_ARCH = $$arch" \ + " QT_TARGET_BUILDABI = $$buildabi" \ "} else {" \ " QT_ARCH = $$arch" \ + " QT_BUILDABI = $$host_buildabi" \ "}" } else { privatePro = \ "QT_CPU_FEATURES.$$arch = $$qtConfEvaluate('tests.architecture.subarch')" publicPro = \ - "QT_ARCH = $$arch" + "QT_ARCH = $$arch" \ + "QT_BUILDABI = $$buildabi" } $${currentConfig}.output.publicPro += $$publicPro diff --git a/doc/global/externalsites/qtcreator.qdoc b/doc/global/externalsites/qtcreator.qdoc index 0e66610d84..bfa467da57 100644 --- a/doc/global/externalsites/qtcreator.qdoc +++ b/doc/global/externalsites/qtcreator.qdoc @@ -551,3 +551,7 @@ \externalpage http://doc.qt.io/qtcreator/creator-autotest.html \title Qt Creator: Running Autotests */ +/*! + \externalpage http://doc.qt.io/qtcreator/creator-project-creating.html#creating-c-classes + \title Qt Creator: Creating C++ Classes +*/ diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index ceb93fde2d..4342391809 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -1581,6 +1581,14 @@ qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \target QMAKE_DEVELOPMENT_TEAM + \section1 QMAKE_DEVELOPMENT_TEAM + + \note This variable is used on \macos, iOS, tvOS, and watchOS only. + + The identifier of a development team to use for signing certificates + and provisioning profiles. + \target QMAKE_DISTCLEAN \section1 QMAKE_DISTCLEAN @@ -2076,6 +2084,17 @@ files for IDEs. The default value is the target name. The value of this variable is typically handled by qmake and rarely needs to be modified. + \target QMAKE_PROVISIONING_PROFILE + \section1 QMAKE_PROVISIONING_PROFILE + + \note This variable is used on \macos, iOS, tvOS, and watchOS only. + + The UUID of a valid provisioning profile. Use in conjunction with + \l{QMAKE_DEVELOPMENT_TEAM} to specify the provisioning profile. + + \note Specifying the provisioning profile disables the automatically + managed signing. + \section1 QMAKE_MAC_SDK This variable is used on \macos when building universal binaries. @@ -3151,6 +3170,7 @@ See also \l{fn_size}{size()}. + \target system_replace \section2 system(command[, mode[, stsvar]]) You can use this variant of the \c system function to obtain stdout from the @@ -3498,7 +3518,7 @@ \snippet code/doc_src_qmake-manual.pro 71 - See also the replace variant of \l{system(command[, mode])}{system()}. + See also the replace variant of \l{system_replace}{system()}. \target touchfunction \section2 touch(filename, reference_filename) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 94a2363594..70f40915b2 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -348,6 +348,7 @@ public class QtNative // application methods public static native void startQtApplication(String params, String env); public static native boolean startQtAndroidPlugin(); + public static native void quitQtCoreApplication(); public static native void quitQtAndroidPlugin(); public static native void terminateQt(); // application methods diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java index 5ac406c710..035a65a84c 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java @@ -185,6 +185,6 @@ public class QtServiceDelegate public void onDestroy() { - QtNative.setService(null, null); + QtNative.quitQtCoreApplication(); } } diff --git a/src/angle/src/common/common.pri b/src/angle/src/common/common.pri index 3da59c61e2..7305362d86 100644 --- a/src/angle/src/common/common.pri +++ b/src/angle/src/common/common.pri @@ -30,29 +30,11 @@ winrt|msvc { error("Cannot determine DirectX SDK location. Please set DXSDK_DIR environment variable.") } - DXINC_DIR = $${DX_DIR}Include - contains(QT_ARCH, x86_64) { - DXLIB_DIR = $${DX_DIR}Lib\\x64 - } else { - DXLIB_DIR = $${DX_DIR}Lib\\x86 - } - equals(QMAKE_TARGET.arch, x86_64) { FXC = \"$${DX_DIR}Utilities\\bin\\x64\\fxc.exe\" } else { FXC = \"$${DX_DIR}Utilities\\bin\\x86\\fxc.exe\" } - - msvc { - # Unfortunately MinGW cannot use the DirectX headers from the DX SDK because d3d11shader.h uses - # buffer annotation macros (eg: __out, __in) which are not defined in the MinGW copy of - # specstrings_strict.h - INCLUDEPATH += $$DXINC_DIR - - # Similarly we want the MinGW linker to use the import libraries shipped with the compiler - # instead of those from the SDK which cause a crash on startup. - LIBS_PRIVATE += -L$$DXLIB_DIR - } } static: DEFINES *= LIBGLESV2_EXPORT_H_ ANGLE_EXPORT= diff --git a/src/corelib/global/qglobal_p.h b/src/corelib/global/qglobal_p.h index b8f9e5fbf7..b1d2836783 100644 --- a/src/corelib/global/qglobal_p.h +++ b/src/corelib/global/qglobal_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** ** Copyright (C) 2015 Intel Corporation. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 4f7bc95330..ff865dc9a1 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -215,7 +215,7 @@ void QLoggingSettingsParser::setContent(QTextStream &stream) continue; } - if (_section.toLower() == QLatin1String("rules")) { + if (_section.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0) { int equalPos = line.indexOf(QLatin1Char('=')); if (equalPos != -1) { if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index e4631bad12..2a08ee2e64 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -211,7 +211,7 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value) default: QString string = QSettingsPrivate::variantToString(value); if (string.contains(QChar::Null)) - result = string.toUtf8().toCFData(); + result = std::move(string).toUtf8().toCFData(); else result = string.toCFString(); } @@ -419,14 +419,13 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString & curPos = nextDot + 1; } javaPackageName.prepend(domainName.midRef(curPos)); - javaPackageName = javaPackageName.toLower(); + javaPackageName = std::move(javaPackageName).toLower(); if (curPos == 0) javaPackageName.prepend(QLatin1String("com.")); suiteId = javaPackageName; if (!application.isEmpty()) { - javaPackageName += QLatin1Char('.'); - javaPackageName += application; + javaPackageName += QLatin1Char('.') + application; applicationId = javaPackageName; } diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index b5772b5ce2..9663235a67 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3418,8 +3418,7 @@ QUrl QUrl::adjusted(QUrl::FormattingOptions options) const QByteArray QUrl::toEncoded(FormattingOptions options) const { options &= ~(FullyDecoded | FullyEncoded); - QString stringForm = toString(options | FullyEncoded); - return stringForm.toLatin1(); + return toString(options | FullyEncoded).toLatin1(); } /*! @@ -3536,8 +3535,7 @@ QString QUrl::fromAce(const QByteArray &domain) */ QByteArray QUrl::toAce(const QString &domain) { - QString result = qt_ACE_do(domain, ToAceOnly, ForbidLeadingDot /*FIXME: make configurable*/); - return result.toLatin1(); + return qt_ACE_do(domain, ToAceOnly, ForbidLeadingDot /*FIXME: make configurable*/).toLatin1(); } /*! diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm index 0e69f69a85..56eabc4b8c 100644 --- a/src/corelib/kernel/qcore_foundation.mm +++ b/src/corelib/kernel/qcore_foundation.mm @@ -328,6 +328,8 @@ NSUUID *QUuid::toNSUUID() const */ QUrl QUrl::fromCFURL(CFURLRef url) { + if (!url) + return QUrl(); return QUrl(QString::fromCFString(CFURLGetString(url))); } @@ -355,6 +357,8 @@ CFURLRef QUrl::toCFURL() const */ QUrl QUrl::fromNSURL(const NSURL *url) { + if (!url) + return QUrl(); return QUrl(QString::fromNSString([url absoluteString])); } diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index ad549dcd7b..a2ec813f11 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** ** Copyright (C) 2016 Intel Corporation. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h index aa0f735fcc..ddab0191ad 100644 --- a/src/corelib/kernel/qdeadlinetimer.h +++ b/src/corelib/kernel/qdeadlinetimer.h @@ -1,31 +1,37 @@ /**************************************************************************** ** ** Copyright (C) 2016 Intel Corporation. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index c8b70464fd..21332e71bc 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -83,11 +83,9 @@ public: static const unsigned MinWeight = 1; explicit QMimeGlobPattern(const QString &thePattern, const QString &theMimeType, unsigned theWeight = DefaultWeight, Qt::CaseSensitivity s = Qt::CaseInsensitive) : - m_pattern(thePattern), m_mimeType(theMimeType), m_weight(theWeight), m_caseSensitivity(s) + m_pattern(s == Qt::CaseInsensitive ? thePattern.toLower() : thePattern), + m_mimeType(theMimeType), m_weight(theWeight), m_caseSensitivity(s) { - if (s == Qt::CaseInsensitive) { - m_pattern = m_pattern.toLower(); - } } void swap(QMimeGlobPattern &other) Q_DECL_NOTHROW diff --git a/src/corelib/statemachine/qfinalstate_p.h b/src/corelib/statemachine/qfinalstate_p.h index 57de703fe9..65598f6c19 100644 --- a/src/corelib/statemachine/qfinalstate_p.h +++ b/src/corelib/statemachine/qfinalstate_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 0448a78160..9be20e6676 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3052,7 +3052,7 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q num_str.prepend(QLatin1Char(' ')); if (flags & QLocaleData::CapitalEorX) - num_str = num_str.toUpper(); + num_str = std::move(num_str).toUpper(); return num_str; } @@ -3134,7 +3134,7 @@ QString QLocaleData::longLongToString(const QChar zero, const QChar group, } if (flags & CapitalEorX) - num_str = num_str.toUpper(); + num_str = std::move(num_str).toUpper(); if (base == 16 && (flags & ShowBase)) num_str.prepend(QLatin1String(flags & UppercaseBase ? "0X" : "0x")); @@ -3213,7 +3213,7 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group, } if (flags & CapitalEorX) - num_str = num_str.toUpper(); + num_str = std::move(num_str).toUpper(); if (base == 16 && flags & ShowBase) num_str.prepend(QLatin1String(flags & UppercaseBase ? "0X" : "0x")); diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index d1abb8b565..2475859abd 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -1037,7 +1037,7 @@ static QString winIso639LangName(LPWSTR id) if (!lang_code.isEmpty()) { const char *endptr; bool ok; - QByteArray latin1_lang_code = lang_code.toLatin1(); + QByteArray latin1_lang_code = std::move(lang_code).toLatin1(); int i = qstrtoull(latin1_lang_code, &endptr, 16, &ok); if (ok && *endptr == '\0') { switch (i) { @@ -1120,15 +1120,12 @@ static QByteArray getWinLocaleName(LPWSTR id) id = lcName; } #endif // Q_OS_WINRT - QString resultuage = winIso639LangName(id); + QString resultusage = winIso639LangName(id); QString country = winIso3116CtryName(id); - result = resultuage.toLatin1(); - if (!country.isEmpty()) { - result += '_'; - result += country.toLatin1(); - } + if (!country.isEmpty()) + resultusage += QLatin1Char('_') + country; - return result; + return std::move(resultusage).toLatin1(); } Q_CORE_EXPORT QLocale qt_localeFromLCID(LCID id) diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 8366e01ee8..f1fac093b0 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -1674,7 +1674,7 @@ QString QRegularExpression::errorString() const } while (errorStringLength < 0); errorString.resize(errorStringLength); - return QCoreApplication::translate("QRegularExpression", errorString.toLatin1().constData()); + return QCoreApplication::translate("QRegularExpression", std::move(errorString).toLatin1().constData()); } return QCoreApplication::translate("QRegularExpression", "no error"); } diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index b2832b5fbe..9a40abcfed 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -277,9 +277,9 @@ template <> struct QConcatenable<QStringRef> : private QAbstractConcatenable } }; -template <int N> struct QConcatenable<char[N]> : private QAbstractConcatenable +template <int N> struct QConcatenable<const char[N]> : private QAbstractConcatenable { - typedef char type[N]; + typedef const char type[N]; typedef QByteArray ConvertTo; enum { ExactSize = false }; static int size(const char[N]) { return N - 1; } @@ -296,23 +296,9 @@ template <int N> struct QConcatenable<char[N]> : private QAbstractConcatenable } }; -template <int N> struct QConcatenable<const char[N]> : private QAbstractConcatenable +template <int N> struct QConcatenable<char[N]> : QConcatenable<const char[N]> { - typedef const char type[N]; - typedef QByteArray ConvertTo; - enum { ExactSize = false }; - static int size(const char[N]) { return N - 1; } -#ifndef QT_NO_CAST_FROM_ASCII - static inline void QT_ASCII_CAST_WARN appendTo(const char a[N], QChar *&out) - { - QAbstractConcatenable::convertFromAscii(a, N - 1, out); - } -#endif - static inline void appendTo(const char a[N], char *&out) - { - while (*a) - *out++ = *a++; - } + typedef char type[N]; }; template <> struct QConcatenable<const char *> : private QAbstractConcatenable diff --git a/src/corelib/tools/qtimezoneprivate_icu.cpp b/src/corelib/tools/qtimezoneprivate_icu.cpp index a07b2593b9..5570ce7571 100644 --- a/src/corelib/tools/qtimezoneprivate_icu.cpp +++ b/src/corelib/tools/qtimezoneprivate_icu.cpp @@ -98,7 +98,7 @@ static QByteArray ucalDefaultTimeZoneId() // If successful on first or second go, resize and return if (U_SUCCESS(status)) { result.resize(size); - return result.toUtf8(); + return std::move(result).toUtf8(); } return QByteArray(); diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp index c6d59be3d8..a50227d3cc 100644 --- a/src/corelib/tools/qtimezoneprivate_win.cpp +++ b/src/corelib/tools/qtimezoneprivate_win.cpp @@ -299,7 +299,7 @@ static QByteArray windowsSystemZoneId() id = readRegistryString(key, L"TimeZoneKeyName"); RegCloseKey(key); if (!id.isEmpty()) - return id.toUtf8(); + return std::move(id).toUtf8(); } // On XP we have to iterate over the zones until we find a match on diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 1a106be98b..9905caa92a 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1189,7 +1189,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence QString keyName(tran == 0 ? QCoreApplication::translate("QShortcut", keyname[i].name) : QString::fromLatin1(keyname[i].name)); - if (accelRef == keyName.toLower()) { + if (accelRef == std::move(keyName).toLower()) { ret |= keyname[i].key; found = true; break; diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 98ff49ea31..b56bcd0866 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1282,35 +1282,11 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ return img; } -#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN - // Without GL_UNSIGNED_INT_8_8_8_8_REV, GL_BGRA only makes sense on little endian. - const bool has_bgra_ext = context->isOpenGLES() - ? context->hasExtension(QByteArrayLiteral("GL_EXT_read_format_bgra")) - : context->hasExtension(QByteArrayLiteral("GL_EXT_bgra")); - -#ifndef Q_OS_IOS - const char *renderer = reinterpret_cast<const char *>(funcs->glGetString(GL_RENDERER)); - const char *ver = reinterpret_cast<const char *>(funcs->glGetString(GL_VERSION)); - - // Blacklist GPU chipsets that have problems with their BGRA support. - const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0 - && ::strstr(ver, "1.3") != 0) || - (qstrcmp(renderer, "Mali-T760") == 0 - && ::strstr(ver, "3.1") != 0) || - (qstrcmp(renderer, "Mali-T720") == 0 - && ::strstr(ver, "3.1") != 0) || - qstrcmp(renderer, "PowerVR SGX 554") == 0; -#else - const bool blackListed = true; -#endif - const bool supports_bgra = has_bgra_ext && !blackListed; + // For OpenGL ES stick with the byte ordered format / RGBA readback format + // since that is the only spec mandated way. (also, skip the + // GL_IMPLEMENTATION_COLOR_READ_FORMAT mess since there is nothing saying a + // BGRA capable impl would return BGRA from there) - if (supports_bgra) { - QImage img(size, include_alpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); - funcs->glReadPixels(0, 0, w, h, GL_BGRA, GL_UNSIGNED_BYTE, img.bits()); - return img; - } -#endif QImage rgbaImage(size, include_alpha ? QImage::Format_RGBA8888_Premultiplied : QImage::Format_RGBX8888); funcs->glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, rgbaImage.bits()); return rgbaImage; @@ -1362,8 +1338,11 @@ Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, If used together with QOpenGLPaintDevice, \a flipped should be the opposite of the value of QOpenGLPaintDevice::paintFlipped(). - The returned image has a format of premultiplied ARGB32 or RGB32. The latter is used - only when internalTextureFormat() is set to \c GL_RGB. + The returned image has a format of premultiplied ARGB32 or RGB32. The latter + is used only when internalTextureFormat() is set to \c GL_RGB. Since Qt 5.2 + the function will fall back to premultiplied RGBA8888 or RGBx8888 when + reading to (A)RGB32 is not supported, and this includes OpenGL ES. Since Qt + 5.4 an A2BGR30 image is returned if the internal format is RGB10_A2. If the rendering in the framebuffer was not done with premultiplied alpha in mind, create a wrapper QImage with a non-premultiplied format. This is necessary before @@ -1376,10 +1355,6 @@ Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, QImage image(fboImage.constBits(), fboImage.width(), fboImage.height(), QImage::Format_ARGB32); \endcode - Since Qt 5.2 the function will fall back to premultiplied RGBA8888 or RGBx8888 when - reading to (A)RGB32 is not supported. Since 5.4 an A2BGR30 image is returned if the - internal format is RGB10_A2. - For multisampled framebuffer objects the samples are resolved using the \c{GL_EXT_framebuffer_blit} extension. If the extension is not available, the contents of the returned image is undefined. diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 8c9d1e1c49..d2a5911767 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6248,13 +6248,13 @@ inline void qt_memfill_template(T *dest, T color, int count) int n = (count + 7) / 8; switch (count & 0x07) { - case 0: do { *dest++ = color; - case 7: *dest++ = color; - case 6: *dest++ = color; - case 5: *dest++ = color; - case 4: *dest++ = color; - case 3: *dest++ = color; - case 2: *dest++ = color; + case 0: do { *dest++ = color; Q_FALLTHROUGH(); + case 7: *dest++ = color; Q_FALLTHROUGH(); + case 6: *dest++ = color; Q_FALLTHROUGH(); + case 5: *dest++ = color; Q_FALLTHROUGH(); + case 4: *dest++ = color; Q_FALLTHROUGH(); + case 3: *dest++ = color; Q_FALLTHROUGH(); + case 2: *dest++ = color; Q_FALLTHROUGH(); case 1: *dest++ = color; } while (--n > 0); } @@ -6265,7 +6265,7 @@ inline void qt_memfill_template(quint16 *dest, quint16 value, int count) { if (count < 3) { switch (count) { - case 2: *dest++ = value; + case 2: *dest++ = value; Q_FALLTHROUGH(); case 1: *dest = value; } return; diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index edce70d2d0..3013d2cf3e 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -237,11 +237,11 @@ void qt_memfill32(quint32 *dest, quint32 value, int count) { if (count < 7) { switch (count) { - case 6: *dest++ = value; - case 5: *dest++ = value; - case 4: *dest++ = value; - case 3: *dest++ = value; - case 2: *dest++ = value; + case 6: *dest++ = value; Q_FALLTHROUGH(); + case 5: *dest++ = value; Q_FALLTHROUGH(); + case 4: *dest++ = value; Q_FALLTHROUGH(); + case 3: *dest++ = value; Q_FALLTHROUGH(); + case 2: *dest++ = value; Q_FALLTHROUGH(); case 1: *dest = value; } return; @@ -249,16 +249,16 @@ void qt_memfill32(quint32 *dest, quint32 value, int count) const int align = (quintptr)(dest) & 0xf; switch (align) { - case 4: *dest++ = value; --count; - case 8: *dest++ = value; --count; + case 4: *dest++ = value; --count; Q_FALLTHROUGH(); + case 8: *dest++ = value; --count; Q_FALLTHROUGH(); case 12: *dest++ = value; --count; } const int rest = count & 0x3; if (rest) { switch (rest) { - case 3: dest[count - 3] = value; - case 2: dest[count - 2] = value; + case 3: dest[count - 3] = value; Q_FALLTHROUGH(); + case 2: dest[count - 2] = value; Q_FALLTHROUGH(); case 1: dest[count - 1] = value; } } @@ -277,8 +277,8 @@ void qt_memfill32(quint32 *dest, quint32 value, int count) } switch (count128 & 0x3) { - case 3: _mm_stream_si128(dst128++, value128); - case 2: _mm_stream_si128(dst128++, value128); + case 3: _mm_stream_si128(dst128++, value128); Q_FALLTHROUGH(); + case 2: _mm_stream_si128(dst128++, value128); Q_FALLTHROUGH(); case 1: _mm_stream_si128(dst128++, value128); } } @@ -318,7 +318,7 @@ void qt_memfill16(quint16 *dest, quint16 value, int count) { if (count < 3) { switch (count) { - case 2: *dest++ = value; + case 2: *dest++ = value; Q_FALLTHROUGH(); case 1: *dest = value; } return; diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index fdbc803174..25e051d739 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -2308,7 +2308,8 @@ int QPdfEnginePrivate::createShadingFunction(const QGradient *gradient, int from for (int i = 0; i < gradientBounds.size(); ++i) s << gradientBounds.at(i).function << "0 R "; s << "]\n" - ">>\n"; + ">>\n" + "endobj\n"; write(data); } else { function = functions.at(0); diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index a0438bd458..64adeaa260 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1822,7 +1822,7 @@ void StyleSheet::buildIndexes(Qt::CaseSensitivity nameCaseSensitivity) nr.order = i; QString name = sel.elementName; if (nameCaseSensitivity == Qt::CaseInsensitive) - name=name.toLower(); + name = std::move(name).toLower(); nameIndex.insert(name, nr); } else { universalsSelectors += selector; @@ -2027,7 +2027,7 @@ QVector<StyleRule> StyleSelector::styleRulesForNode(NodePtr node) for (int i = 0; i < names.count(); i++) { QString name = names.at(i); if (nameCaseSensitivity == Qt::CaseInsensitive) - name = name.toLower(); + name = std::move(name).toLower(); QMultiHash<QString, StyleRule>::const_iterator it = styleSheet.nameIndex.constFind(name); while (it != styleSheet.nameIndex.constEnd() && it.key() == name) { matchRule(node, it.value(), styleSheet.origin, styleSheet.depth, &weightedRules); @@ -2748,7 +2748,7 @@ bool Parser::testAndParseUri(QString *uri) index = rewind; return false; } - if (name.toLower() != QLatin1String("url")) { + if (name.compare(QLatin1String("url"), Qt::CaseInsensitive) != 0) { index = rewind; return false; } diff --git a/src/gui/text/qinputcontrol.cpp b/src/gui/text/qinputcontrol.cpp index 2f7dcfcd2b..3381fdb673 100644 --- a/src/gui/text/qinputcontrol.cpp +++ b/src/gui/text/qinputcontrol.cpp @@ -85,4 +85,55 @@ bool QInputControl::isAcceptableInput(const QKeyEvent *event) const return false; } +bool QInputControl::isCommonTextEditShortcut(const QKeyEvent *ke) +{ + if (ke->modifiers() == Qt::NoModifier + || ke->modifiers() == Qt::ShiftModifier + || ke->modifiers() == Qt::KeypadModifier) { + if (ke->key() < Qt::Key_Escape) { + return true; + } else { + switch (ke->key()) { + case Qt::Key_Return: + case Qt::Key_Enter: + case Qt::Key_Delete: + case Qt::Key_Home: + case Qt::Key_End: + case Qt::Key_Backspace: + case Qt::Key_Left: + case Qt::Key_Right: + case Qt::Key_Up: + case Qt::Key_Down: + case Qt::Key_Tab: + return true; + default: + break; + } + } +#if QT_CONFIG(shortcut) + } else if (ke->matches(QKeySequence::Copy) + || ke->matches(QKeySequence::Paste) + || ke->matches(QKeySequence::Cut) + || ke->matches(QKeySequence::Redo) + || ke->matches(QKeySequence::Undo) + || ke->matches(QKeySequence::MoveToNextWord) + || ke->matches(QKeySequence::MoveToPreviousWord) + || ke->matches(QKeySequence::MoveToStartOfDocument) + || ke->matches(QKeySequence::MoveToEndOfDocument) + || ke->matches(QKeySequence::SelectNextWord) + || ke->matches(QKeySequence::SelectPreviousWord) + || ke->matches(QKeySequence::SelectStartOfLine) + || ke->matches(QKeySequence::SelectEndOfLine) + || ke->matches(QKeySequence::SelectStartOfBlock) + || ke->matches(QKeySequence::SelectEndOfBlock) + || ke->matches(QKeySequence::SelectStartOfDocument) + || ke->matches(QKeySequence::SelectEndOfDocument) + || ke->matches(QKeySequence::SelectAll) + ) { + return true; +#endif + } + return false; +} + QT_END_NAMESPACE diff --git a/src/gui/text/qinputcontrol_p.h b/src/gui/text/qinputcontrol_p.h index e5709b5e54..b4c1ca8f8f 100644 --- a/src/gui/text/qinputcontrol_p.h +++ b/src/gui/text/qinputcontrol_p.h @@ -69,6 +69,7 @@ public: explicit QInputControl(Type type, QObject *parent = nullptr); bool isAcceptableInput(const QKeyEvent *event) const; + static bool isCommonTextEditShortcut(const QKeyEvent *ke); protected: explicit QInputControl(Type type, QObjectPrivate &dd, QObject *parent = nullptr); diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 6074917087..f8215f92e9 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -133,7 +133,7 @@ bool Qt::mightBeRichText(const QString& text) return false; // that's not a tag } #ifndef QT_NO_TEXTHTMLPARSER - return QTextHtmlParser::lookupElement(tag.toLower()) != -1; + return QTextHtmlParser::lookupElement(std::move(tag).toLower()) != -1; #else return false; #endif // QT_NO_TEXTHTMLPARSER diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 8ad2d85e7c..e9194e73ff 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -834,6 +834,8 @@ void QTextDocumentLayoutPrivate::drawBorder(QPainter *painter, const QRectF &rec #ifndef QT_NO_CSSPARSER QCss::BorderStyle cssStyle = static_cast<QCss::BorderStyle>(style + 1); +#else + Q_UNUSED(style); #endif //QT_NO_CSSPARSER bool turn_off_antialiasing = !(painter->renderHints() & QPainter::Antialiasing); diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 269e505a56..da4e21728f 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -706,8 +706,8 @@ void QTextHtmlParser::parseTag() node = resolveParent(); resolveNode(); - const int nodeIndex = nodes.count() - 1; // this new node is always the last #ifndef QT_NO_CSSPARSER + const int nodeIndex = nodes.count() - 1; // this new node is always the last node->applyCssDeclarations(declarationsForNode(nodeIndex), resourceProvider); #endif applyAttributes(node->attributes); @@ -1525,7 +1525,7 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) } else if (value == QLatin1String("I")) { node->listStyle = QTextListFormat::ListUpperRoman; } else { - value = value.toLower(); + value = std::move(value).toLower(); if (value == QLatin1String("square")) node->listStyle = QTextListFormat::ListSquare; else if (value == QLatin1String("disc")) @@ -1636,7 +1636,7 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) node->parseStyleAttribute(value, resourceProvider); #endif } else if (key == QLatin1String("align")) { - value = value.toLower(); + value = std::move(value).toLower(); bool alignmentSet = true; if (value == QLatin1String("left")) @@ -1664,7 +1664,7 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) } } } else if (key == QLatin1String("valign")) { - value = value.toLower(); + value = std::move(value).toLower(); if (value == QLatin1String("top")) node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop); else if (value == QLatin1String("middle")) @@ -1672,7 +1672,7 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) else if (value == QLatin1String("bottom")) node->charFormat.setVerticalAlignment(QTextCharFormat::AlignBottom); } else if (key == QLatin1String("dir")) { - value = value.toLower(); + value = std::move(value).toLower(); if (value == QLatin1String("ltr")) node->blockFormat.setLayoutDirection(Qt::LeftToRight); else if (value == QLatin1String("rtl")) diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index e9cb3aa498..47579ba654 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -574,7 +574,7 @@ static void _q_parseDosDir(const QStringList &tokens, const QString &userName, Q QString name = tokens.at(3); info->setName(name); - info->setSymLink(name.toLower().endsWith(QLatin1String(".lnk"))); + info->setSymLink(name.endsWith(QLatin1String(".lnk"), Qt::CaseInsensitive)); if (tokens.at(2) == QLatin1String("<DIR>")) { info->setFile(false); diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 60313422da..555f1ba0ef 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -1387,6 +1387,8 @@ void QHttp2ProtocolHandler::initReplyFromPushPromise(const HttpMessagePair &mess { Q_ASSERT(promisedData.contains(cacheKey)); auto promise = promisedData.take(cacheKey); + Q_ASSERT(message.second); + message.second->setSpdyWasUsed(true); qCDebug(QT_HTTP2) << "found cached/promised response on stream" << promise.reservedID; diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 72feffda8c..da055de2da 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -327,7 +327,7 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) acceptLanguage = systemLocale + QLatin1String(",*"); else acceptLanguage = systemLocale + QLatin1String(",en,*"); - request.setHeaderField("Accept-Language", acceptLanguage.toLatin1()); + request.setHeaderField("Accept-Language", std::move(acceptLanguage).toLatin1()); } // set the User Agent diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index e9b3760ce5..e9287b233a 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -173,7 +173,7 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy) Q_UNUSED(proxy) #endif - return "http-connection:" + result.toLatin1(); + return "http-connection:" + std::move(result).toLatin1(); } class QNetworkAccessCachedHttpConnection: public QHttpNetworkConnection, diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 5cd0747e34..bdb23ede1d 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1234,7 +1234,14 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QList<QPair<QByte } q->setAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, pu); - q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, spdyWasUsed); + const QVariant http2Allowed = request.attribute(QNetworkRequest::HTTP2AllowedAttribute); + if (http2Allowed.isValid() && http2Allowed.toBool()) { + q->setAttribute(QNetworkRequest::HTTP2WasUsedAttribute, spdyWasUsed); + q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, false); + } else { + q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, spdyWasUsed); + q->setAttribute(QNetworkRequest::HTTP2WasUsedAttribute, false); + } // reconstruct the HTTP header QList<QPair<QByteArray, QByteArray> > headerMap = hm; diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index e95187de30..60701d45be 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -266,7 +266,10 @@ QT_BEGIN_NAMESPACE allowed to use HTTP/2 with this request. This applies to SSL requests or 'cleartext' HTTP/2. - \omitvalue HTTP2WasUsedAttribute + \value HTTP2WasUsedAttribute + Replies only, type: QMetaType::Bool (default: false) + Indicates whether HTTP/2 was used for receiving this reply. + (This value was introduced in 5.9.) \value EmitAllUploadProgressSignalsAttribute Requests only, type: QMetaType::Bool (default: false) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 2b9e928266..3588948133 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -615,7 +615,7 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo return fallbackLists[styleLookupKey.arg(styleHint)]; } -static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fileName = QString()) +CFArrayRef QCoreTextFontDatabase::createDescriptorArrayForFont(CTFontRef font, const QString &fileName) { CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); QCFType<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(font); @@ -625,7 +625,7 @@ static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fi // 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()) { + if (m_useFreeType && !fileName.isEmpty()) { QCFType<CFURLRef> fontURL; if (fileName.startsWith(QLatin1String(":/"))) { @@ -662,11 +662,7 @@ QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData if (cgFont) { if (CTFontManagerRegisterGraphicsFont(cgFont, &error)) { QCFType<CTFontRef> font = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL); - fonts = createDescriptorArrayForFont(font -#ifndef QT_NO_FREETYPE - , m_useFreeType ? fileName : QString() -#endif - ); + fonts = createDescriptorArrayForFont(font, fileName); m_applicationFonts.append(QVariant::fromValue(QCFType<CGFontRef>::constructFromGet(cgFont))); } } diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index 344e235053..4caa50afbe 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -58,6 +58,7 @@ #include <private/qcore_mac_p.h> Q_FORWARD_DECLARE_CF_TYPE(CTFontDescriptor); +Q_FORWARD_DECLARE_CF_TYPE(CTFont); Q_DECLARE_METATYPE(QCFType<CGFontRef>); Q_DECLARE_METATYPE(QCFType<CFURLRef>); @@ -88,6 +89,7 @@ public: private: void populateFromDescriptor(CTFontDescriptorRef font, const QString &familyName = QString()); + CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fileName); #ifndef QT_NO_FREETYPE bool m_useFreeType; diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp index fb0705c8c7..b13c875854 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp @@ -120,7 +120,7 @@ void QDBusMenuBar::syncMenu(QPlatformMenu *menu) void QDBusMenuBar::handleReparent(QWindow *newParentWindow) { - if (newParentWindow && newParentWindow->winId() != m_windowId) { + if (newParentWindow) { unregisterMenuBar(); m_windowId = newParentWindow->winId(); registerMenuBar(); diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 4eefcace0f..e9116223bd 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -555,6 +555,7 @@ QIcon QKdeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions #if QT_CONFIG(mimetype) return xdgFileIcon(fileInfo); #else + Q_UNUSED(fileInfo); return QIcon(); #endif } @@ -720,6 +721,7 @@ QIcon QGnomeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptio #if QT_CONFIG(mimetype) return xdgFileIcon(fileInfo); #else + Q_UNUSED(fileInfo); return QIcon(); #endif } diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 0fabb25233..17c197ea38 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -533,6 +533,12 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para return pthread_create(&m_qtAppThread, nullptr, startMainMethod, nullptr) == 0; } +static void quitQtCoreApplication(JNIEnv *env, jclass /*clazz*/) +{ + Q_UNUSED(env); + QCoreApplication::quit(); +} + static void quitQtAndroidPlugin(JNIEnv *env, jclass /*clazz*/) { Q_UNUSED(env); @@ -733,6 +739,7 @@ static JNINativeMethod methods[] = { {"startQtAndroidPlugin", "()Z", (void *)startQtAndroidPlugin}, {"startQtApplication", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)startQtApplication}, {"quitQtAndroidPlugin", "()V", (void *)quitQtAndroidPlugin}, + {"quitQtCoreApplication", "()V", (void *)quitQtCoreApplication}, {"terminateQt", "()V", (void *)terminateQt}, {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 6478365d07..602cea97a7 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -58,6 +58,8 @@ #include <QDebug> +#include <vector> + enum { defaultWindowWidth = 160, defaultWindowHeight = 160 @@ -1613,6 +1615,13 @@ void QCocoaWindow::recreateWindowIfNeeded() [m_nsWindow closeAndRelease]; if (isChildNSWindow()) [m_view.window.parentWindow removeChildWindow:m_view.window]; + if (isContentView()) { + // We explicitly disassociate m_view from the window's contentView, + // as AppKit does not automatically do this in response to removing + // the view from the NSThemeFrame subview list, so we might end up + // with a NSWindow contentView pointing to a deallocated NSView. + m_view.window.contentView = nil; + } m_nsWindow = 0; } @@ -1636,13 +1645,6 @@ void QCocoaWindow::recreateWindowIfNeeded() [m_nsWindow setContentView:m_view]; [m_view release]; [m_view setPostsFrameChangedNotifications:YES]; - // QTBUG-58963 - // viewDidChangeFrame() should be called for each window automatically at this point because it is - // registered with Q_NOTIFICATION_HANDLER(NSViewFrameDidChangeNotification); - // The corner case when it's not called and we need to make a manual geometry update is when window's - // size is not specified explicitly but minimumSize is set and matches to the size NSView was created with. - if (QSizeF::fromCGSize(m_view.frame.size) == [QNSView defaultViewSize]) - viewDidChangeFrame(); } } @@ -1862,8 +1864,7 @@ void QCocoaWindow::applyWindowState(Qt::WindowStates requestedState) // the new state. return; } - default: - Q_FALLTHROUGH(); + default:; } // Then we apply the new state if needed @@ -1881,12 +1882,8 @@ void QCocoaWindow::applyWindowState(Qt::WindowStates requestedState) [m_nsWindow miniaturize:sender]; break; case Qt::WindowNoState: - switch (windowState()) { - case Qt::WindowMaximized: + if (windowState() == Qt::WindowMaximized) toggleMaximized(); - default: - Q_FALLTHROUGH(); - } break; default: Q_UNREACHABLE(); @@ -2068,10 +2065,10 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window) } // Find consecutive registered border areas, starting from the top. - QList<BorderRange> ranges = m_contentBorderAreas.values(); + std::vector<BorderRange> ranges(m_contentBorderAreas.cbegin(), m_contentBorderAreas.cend()); std::sort(ranges.begin(), ranges.end()); int effectiveTopContentBorderThickness = m_topContentBorderThickness; - foreach (BorderRange range, ranges) { + for (BorderRange range : ranges) { // Skip disiabled ranges (typically hidden tool bars) if (!m_enabledContentBorderAreas.value(range.identifier, false)) continue; diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index a05bd66890..75a508370f 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -88,7 +88,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); QSet<quint32> m_acceptedKeyDowns; } -+ (QSizeF)defaultViewSize; - (id)init; - (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow; #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index e16915273a..bbdf9ad44f 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -140,8 +140,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (id) init { - self = [super initWithFrame : NSMakeRect(0, 0, [[self class] defaultViewSize].width(), [[self class] defaultViewSize].height())]; - if (self) { + if (self = [super initWithFrame:NSZeroRect]) { m_backingStore = 0; m_maskImage = 0; m_shouldInvalidateWindowShadow = false; @@ -189,11 +188,6 @@ static bool _q_dontOverrideCtrlLMB = false; [super dealloc]; } -+ (QSizeF)defaultViewSize -{ - return QSizeF(300.0, 300.0); -} - - (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow { self = [self init]; diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 5f65f8e958..f017929148 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1088,6 +1088,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, #endif } break; case QtWindows::DpiChangedEvent: { + if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_DLGFRAME) + return false; // Fixed-size window should not be resized + platformWindow->setFlag(QWindowsWindow::WithinDpiChanged); const RECT *prcNewWindow = reinterpret_cast<RECT *>(lParam); SetWindowPos(hwnd, NULL, prcNewWindow->left, prcNewWindow->top, diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 71fd12d71b..bd4822c664 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -717,7 +717,7 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData if (preferredType == QVariant::String) ret = str; else - ret = str.toUtf8(); + ret = std::move(str).toUtf8(); } qCDebug(lcQpaMime) << __FUNCTION__ << ret; return ret; diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 4ae1a751e9..3e2cb5e9e9 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -815,14 +815,14 @@ QString QWindowsFileIconEngine::cacheKey() const // Return "" for .exe, .lnk and .ico extensions. // It is faster to just look at the file extensions; // avoiding slow QFileInfo::isExecutable() (QTBUG-13182) - const QString &suffix = fileInfo().suffix(); + QString suffix = fileInfo().suffix(); if (!suffix.compare(QLatin1String("exe"), Qt::CaseInsensitive) || !suffix.compare(QLatin1String("lnk"), Qt::CaseInsensitive) || !suffix.compare(QLatin1String("ico"), Qt::CaseInsensitive)) { return QString(); } return QLatin1String("qt_.") - + (suffix.isEmpty() ? fileInfo().fileName() : suffix.toUpper()); // handle "Makefile" ;) + + (suffix.isEmpty() ? fileInfo().fileName() : std::move(suffix).toUpper()); // handle "Makefile" ;) } QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon::State) diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 150fc8a25e..edfcf038d7 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -91,6 +91,7 @@ typedef ITypedEventHandler<CoreWindow*, PointerEventArgs*> PointerHandler; typedef ITypedEventHandler<CoreWindow*, WindowSizeChangedEventArgs*> SizeChangedHandler; typedef ITypedEventHandler<CoreWindow*, VisibilityChangedEventArgs*> VisibilityChangedHandler; typedef ITypedEventHandler<DisplayInformation*, IInspectable*> DisplayInformationHandler; +typedef ITypedEventHandler<ICorePointerRedirector*, PointerEventArgs*> RedirectHandler; #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) typedef ITypedEventHandler<ApplicationView*, IInspectable*> VisibleBoundsChangedHandler; #endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) @@ -454,6 +455,8 @@ typedef HRESULT (__stdcall ICoreWindow::*CoreWindowCallbackRemover)(EventRegistr uint qHash(CoreWindowCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } typedef HRESULT (__stdcall IDisplayInformation::*DisplayCallbackRemover)(EventRegistrationToken); uint qHash(DisplayCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } +typedef HRESULT (__stdcall ICorePointerRedirector::*RedirectorCallbackRemover)(EventRegistrationToken); +uint qHash(RedirectorCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) typedef HRESULT (__stdcall IApplicationView2::*ApplicationView2CallbackRemover)(EventRegistrationToken); uint qHash(ApplicationView2CallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } @@ -464,6 +467,7 @@ class QWinRTScreenPrivate public: QTouchDevice *touchDevice; ComPtr<ICoreWindow> coreWindow; + ComPtr<ICorePointerRedirector> redirect; ComPtr<Xaml::IDependencyObject> canvas; ComPtr<IApplicationView> view; ComPtr<IDisplayInformation> displayInformation; @@ -482,6 +486,7 @@ public: QHash<Qt::Key, KeyInfo> activeKeys; QHash<CoreWindowCallbackRemover, EventRegistrationToken> windowTokens; QHash<DisplayCallbackRemover, EventRegistrationToken> displayTokens; + QHash<RedirectorCallbackRemover, EventRegistrationToken> redirectTokens; #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) QHash<ApplicationView2CallbackRemover, EventRegistrationToken> view2Tokens; ComPtr<IApplicationView2> view2; @@ -513,6 +518,10 @@ QWinRTScreen::QWinRTScreen() hr = window->get_CoreWindow(&d->coreWindow); Q_ASSERT_SUCCEEDED(hr); + + hr = d->coreWindow.As(&d->redirect); + Q_ASSERT_SUCCEEDED(hr); + hr = d->coreWindow->Activate(); Q_ASSERT_SUCCEEDED(hr); @@ -595,6 +604,10 @@ QWinRTScreen::~QWinRTScreen() hr = (d->displayInformation.Get()->*i.key())(i.value()); Q_ASSERT_SUCCEEDED(hr); } + for (QHash<RedirectorCallbackRemover, EventRegistrationToken>::const_iterator i = d->redirectTokens.begin(); i != d->redirectTokens.end(); ++i) { + hr = (d->redirect.Get()->*i.key())(i.value()); + Q_ASSERT_SUCCEEDED(hr); + } #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) for (QHash<ApplicationView2CallbackRemover, EventRegistrationToken>::const_iterator i = d->view2Tokens.begin(); i != d->view2Tokens.end(); ++i) { hr = (d->view2.Get()->*i.key())(i.value()); @@ -754,6 +767,9 @@ void QWinRTScreen::initialize() Q_ASSERT_SUCCEEDED(hr); onOrientationChanged(Q_NULLPTR, Q_NULLPTR); onVisibilityChanged(nullptr, nullptr); + + hr = d->redirect->add_PointerRoutedReleased(Callback<RedirectHandler>(this, &QWinRTScreen::onRedirectReleased).Get(), &d->redirectTokens[&ICorePointerRedirector::remove_PointerRoutedReleased]); + Q_ASSERT_SUCCEEDED(hr); } void QWinRTScreen::setCursorRect(const QRectF &cursorRect) @@ -1378,6 +1394,13 @@ HRESULT QWinRTScreen::onDpiChanged(IDisplayInformation *, IInspectable *) return S_OK; } +HRESULT QWinRTScreen::onRedirectReleased(ICorePointerRedirector *, IPointerEventArgs *args) +{ + // When dragging ends with a non-mouse input device then onRedirectRelease is invoked. + // QTBUG-58781 + return onPointerUpdated(nullptr, args); +} + #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) HRESULT QWinRTScreen::onWindowSizeChanged(IApplicationView *, IInspectable *) #else diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index 7dcdb98ead..fd6499c2b9 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -52,6 +52,7 @@ namespace ABI { namespace Core { struct IAutomationProviderRequestedEventArgs; struct ICharacterReceivedEventArgs; + struct ICorePointerRedirector; struct ICoreWindow; struct ICoreWindowEventArgs; struct IKeyEventArgs; @@ -149,6 +150,7 @@ private: #else HRESULT onWindowSizeChanged(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *); #endif + HRESULT onRedirectReleased(ABI::Windows::UI::Core::ICorePointerRedirector *, ABI::Windows::UI::Core::IPointerEventArgs *); QScopedPointer<QWinRTScreenPrivate> d_ptr; QRectF mCursorRect; diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 7f1cff1299..396d8837e9 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -479,7 +479,7 @@ QByteArray QXcbIntegration::wmClass() const } if (!name.isEmpty() && !className.isEmpty()) - m_wmClass = name.toLocal8Bit() + '\0' + className.toLocal8Bit() + '\0'; + m_wmClass = std::move(name).toLocal8Bit() + '\0' + std::move(className).toLocal8Bit() + '\0'; } return m_wmClass; } diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 7592eb2887..186f31e08a 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -305,7 +305,7 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString QString formatWithCharset = format; formatWithCharset.append(QLatin1String(";charset=utf-8")); - xcb_atom_t a = connection->internAtom(formatWithCharset.toLatin1()); + xcb_atom_t a = connection->internAtom(std::move(formatWithCharset).toLatin1()); if (a && atoms.contains(a)) { *requestedEncoding = "utf-8"; return a; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 3d8c6de72f..db6ade5662 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1472,8 +1472,8 @@ void QXcbWindow::setParent(const QPlatformWindow *parent) void QXcbWindow::setWindowTitle(const QString &title) { - const QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH - const QByteArray ba = fullTitle.toUtf8(); + QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH + const QByteArray ba = std::move(fullTitle).toUtf8(); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index 8b6ec31400..c64a02fa0c 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -57,11 +57,6 @@ QT_BEGIN_NAMESPACE -static QByteArray standardButtonText(int button) -{ - return QGtk3Theme::defaultStandardButtonText(button).toUtf8(); -} - class QGtk3Dialog : public QWindow { Q_OBJECT @@ -236,7 +231,7 @@ void QGtk3ColorDialogHelper::onColorChanged(QGtk3ColorDialogHelper *dialog) void QGtk3ColorDialogHelper::applyOptions() { GtkDialog *gtkDialog = d->gtkDialog(); - gtk_window_set_title(GTK_WINDOW(gtkDialog), options()->windowTitle().toUtf8()); + gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(options()->windowTitle())); gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(gtkDialog), options()->testOption(QColorDialogOptions::ShowAlphaChannel)); } @@ -245,8 +240,8 @@ QGtk3FileDialogHelper::QGtk3FileDialogHelper() { d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", 0, GTK_FILE_CHOOSER_ACTION_OPEN, - standardButtonText(QPlatformDialogHelper::Cancel), GTK_RESPONSE_CANCEL, - standardButtonText(QPlatformDialogHelper::Ok), GTK_RESPONSE_OK, + qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Cancel)), GTK_RESPONSE_CANCEL, + qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Ok)), GTK_RESPONSE_OK, NULL))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); @@ -294,7 +289,7 @@ bool QGtk3FileDialogHelper::defaultNameFilterDisables() const void QGtk3FileDialogHelper::setDirectory(const QUrl &directory) { GtkDialog *gtkDialog = d->gtkDialog(); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), directory.toLocalFile().toUtf8()); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(directory.toLocalFile())); } QUrl QGtk3FileDialogHelper::directory() const @@ -316,13 +311,19 @@ QUrl QGtk3FileDialogHelper::directory() const void QGtk3FileDialogHelper::selectFile(const QUrl &filename) { + setFileChooserAction(); + selectFileInternal(filename); +} + +void QGtk3FileDialogHelper::selectFileInternal(const QUrl &filename) +{ GtkDialog *gtkDialog = d->gtkDialog(); if (options()->acceptMode() == QFileDialogOptions::AcceptSave) { QFileInfo fi(filename.toLocalFile()); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), fi.path().toUtf8()); - gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(gtkDialog), fi.fileName().toUtf8()); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(fi.path())); + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(fi.fileName())); } else { - gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(gtkDialog), filename.toLocalFile().toUtf8()); + gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(filename.toLocalFile())); } } @@ -409,16 +410,23 @@ static GtkFileChooserAction gtkFileChooserAction(const QSharedPointer<QFileDialo } } +void QGtk3FileDialogHelper::setFileChooserAction() +{ + GtkDialog *gtkDialog = d->gtkDialog(); + + const GtkFileChooserAction action = gtkFileChooserAction(options()); + gtk_file_chooser_set_action(GTK_FILE_CHOOSER(gtkDialog), action); +} + void QGtk3FileDialogHelper::applyOptions() { GtkDialog *gtkDialog = d->gtkDialog(); const QSharedPointer<QFileDialogOptions> &opts = options(); - gtk_window_set_title(GTK_WINDOW(gtkDialog), opts->windowTitle().toUtf8()); + gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(opts->windowTitle())); gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(gtkDialog), true); - const GtkFileChooserAction action = gtkFileChooserAction(opts); - gtk_file_chooser_set_action(GTK_FILE_CHOOSER(gtkDialog), action); + setFileChooserAction(); const bool selectMultiple = opts->fileMode() == QFileDialogOptions::ExistingFiles; gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(gtkDialog), selectMultiple); @@ -437,7 +445,7 @@ void QGtk3FileDialogHelper::applyOptions() setDirectory(opts->initialDirectory()); foreach (const QUrl &filename, opts->initiallySelectedFiles()) - selectFile(filename); + selectFileInternal(filename); const QString initialNameFilter = opts->initiallySelectedNameFilter(); if (!initialNameFilter.isEmpty()) @@ -446,19 +454,19 @@ void QGtk3FileDialogHelper::applyOptions() GtkWidget *acceptButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_OK); if (acceptButton) { if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept)) - gtk_button_set_label(GTK_BUTTON(acceptButton), opts->labelText(QFileDialogOptions::Accept).toUtf8()); + gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(opts->labelText(QFileDialogOptions::Accept))); else if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) - gtk_button_set_label(GTK_BUTTON(acceptButton), standardButtonText(QPlatformDialogHelper::Open)); + gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Open))); else - gtk_button_set_label(GTK_BUTTON(acceptButton), standardButtonText(QPlatformDialogHelper::Save)); + gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Save))); } GtkWidget *rejectButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_CANCEL); if (rejectButton) { if (opts->isLabelExplicitlySet(QFileDialogOptions::Reject)) - gtk_button_set_label(GTK_BUTTON(rejectButton), opts->labelText(QFileDialogOptions::Reject).toUtf8()); + gtk_button_set_label(GTK_BUTTON(rejectButton), qUtf8Printable(opts->labelText(QFileDialogOptions::Reject))); else - gtk_button_set_label(GTK_BUTTON(rejectButton), standardButtonText(QPlatformDialogHelper::Cancel)); + gtk_button_set_label(GTK_BUTTON(rejectButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Cancel))); } } @@ -473,12 +481,12 @@ void QGtk3FileDialogHelper::setNameFilters(const QStringList &filters) foreach (const QString &filter, filters) { GtkFileFilter *gtkFilter = gtk_file_filter_new(); - const QStringRef name = filter.leftRef(filter.indexOf(QLatin1Char('('))); + const QString name = filter.left(filter.indexOf(QLatin1Char('('))); const QStringList extensions = cleanFilterList(filter); - gtk_file_filter_set_name(gtkFilter, name.isEmpty() ? extensions.join(QLatin1String(", ")).toUtf8() : name.toUtf8()); + gtk_file_filter_set_name(gtkFilter, qUtf8Printable(name.isEmpty() ? extensions.join(QLatin1String(", ")) : name)); foreach (const QString &ext, extensions) - gtk_file_filter_add_pattern(gtkFilter, ext.toUtf8()); + gtk_file_filter_add_pattern(gtkFilter, qUtf8Printable(ext)); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(gtkDialog), gtkFilter); @@ -520,7 +528,7 @@ static QString qt_fontToString(const QFont &font) { PangoFontDescription *desc = pango_font_description_new(); pango_font_description_set_size(desc, (font.pointSizeF() > 0.0 ? font.pointSizeF() : QFontInfo(font).pointSizeF()) * PANGO_SCALE); - pango_font_description_set_family(desc, QFontInfo(font).family().toUtf8()); + pango_font_description_set_family(desc, qUtf8Printable(QFontInfo(font).family())); int weight = font.weight(); if (weight >= QFont::Black) @@ -560,7 +568,7 @@ static QString qt_fontToString(const QFont &font) static QFont qt_fontFromString(const QString &name) { QFont font; - PangoFontDescription *desc = pango_font_description_from_string(name.toUtf8()); + PangoFontDescription *desc = pango_font_description_from_string(qUtf8Printable(name)); font.setPointSizeF(static_cast<float>(pango_font_description_get_size(desc)) / PANGO_SCALE); QString family = QString::fromUtf8(pango_font_description_get_family(desc)); @@ -585,7 +593,7 @@ static QFont qt_fontFromString(const QString &name) void QGtk3FontDialogHelper::setCurrentFont(const QFont &font) { GtkFontChooser *gtkDialog = GTK_FONT_CHOOSER(d->gtkDialog()); - gtk_font_chooser_set_font(gtkDialog, qt_fontToString(font).toUtf8()); + gtk_font_chooser_set_font(gtkDialog, qUtf8Printable(qt_fontToString(font))); } QFont QGtk3FontDialogHelper::currentFont() const @@ -612,7 +620,7 @@ void QGtk3FontDialogHelper::applyOptions() GtkDialog *gtkDialog = d->gtkDialog(); const QSharedPointer<QFontDialogOptions> &opts = options(); - gtk_window_set_title(GTK_WINDOW(gtkDialog), opts->windowTitle().toUtf8()); + gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(opts->windowTitle())); } QT_END_NAMESPACE diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h index 99add3bda3..ba43046e04 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h @@ -110,6 +110,8 @@ private: static void onFilterChanged(QGtk3FileDialogHelper *helper); void applyOptions(); void setNameFilters(const QStringList &filters); + void selectFileInternal(const QUrl &filename); + void setFileChooserAction(); QUrl _dir; QList<QUrl> _selection; diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index f8cab07597..b60fa1058f 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -911,7 +911,7 @@ bool QPSQLDriver::open(const QString & db, connectString.append(QLatin1Char(' ')).append(opt); } - d->connection = PQconnectdb(connectString.toLocal8Bit().constData()); + d->connection = PQconnectdb(std::move(connectString).toLocal8Bit().constData()); if (PQstatus(d->connection) == CONNECTION_BAD) { setLastError(qMakeError(tr("Unable to connect"), QSqlError::ConnectionError, d)); setOpenError(true); @@ -1073,12 +1073,12 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const if (isIdentifierEscaped(tbl, QSqlDriver::TableName)) tbl = stripDelimiters(tbl, QSqlDriver::TableName); else - tbl = tbl.toLower(); + tbl = std::move(tbl).toLower(); if (isIdentifierEscaped(schema, QSqlDriver::TableName)) schema = stripDelimiters(schema, QSqlDriver::TableName); else - schema = schema.toLower(); + schema = std::move(schema).toLower(); switch(d->pro) { case QPSQLDriver::Version6: @@ -1153,12 +1153,12 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const if (isIdentifierEscaped(tbl, QSqlDriver::TableName)) tbl = stripDelimiters(tbl, QSqlDriver::TableName); else - tbl = tbl.toLower(); + tbl = std::move(tbl).toLower(); if (isIdentifierEscaped(schema, QSqlDriver::TableName)) schema = stripDelimiters(schema, QSqlDriver::TableName); else - schema = schema.toLower(); + schema = std::move(schema).toLower(); QString stmt; switch(d->pro) { diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index 3c6a6caffa..d655dd09ba 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -101,6 +101,7 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, return localDateTime.toUTC().time().toString(QStringLiteral("HH:mm")); } // else fall through: + Q_FALLTHROUGH(); case QCUPSSupport::NoHold: return QString(); } diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index f1ccbaa90a..37f2290d94 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -106,7 +106,7 @@ static QByteArray msgBeginFailed(const char *function, const DOCINFO &d) str << ", document \"" << QString::fromWCharArray(d.lpszDocName) << '"'; if (d.lpszOutput && d.lpszOutput[0]) str << ", file \"" << QString::fromWCharArray(d.lpszOutput) << '"'; - return result.toLocal8Bit(); + return std::move(result).toLocal8Bit(); } bool QWin32PrintEngine::begin(QPaintDevice *pdev) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 8166613e53..c0706ac22d 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -986,8 +986,8 @@ QString QSqlTableModel::orderByClause() const //we can safely escape the field because it would have been obtained from the database //and have the correct case - QString field = d->db.driver()->escapeIdentifier(f.name(), QSqlDriver::FieldName); - field.prepend(QLatin1Char('.')).prepend(d->tableName); + QString field = d->tableName + QLatin1Char('.') + + d->db.driver()->escapeIdentifier(f.name(), QSqlDriver::FieldName); field = d->sortOrder == Qt::AscendingOrder ? Sql::asc(field) : Sql::desc(field); return Sql::orderBy(field); } diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index dc20d922e5..77959341cf 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -199,8 +199,8 @@ namespace QTest { int formatResult(char * buffer, int bufferSize, T number, int significantDigits) { QString result = formatResult(number, significantDigits); - qstrncpy(buffer, result.toLatin1().constData(), bufferSize); int size = result.count(); + qstrncpy(buffer, std::move(result).toLatin1().constData(), bufferSize); return size; } } diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index efce778acf..7ddd0fcf5d 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -447,7 +447,7 @@ int main(int argc, char **argv) output.write("<node>\n"); for (const ClassDef &cdef : qAsConst(classes)) { QString xml = qDBusGenerateClassDefXml(&cdef); - output.write(xml.toLocal8Bit()); + output.write(std::move(xml).toLocal8Bit()); } output.write("</node>\n"); diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index cdf3ad3310..9ccf8be73a 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -217,7 +217,7 @@ static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection: annotationName += QString::fromLatin1(".%1%2").arg(QLatin1String(direction)).arg(paramId); QString qttype = annotations.value(annotationName); if (!qttype.isEmpty()) - return qttype.toLatin1(); + return std::move(qttype).toLatin1(); QString oldAnnotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName"); if (paramId >= 0) @@ -242,7 +242,7 @@ static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection: "suggest updating to '%s'\n", PROGRAMNAME, qPrintable(oldAnnotationName), qPrintable(inputFile), qPrintable(annotationName)); - return qttype.toLatin1(); + return std::move(qttype).toLatin1(); } return QVariant::typeToName(QVariant::Type(type)); diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 301d6fdabb..bbef010a9c 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -48,10 +48,11 @@ namespace { // Fixup an enumeration name from class Qt. // They are currently stored as "BottomToolBarArea" instead of "Qt::BottomToolBarArea". // due to MO issues. This might be fixed in the future. - void fixQtEnumerationName(QString& name) { + QLatin1String qtEnumerationPrefix(const QString &name) { static const QLatin1String prefix("Qt::"); if (name.indexOf(prefix) != 0) - name.prepend(prefix); + return prefix; + return QLatin1String(); } // figure out the toolbar area of a DOM attrib list. // By legacy, it is stored as an integer. As of 4.3.0, it is the enumeration value. @@ -62,16 +63,12 @@ namespace { switch (pstyle->kind()) { case DomProperty::Number: { - QString area = QLatin1String("static_cast<Qt::ToolBarArea>("); - area += QString::number(pstyle->elementNumber()); - area += QLatin1String("), "); - return area; + return QLatin1String("static_cast<Qt::ToolBarArea>(") + + QString::number(pstyle->elementNumber()) + QLatin1String("), "); } case DomProperty::Enum: { - QString area = pstyle->elementEnum(); - fixQtEnumerationName(area); - area += QLatin1String(", "); - return area; + const QString area = pstyle->elementEnum(); + return qtEnumerationPrefix(area) + area + QLatin1String(", "); } default: break; diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index db5af4fd7c..eec9a0021c 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -310,6 +310,7 @@ bool QAccessibleTable::selectColumn(int column) case QAbstractItemView::SingleSelection: if (view()->selectionBehavior() != QAbstractItemView::SelectColumns && rowCount() > 1) return false; + Q_FALLTHROUGH(); case QAbstractItemView::ContiguousSelection: if ((!column || !view()->selectionModel()->isColumnSelected(column - 1, view()->rootIndex())) && !view()->selectionModel()->isColumnSelected(column + 1, view()->rootIndex())) diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index 2adc58e4a4..1ff01b875c 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -1500,6 +1500,7 @@ void QGraphicsWidget::changeEvent(QEvent *event) unsetWindowFrameMargins(); if (d->layout) d->layout->invalidate(); + Q_FALLTHROUGH(); case QEvent::FontChange: update(); updateGeometry(); diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 20002b1f82..d24456edef 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -4035,6 +4035,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC switch (static_cast<const QKeyEvent*>(event)->key()) { case Qt::Key_Backtab: modifiers = modifiers & ~Qt::ShiftModifier; // special case for backtab + Q_FALLTHROUGH(); case Qt::Key_Down: case Qt::Key_Up: case Qt::Key_Left: diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index d2f9618c29..e0e993ce77 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2565,6 +2565,7 @@ void QHeaderView::mouseReleaseEvent(QMouseEvent *e) d->updateSectionIndicator(d->section, pos); break; } // not moving + Q_FALLTHROUGH(); case QHeaderViewPrivate::SelectSections: if (!d->clickableSections) { int section = logicalIndexAt(pos); diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index c044d37575..c535cf5f9e 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -55,6 +55,7 @@ #include <qapplication.h> #include <qdebug.h> +#include <vector> #include <algorithm> QT_BEGIN_NAMESPACE @@ -191,9 +192,11 @@ QByteArray QItemEditorFactory::valuePropertyName(int userType) const QItemEditorFactory::~QItemEditorFactory() { //we make sure we delete all the QItemEditorCreatorBase - //this has to be done only once, hence the QSet - QSet<QItemEditorCreatorBase*> set = creatorMap.values().toSet(); - qDeleteAll(set); + //this has to be done only once, hence the sort-unique idiom + std::vector<QItemEditorCreatorBase*> creators(creatorMap.cbegin(), creatorMap.cend()); + std::sort(creators.begin(), creators.end()); + const auto it = std::unique(creators.begin(), creators.end()); + qDeleteAll(creators.begin(), it); } /*! diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 653b03ef0d..3ef5b788c6 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -1157,6 +1157,7 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie rect.moveTop(rect.top() - d->viewport->height() + 2 * rect.height()); if (rect.top() < rect.height()) rect.moveTop(rect.height()); + Q_FALLTHROUGH(); case MovePrevious: case MoveUp: while (intersectVector.isEmpty()) { @@ -1185,6 +1186,7 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie rect.moveTop(rect.top() + d->viewport->height() - 2 * rect.height()); if (rect.bottom() > contents.height() - rect.height()) rect.moveBottom(contents.height() - rect.height()); + Q_FALLTHROUGH(); case MoveNext: case MoveDown: while (intersectVector.isEmpty()) { diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 92cd5cc0f1..851b7a33c8 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4882,6 +4882,8 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz.rheight() += 2; // Prevent icons from overlapping. } break; +#else + Q_UNUSED(d); #endif // QT_NO_ITEMVIEWS #ifndef QT_NO_SPINBOX case CT_SpinBox: diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index 3aec3cf991..19f4cc3617 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -732,6 +732,8 @@ void QPixmapStyle::drawLineEdit(const QStyleOption *option, #if QT_CONFIG(combobox) if (widget && qobject_cast<const QComboBox*>(widget->parentWidget())) return; +#else + Q_UNUSED(widget); #endif const bool enabled = option->state & State_Enabled; const bool focused = option->state & State_HasFocus; diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index e8f23f08bc..5a31eb4e52 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -493,7 +493,7 @@ QMatchData QCompletionEngine::filterHistory() bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatchData *hint) { if (c->cs == Qt::CaseInsensitive) - part = part.toLower(); + part = std::move(part).toLower(); const CacheItem& map = cache[parent]; @@ -512,7 +512,7 @@ bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatc bool QCompletionEngine::lookupCache(QString part, const QModelIndex& parent, QMatchData *m) { if (c->cs == Qt::CaseInsensitive) - part = part.toLower(); + part = std::move(part).toLower(); const CacheItem& map = cache[parent]; if (!map.contains(part)) return false; @@ -548,7 +548,7 @@ void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, con } if (c->cs == Qt::CaseInsensitive) - part = part.toLower(); + part = std::move(part).toLower(); cache[parent][part] = m; } @@ -558,7 +558,7 @@ QIndexMapper QSortedModelEngine::indexHint(QString part, const QModelIndex& pare const QAbstractItemModel *model = c->proxy->sourceModel(); if (c->cs == Qt::CaseInsensitive) - part = part.toLower(); + part = std::move(part).toLower(); const CacheItem& map = cache[parent]; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 5926476470..29c8a42cad 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -64,6 +64,8 @@ #include "qdebug.h" #include "qtextedit.h" #include <private/qtextedit_p.h> +#include <private/qwidgettextcontrol_p.h> + #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 68be82c71d..7c5ba79cb6 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -536,7 +536,8 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE // If there is a 'before' action, it takes preference // There's a bug in GHS compiler that causes internal error on the following code. - // The affected GHS compiler versions are 2016.5.4 and 2017.1 + // The affected GHS compiler versions are 2016.5.4 and 2017.1. GHS internal reference + // to track the progress of this issue is TOOLS-26637. // This temporary workaround allows to compile with GHS toolchain and should be // removed when GHS provides a patch to fix the compiler issue. diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 63b6bcfaef..98421588a7 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2330,6 +2330,9 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) } #endif +#if !QT_CONFIG(dockwidget) || !QT_CONFIG(tabbar) + Q_UNUSED(group); +#endif layoutState.unplug(path ,&savedState); savedState.fitLayout(); diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 77ed7a4f78..c16b2a5ac1 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1470,6 +1470,17 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event) } } + if (isNativeMenuBar() && event->type() == QEvent::ShowToParent) { + // On some desktops like Unity, the D-Bus menu bar is unregistered + // when the window is hidden. So when the window is shown, we need + // to forcefully re-register it. The only way to force re-registering + // with D-Bus menu is the handleReparent method. + QWidget *widget = qobject_cast<QWidget *>(object); + QWindow *handle = widget ? widget->windowHandle() : nullptr; + if (handle != nullptr) + d->platformMenuBar->handleReparent(handle); + } + if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) { if (d->altPressed) { switch (event->type()) { diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index e6332293e4..e92347c65c 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -1798,9 +1798,9 @@ QTextStream& operator>>(QTextStream& ts, QSplitter& splitter) QString line = ts.readLine(); line = line.simplified(); line.replace(QLatin1Char(' '), QString()); - line = line.toUpper(); + line = std::move(line).toUpper(); - splitter.restoreState(line.toLatin1()); + splitter.restoreState(std::move(line).toLatin1()); return ts; } diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 9e848ca834..0d34fae78f 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1144,52 +1144,8 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget case QEvent::ShortcutOverride: if (d->interactionFlags & Qt::TextEditable) { QKeyEvent* ke = static_cast<QKeyEvent *>(e); - if (ke->modifiers() == Qt::NoModifier - || ke->modifiers() == Qt::ShiftModifier - || ke->modifiers() == Qt::KeypadModifier) { - if (ke->key() < Qt::Key_Escape) { - ke->accept(); - } else { - switch (ke->key()) { - case Qt::Key_Return: - case Qt::Key_Enter: - case Qt::Key_Delete: - case Qt::Key_Home: - case Qt::Key_End: - case Qt::Key_Backspace: - case Qt::Key_Left: - case Qt::Key_Right: - case Qt::Key_Up: - case Qt::Key_Down: - case Qt::Key_Tab: - ke->accept(); - default: - break; - } - } -#ifndef QT_NO_SHORTCUT - } else if (ke == QKeySequence::Copy - || ke == QKeySequence::Paste - || ke == QKeySequence::Cut - || ke == QKeySequence::Redo - || ke == QKeySequence::Undo - || ke == QKeySequence::MoveToNextWord - || ke == QKeySequence::MoveToPreviousWord - || ke == QKeySequence::MoveToStartOfDocument - || ke == QKeySequence::MoveToEndOfDocument - || ke == QKeySequence::SelectNextWord - || ke == QKeySequence::SelectPreviousWord - || ke == QKeySequence::SelectStartOfLine - || ke == QKeySequence::SelectEndOfLine - || ke == QKeySequence::SelectStartOfBlock - || ke == QKeySequence::SelectEndOfBlock - || ke == QKeySequence::SelectStartOfDocument - || ke == QKeySequence::SelectEndOfDocument - || ke == QKeySequence::SelectAll - ) { + if (isCommonTextEditShortcut(ke)) ke->accept(); -#endif - } } break; default: diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index dd9bb4f875..9affd697a0 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -6442,7 +6442,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod if (enc.isEmpty()) enc = encoding.cap(5); if (!enc.isEmpty()) - codec = QTextCodec::codecForName(enc.toLatin1().data()); + codec = QTextCodec::codecForName(std::move(enc).toLatin1()); } if (!codec) codec = QTextCodec::codecForName("UTF-8"); diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 1724076b84..bc7d00483a 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -1407,7 +1407,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) QString encoding = extractEncodingDecl(d->encodingDeclChars, &needMoreText); if (!encoding.isEmpty()) { - if (QTextCodec *codec = QTextCodec::codecForName(encoding.toLatin1())) { + if (QTextCodec *codec = QTextCodec::codecForName(std::move(encoding).toLatin1())) { /* If the encoding is the same, we don't have to do toUnicode() all over again. */ if(codec->mibEnum() != mib) { delete d->encMapper; diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST index e11e4ae6fb..36b777de34 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST @@ -2,3 +2,4 @@ windows [finishWithUncontrolledAnimation] windows +macos-10.12 diff --git a/tests/auto/corelib/io/largefile/largefile.pro b/tests/auto/corelib/io/largefile/largefile.pro index 6c1bb8d7ea..e96d1398ca 100644 --- a/tests/auto/corelib/io/largefile/largefile.pro +++ b/tests/auto/corelib/io/largefile/largefile.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_largefile QT = core testlib SOURCES = tst_largefile.cpp +INCLUDEPATH += ../../../../shared/ +HEADERS += ../../../../shared/emulationdetector.h diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index a19a5ce58d..4e7877253f 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -47,6 +47,8 @@ # endif #endif // Q_OS_WIN +#include "emulationdetector.h" + class tst_LargeFile : public QObject { @@ -68,6 +70,10 @@ public: #else maxSizeBits = 24; // 16 MiB #endif + + // QEMU only supports < 4GB files + if (EmulationDetector::isRunningArmOnX86()) + maxSizeBits = qMin(maxSizeBits, 28); } private: diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index f8bcb14ab3..a935258fb8 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -70,6 +70,8 @@ private slots: void palette(); void modalWindow(); void quitOnLastWindowClosed(); + void quitOnLastWindowClosedMulti(); + void dontQuitOnLastWindowClosed(); void genericPluginsAndWindowSystemEvents(); void layoutDirection(); void globalShareContext(); @@ -791,107 +793,111 @@ void tst_QGuiApplication::modalWindow() void tst_QGuiApplication::quitOnLastWindowClosed() { - { - int argc = 0; - QGuiApplication app(argc, 0); - const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); + int argc = 0; + QGuiApplication app(argc, 0); + const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); - QTimer timer; - timer.setInterval(100); + QTimer timer; + timer.setInterval(100); - QSignalSpy spy(&app, SIGNAL(aboutToQuit())); - QSignalSpy spy2(&timer, SIGNAL(timeout())); + QSignalSpy spyAboutToQuit(&app, &QCoreApplication::aboutToQuit); + QSignalSpy spyTimeout(&timer, &QTimer::timeout); - QWindow mainWindow; - mainWindow.setTitle(QStringLiteral("quitOnLastWindowClosedMainWindow")); - mainWindow.resize(windowSize, windowSize); - mainWindow.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); + QWindow mainWindow; + mainWindow.setTitle(QStringLiteral("quitOnLastWindowClosedMainWindow")); + mainWindow.resize(windowSize, windowSize); + mainWindow.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); - QWindow dialog; - dialog.setTransientParent(&mainWindow); - dialog.setTitle(QStringLiteral("quitOnLastWindowClosedDialog")); - dialog.resize(windowSize, windowSize); - dialog.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing)); + QWindow dialog; + dialog.setTransientParent(&mainWindow); + dialog.setTitle(QStringLiteral("quitOnLastWindowClosedDialog")); + dialog.resize(windowSize, windowSize); + dialog.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing)); - QVERIFY(app.quitOnLastWindowClosed()); + QVERIFY(app.quitOnLastWindowClosed()); - mainWindow.show(); - dialog.show(); - QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + mainWindow.show(); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); - timer.start(); - QTimer::singleShot(1000, &mainWindow, SLOT(close())); // This should quit the application - QTimer::singleShot(2000, &app, SLOT(quit())); // This makes sure we quit even if it didn't + timer.start(); + QTimer::singleShot(1000, &mainWindow, &QWindow::close); // This should quit the application + QTimer::singleShot(2000, &app, QCoreApplication::quit); // This makes sure we quit even if it didn't - app.exec(); + app.exec(); - QCOMPARE(spy.count(), 1); - QVERIFY(spy2.count() < 15); // Should be around 10 if closing caused the quit - } - { - int argc = 0; - QGuiApplication app(argc, 0); - const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); + QCOMPARE(spyAboutToQuit.count(), 1); + // Should be around 10 if closing caused the quit + QVERIFY2(spyTimeout.count() < 15, QByteArray::number(spyTimeout.count()).constData()); +} - QTimer timer; - timer.setInterval(100); +void tst_QGuiApplication::quitOnLastWindowClosedMulti() +{ + int argc = 0; + QGuiApplication app(argc, 0); + const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); - QSignalSpy spy(&app, SIGNAL(aboutToQuit())); - QSignalSpy spy2(&timer, SIGNAL(timeout())); + QTimer timer; + timer.setInterval(100); - QWindow mainWindow; - mainWindow.setTitle(QStringLiteral("quitOnLastWindowClosedMainWindow")); - mainWindow.resize(windowSize, windowSize); - mainWindow.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); + QSignalSpy spyAboutToQuit(&app, &QCoreApplication::aboutToQuit); + QSignalSpy spyTimeout(&timer, &QTimer::timeout); - QWindow dialog; - dialog.setTitle(QStringLiteral("quitOnLastWindowClosedDialog")); - dialog.resize(windowSize, windowSize); - dialog.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing)); + QWindow mainWindow; + mainWindow.setTitle(QStringLiteral("quitOnLastWindowClosedMultiMainWindow")); + mainWindow.resize(windowSize, windowSize); + mainWindow.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); - QVERIFY(!dialog.transientParent()); - QVERIFY(app.quitOnLastWindowClosed()); + QWindow dialog; + dialog.setTitle(QStringLiteral("quitOnLastWindowClosedMultiDialog")); + dialog.resize(windowSize, windowSize); + dialog.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing)); - mainWindow.show(); - dialog.show(); - QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + QVERIFY(!dialog.transientParent()); + QVERIFY(app.quitOnLastWindowClosed()); - timer.start(); - QTimer::singleShot(1000, &mainWindow, SLOT(close())); // This should not quit the application - QTimer::singleShot(2000, &app, SLOT(quit())); + mainWindow.show(); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); - app.exec(); + timer.start(); + QTimer::singleShot(1000, &mainWindow, &QWindow::close); // This should not quit the application + QTimer::singleShot(2000, &app, &QCoreApplication::quit); - QCOMPARE(spy.count(), 1); - QVERIFY(spy2.count() > 15); // Should be around 20 if closing did not cause the quit - } - { - int argc = 0; - QGuiApplication app(argc, 0); - app.setQuitOnLastWindowClosed(false); + app.exec(); + + QCOMPARE(spyAboutToQuit.count(), 1); + // Should be around 20 if closing did not cause the quit + QVERIFY2(spyTimeout.count() > 15, QByteArray::number(spyTimeout.count()).constData()); +} + +void tst_QGuiApplication::dontQuitOnLastWindowClosed() +{ + int argc = 0; + QGuiApplication app(argc, 0); + app.setQuitOnLastWindowClosed(false); - QTimer timer; - timer.setInterval(2000); - timer.setSingleShot(true); - QObject::connect(&timer, SIGNAL(timeout()), &app, SLOT(quit())); + QTimer timer; + timer.setInterval(2000); + timer.setSingleShot(true); + QObject::connect(&timer, &QTimer::timeout, &app, &QCoreApplication::quit); - QSignalSpy spy(&app, SIGNAL(lastWindowClosed())); - QSignalSpy spy2(&timer, SIGNAL(timeout())); + QSignalSpy spyLastWindowClosed(&app, &QGuiApplication::lastWindowClosed); + QSignalSpy spyTimeout(&timer, &QTimer::timeout); - QPointer<QWindow> mainWindow = new QWindow; + QScopedPointer<QWindow> mainWindow(new QWindow); - mainWindow->show(); + mainWindow->show(); - QTimer::singleShot(1000, mainWindow, SLOT(close())); // This should not quit the application - timer.start(); + QTimer::singleShot(1000, mainWindow.data(), &QWindow::close); // This should not quit the application + timer.start(); - app.exec(); + app.exec(); - QCOMPARE(spy2.count(), 1); // quit timer fired - QCOMPARE(spy.count(), 1); // lastWindowClosed emitted + app.setQuitOnLastWindowClosed(true); // restore underlying static to default value - app.setQuitOnLastWindowClosed(true); // restore underlying static to default value - } + QCOMPARE(spyTimeout.count(), 1); // quit timer fired + QCOMPARE(spyLastWindowClosed.count(), 1); // lastWindowClosed emitted } static Qt::ScreenOrientation testOrientationToSend = Qt::PrimaryOrientation; diff --git a/tests/auto/gui/qopengl/qopengl.pro b/tests/auto/gui/qopengl/qopengl.pro index aaef6e5125..d744d37280 100644 --- a/tests/auto/gui/qopengl/qopengl.pro +++ b/tests/auto/gui/qopengl/qopengl.pro @@ -8,4 +8,4 @@ QT += gui-private core-private testlib SOURCES += tst_qopengl.cpp -linux:qtConfig(xcb-glx):qtConfig(xcb-xlib):!qtConfig(egl): DEFINES += USE_GLX +linux:qtConfig(xcb):qtConfig(xcb-glx):qtConfig(xcb-xlib):!qtConfig(egl): DEFINES += USE_GLX diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index e8244a0e5d..e52cb63384 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -244,8 +244,13 @@ void tst_QFontDatabase::addAppFont() QVERIFY(!newFamilies.isEmpty()); QVERIFY(newFamilies.count() >= oldFamilies.count()); - for (int i = 0; i < addedFamilies.count(); ++i) - QVERIFY(newFamilies.contains(addedFamilies.at(i))); + for (int i = 0; i < addedFamilies.count(); ++i) { + QString family = addedFamilies.at(i); + QVERIFY(newFamilies.contains(family)); + QFont qfont(family); + QFontInfo fi(qfont); + QCOMPARE(fi.family(), family); + } QVERIFY(QFontDatabase::removeApplicationFont(id)); QCOMPARE(fontDbChangedSpy.count(), 2); diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index e7609b3243..d7a57f5e26 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -590,8 +590,15 @@ void tst_Http2::replyFinished() { QVERIFY(nRequests); - if (const auto reply = qobject_cast<QNetworkReply *>(sender())) + if (const auto reply = qobject_cast<QNetworkReply *>(sender())) { QCOMPARE(reply->error(), QNetworkReply::NoError); + const QVariant http2Used(reply->attribute(QNetworkRequest::HTTP2WasUsedAttribute)); + QVERIFY(http2Used.isValid()); + QVERIFY(http2Used.toBool()); + const QVariant spdyUsed(reply->attribute(QNetworkRequest::SpdyWasUsedAttribute)); + QVERIFY(spdyUsed.isValid()); + QVERIFY(!spdyUsed.toBool()); + } --nRequests; if (!nRequests && serverGotSettingsACK) diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 1133a80820..9a604e5d04 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -52,6 +52,13 @@ #include <QtNetwork/qnetworksession.h> #endif +#if defined(Q_OS_LINUX) +#define SHOULD_CHECK_SYSCALL_SUPPORT +#include <netinet/in.h> +#include <sys/socket.h> +#include <errno.h> +#endif + Q_DECLARE_METATYPE(QHostAddress) QT_FORWARD_DECLARE_CLASS(QUdpSocket) @@ -115,6 +122,12 @@ protected slots: void async_readDatagramSlot(); private: + bool shouldSkipIpv6TestsForBrokenSetsockopt(); +#ifdef SHOULD_CHECK_SYSCALL_SUPPORT + bool ipv6SetsockoptionMissing(int level, int optname); +#endif + + bool m_skipUnsupportedIPv6Tests; QList<QHostAddress> allAddresses; #ifndef QT_NO_BEARERMANAGEMENT QNetworkConfigurationManager *netConfMan; @@ -125,6 +138,43 @@ private: QUdpSocket *m_asyncReceiver; }; +#ifdef SHOULD_CHECK_SYSCALL_SUPPORT +bool tst_QUdpSocket::ipv6SetsockoptionMissing(int level, int optname) +{ + int testSocket; + + testSocket = socket(PF_INET6, SOCK_DGRAM, 0); + + // If we can't test here, assume it's not missing + if (testSocket == -1) + return false; + + bool result = false; + if (setsockopt(testSocket, level, optname, nullptr, 0) == -1) + if (errno == ENOPROTOOPT) + result = true; + + close(testSocket); + return result; +} +#endif //SHOULD_CHECK_SYSCALL_SUPPORT + +bool tst_QUdpSocket::shouldSkipIpv6TestsForBrokenSetsockopt() +{ +#ifdef SHOULD_CHECK_SYSCALL_SUPPORT + // Following parameters for setsockopt are not supported by all QEMU versions: + if (ipv6SetsockoptionMissing(SOL_IPV6, IPV6_JOIN_GROUP) + || ipv6SetsockoptionMissing(SOL_IPV6, IPV6_MULTICAST_HOPS) + || ipv6SetsockoptionMissing(SOL_IPV6, IPV6_MULTICAST_IF) + || ipv6SetsockoptionMissing(SOL_IPV6, IPV6_MULTICAST_LOOP) + || ipv6SetsockoptionMissing(SOL_IPV6, IPV6_RECVHOPLIMIT)) { + return true; + } +#endif //SHOULD_CHECK_SYSCALL_SUPPORT + + return false; +} + static QHostAddress makeNonAny(const QHostAddress &address, QHostAddress::SpecialAddress preferForAny = QHostAddress::LocalHost) { if (address == QHostAddress::Any) @@ -176,6 +226,7 @@ void tst_QUdpSocket::initTestCase() if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); allAddresses = QNetworkInterface::allAddresses(); + m_skipUnsupportedIPv6Tests = shouldSkipIpv6TestsForBrokenSetsockopt(); } void tst_QUdpSocket::init() @@ -1140,6 +1191,13 @@ void tst_QUdpSocket::multicastTtlOption() expected = 0; } + // Some syscalls needed for ipv6 udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + if (bindAddress.protocol() == QAbstractSocket::IPv6Protocol) { + QSKIP("Syscalls needed for ipv6 udp multicasting missing functionality"); + } + } + QUdpSocket udpSocket; #ifdef FORCE_SESSION udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -1186,6 +1244,13 @@ void tst_QUdpSocket::multicastLoopbackOption() expected = 0; } + // Some syscalls needed for ipv6 udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + if (bindAddress.protocol() == QAbstractSocket::IPv6Protocol) { + QSKIP("Syscalls needed for ipv6 udp multicasting missing functionality"); + } + } + QUdpSocket udpSocket; #ifdef FORCE_SESSION udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -1240,6 +1305,13 @@ void tst_QUdpSocket::multicastLeaveAfterClose() if (!QtNetworkSettings::hasIPv6() && groupAddress.protocol() == QAbstractSocket::IPv6Protocol) QSKIP("system doesn't support ipv6!"); + // Some syscalls needed for ipv6 udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) { + QSKIP("Syscalls needed for ipv6 udp multicasting missing functionality"); + } + } + QUdpSocket udpSocket; #ifdef FORCE_SESSION udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -1280,6 +1352,11 @@ void tst_QUdpSocket::setMulticastInterface() QFETCH(QNetworkInterface, iface); QFETCH(QHostAddress, address); + // Some syscalls needed for udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + QSKIP("Syscalls needed for udp multicasting missing functionality"); + } + QUdpSocket udpSocket; // bind initializes the socket bool bound = udpSocket.bind((address.protocol() == QAbstractSocket::IPv6Protocol @@ -1339,6 +1416,13 @@ void tst_QUdpSocket::multicast() return; } + // Some syscalls needed for ipv6 udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) { + QSKIP("Syscalls needed for ipv6 udp multicasting missing functionality"); + } + } + QUdpSocket receiver; #ifdef FORCE_SESSION receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST index 52c023b78f..cfab0b7eb0 100644 --- a/tests/auto/network/ssl/qsslsocket/BLACKLIST +++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST @@ -5,3 +5,5 @@ windows rhel-7.2 [protocolServerSide:tls1.0-any] rhel-7.2 +[protocolServerSide] +osx-10.11 diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index f44e5261dd..4e2974b4bf 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -29,6 +29,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qthread.h> +#include <QtCore/qoperatingsystemversion.h> #include <QtNetwork/qhostaddress.h> #include <QtNetwork/qhostinfo.h> #include <QtNetwork/qnetworkproxy.h> @@ -1170,6 +1171,19 @@ void tst_QSslSocket::protocolServerSide_data() QTest::addColumn<QSsl::SslProtocol>("clientProtocol"); QTest::addColumn<bool>("works"); + // On macOS 10.11 with SecureTransport backend some tests are failing for no + // obvious reason (so no bug in our code): QTBUG-48860 - an error can be + // errSSLInternal or cipher negotiation failure. This problem does not exist + // on macOS before 10.11 and after 10.11, so we adjust these tests only for 10.11. + +#if defined(QT_SECURETRANSPORT) + using OSVersion = QOperatingSystemVersion; + const bool testWorks = OSVersion::current() < OSVersion::OSXElCapitan + || OSVersion::current() > OSVersion::OSXElCapitan; +#else + const bool testWorks = true; +#endif + #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) QTest::newRow("ssl2-ssl2") << QSsl::SslV2 << QSsl::SslV2 << false; // no idea why it does not work, but we don't care about SSL 2 #endif @@ -1194,14 +1208,14 @@ void tst_QSslSocket::protocolServerSide_data() #endif #if !defined(OPENSSL_NO_SSL3) QTest::newRow("ssl3-tls1.0") << QSsl::SslV3 << QSsl::TlsV1_0 << false; - QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << true; + QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << testWorks; QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << false; #endif #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) && !defined(OPENSSL_NO_SSL3) QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << false; // we won't set a SNI header here because we connect to a // numerical IP, so OpenSSL will send a SSL 2 handshake #elif !defined(OPENSSL_NO_SSL3) - QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << true; + QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << testWorks; #endif #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index cf92c9fab6..7dfa8e4e22 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -1195,7 +1195,9 @@ void tst_QGL::currentFboSync() QGLFramebufferObject::bindDefault(); - QCOMPARE(fbo1.toImage(), fbo2Image); + // Convert the QGLFBO's result since QOpenGLFBO uses a wider + // variety of possible return formats. + QCOMPARE(fbo1.toImage().convertToFormat(fbo2Image.format()), fbo2Image); } { diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 7404a1c49b..66c7e06760 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -45,3 +45,6 @@ SUBPROGRAMS = \ verifyexceptionthrown \ warnings \ xunit + +INCLUDEPATH += ../../../../shared/ +HEADERS += ../../../../shared/emulationdetector.h diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 0c078127b4..e7123fc059 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -36,6 +36,8 @@ #include <private/cycle_p.h> +#include "emulationdetector.h" + struct LoggerSet; class tst_Selftests: public QObject @@ -550,6 +552,7 @@ static QProcessEnvironment processEnvironment() || key == QLatin1String("GRAPHICS_ROOT") || key == QLatin1String("TZ") #elif defined(Q_OS_UNIX) || key == QLatin1String("HOME") || key == QLatin1String("USER") // Required for X11 on openSUSE + || key == QLatin1String("QEMU_SET_ENV") || key == QLatin1String("QEMU_LD_PREFIX") // Required for QEMU # if !defined(Q_OS_MAC) || key == QLatin1String("DISPLAY") || key == QLatin1String("XAUTHLOCALHOSTNAME") || key.startsWith(QLatin1String("XDG_")) @@ -642,6 +645,16 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge && subdir != QLatin1String("blacklisted") // calls qFatal() && subdir != QLatin1String("silent") // calls qFatal() #endif +#ifdef Q_OS_LINUX + // QEMU outputs to stderr about uncaught signals + && (!EmulationDetector::isRunningArmOnX86() || + (subdir != QLatin1String("blacklisted") + && subdir != QLatin1String("silent") + && subdir != QLatin1String("assert") + && subdir != QLatin1String("crashes") + ) + ) +#endif && subdir != QLatin1String("benchlibcallgrind")) QVERIFY2(err.isEmpty(), err.constData()); diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 6fe6bd2f67..4a49a94c5d 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -9,6 +9,7 @@ ubuntu-14.04 osx [updateWhileMinimized] ubuntu-14.04 +ubuntu-16.04 rhel-7.1 rhel-7.2 osx diff --git a/tests/shared/emulationdetector.h b/tests/shared/emulationdetector.h new file mode 100644 index 0000000000..bf1192a0b2 --- /dev/null +++ b/tests/shared/emulationdetector.h @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef EMULATIONDETECTOR_H +#define EMULATIONDETECTOR_H + +#if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM) +#define SHOULD_CHECK_ARM_ON_X86 + +#if QT_CONFIG(process) && !defined(QT_NO_REGULAREXPRESSION) +#include <QProcess> +#include <QRegularExpression> +#endif + +#endif + +QT_BEGIN_NAMESPACE + +// Helper functions for detecting if running emulated +namespace EmulationDetector { + +#ifdef SHOULD_CHECK_ARM_ON_X86 +static bool isX86SpecificFileAvailable(void); +static bool isReportedArchitectureX86(void); +#endif + +/* + * Check if we are running Arm binary on x86 machine. + * + * Currently this is only able to check on Linux. If not able to + * detect, return false. + */ +static bool isRunningArmOnX86() +{ +#ifdef SHOULD_CHECK_ARM_ON_X86 + if (isX86SpecificFileAvailable()) + return true; + + if (isReportedArchitectureX86()) + return true; +#endif + return false; +} + +#ifdef SHOULD_CHECK_ARM_ON_X86 +/* + * Check if we can find a file that's only available on x86 + */ +static bool isX86SpecificFileAvailable() +{ + // MTRR (Memory Type Range Registers) are a feature of the x86 architecture + // and /proc/mtrr is only present (on Linux) for that family. + // However, it's an optional kernel feature, so the absence of the file is + // not sufficient to conclude we're on real hardware. + QFileInfo mtrr("/proc/mtrr"); + if (mtrr.exists()) + return true; + return false; +} + +/* + * Check if architecture reported by the OS is x86 + */ +static bool isReportedArchitectureX86(void) +{ +#if QT_CONFIG(process) && !defined(QT_NO_REGULAREXPRESSION) + QProcess unamer; + QString machineString; + + // Using syscall "uname" is not possible since that would be captured by + // QEMU and result would be the architecture being emulated (e.g. armv7l). + // By using QProcess we get the architecture used by the host. + unamer.start("uname -a"); + if (!unamer.waitForFinished()) { + return false; + } + machineString = unamer.readAll(); + + // Is our current host cpu x86? + if (machineString.contains(QRegularExpression("i386|i686|x86"))) { + return true; + } +#endif + + return false; +} +#endif // SHOULD_CHECK_ARM_ON_X86 + +} // EmulationDetector namespace + +QT_END_NAMESPACE + +#endif + |