From 12d5608a2521bd10313b44c6c56d68b9a0a680cc Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 7 Apr 2020 21:08:12 +0200 Subject: [PATCH 01/42] macOS: Fix CONFIG+=separate_debug_info for custom QMAKE_BUNDLE_EXTENSION The code that sets up QMAKE_RESOLVED_BUNDLE did not take QMAKE_BUNDLE_EXTENSION into account. The logic is the same as in UnixMakefileGenerator::init(). Fixes: QTBUG-83222 Change-Id: I8fc4f16b399303394f2106e5c1071347ace93d4a Reviewed-by: Alexandru Croitor --- mkspecs/features/resolve_target.prf | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/resolve_target.prf b/mkspecs/features/resolve_target.prf index a9fe0d76d69..1ef1dcfd1cb 100644 --- a/mkspecs/features/resolve_target.prf +++ b/mkspecs/features/resolve_target.prf @@ -36,7 +36,11 @@ win32 { plugin_target = $$QMAKE_PLUGIN_BUNDLE_NAME else: \ plugin_target = $$TARGET - QMAKE_RESOLVED_BUNDLE = $${QMAKE_RESOLVED_TARGET}$${plugin_target}.plugin + isEmpty(QMAKE_BUNDLE_EXTENSION): \ + plugin_ext = .plugin + else: \ + plugin_ext = $$QMAKE_BUNDLE_EXTENSION + QMAKE_RESOLVED_BUNDLE = $${QMAKE_RESOLVED_TARGET}$${plugin_target}$${plugin_ext} !shallow_bundle: \ QMAKE_RESOLVED_TARGET = $${QMAKE_RESOLVED_BUNDLE}/Contents/MacOS/$${TARGET} else: \ @@ -46,7 +50,11 @@ win32 { framework_target = $$QMAKE_FRAMEWORK_BUNDLE_NAME else: \ framework_target = $$TARGET - QMAKE_RESOLVED_BUNDLE = $${QMAKE_RESOLVED_TARGET}$${framework_target}.framework + isEmpty(QMAKE_BUNDLE_EXTENSION): \ + framework_ext = .framework + else: \ + framework_ext = $$QMAKE_BUNDLE_EXTENSION + QMAKE_RESOLVED_BUNDLE = $${QMAKE_RESOLVED_TARGET}$${framework_target}$${framework_ext} !shallow_bundle { TEMP_VERSION = $$section(VERSION, ., 0, 0) isEmpty(TEMP_VERSION):TEMP_VERSION = A From 2bf5e2edbb67d6bc0ad021f79c2ff3939a174669 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 7 Apr 2020 20:47:37 +0200 Subject: [PATCH 02/42] Fix path replacement on install for header module prl files For prefix builds the prl files of header modules still contained the absolute path of the install prefix instead of $$[QT_INSTALL_LIBS]. This was, because the QMAKE_PRL_INSTALL_REPLACE variable was only filled for 'lib' TEMPLATE projects. Header modules, however, have the 'aux' template. Fixes: QTBUG-82871 Change-Id: I90f248967f1bff41423d871a977ae91c78015bbd Reviewed-by: Alexandru Croitor --- mkspecs/features/qt_common.prf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index c24f2c60621..99e9a4c1458 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -26,7 +26,8 @@ contains(TEMPLATE, .*lib) { if(!host_build|!cross_compile):qtConfig(reduce_exports): CONFIG += hide_symbols unix:qtConfig(reduce_relocations): CONFIG += bsymbolic_functions qtConfig(separate_debug_info): CONFIG += separate_debug_info - +} +contains(TEMPLATE, .*lib)|contains(TEMPLATE, aux) { !isEmpty(_QMAKE_SUPER_CACHE_): \ rplbase = $$dirname(_QMAKE_SUPER_CACHE_)/[^/][^/]* else: \ From bfb9b02d3b36244dc19c94a5693071a738bac8a2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 12:13:55 -0300 Subject: [PATCH 03/42] QCborValue: fix the move-assignment operator The double-swap technique I used was flawed and broke on self-assignment. What I had meant to use was the move-and-swap technique. Thanks to Peppe for pointing it out. This also fixes a compiler bug in the Green Hills compiler. It was finding the wrong "swap" function in qSwap: using std::swap; swap(value1, value2); It's supposed to find swap(QCborValue &, QCborValue &) due to argument- dependent lookup. It's instead finding std::swap, which recurses. Fixes: QTBUG-83390 Change-Id: Ibdc95e9af7bd456a94ecfffd1603e1bee90cd107 Reviewed-by: Giuseppe D'Angelo --- src/corelib/serialization/qcborvalue.h | 5 ++--- .../serialization/qcborvalue/tst_qcborvalue.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index f7064ac6e17..aa51e5da810 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -188,9 +188,8 @@ public: QCborValue &operator=(const QCborValue &other); QCborValue &operator=(QCborValue &&other) noexcept { - QCborValue tmp; - qSwap(*this, tmp); - qSwap(other, *this); + QCborValue tmp(std::move(other)); + swap(tmp); return *this; } diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 05cf199abe6..64321c11faa 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -385,9 +385,21 @@ void tst_QCborValue::copyCompare() { QFETCH(QCborValue, v); QCborValue other = v; + + // self-moving + v = std::move(v); + QCOMPARE(v, other); // make sure it's still valid + + // moving + v = std::move(other); + other = std::move(v); + + // normal copying + other = v; other = v; v = other; + QCOMPARE(v.compare(other), 0); QCOMPARE(v, other); QVERIFY(!(v != other)); From 10c1625cd8c32faf6a1d42c2106b3b3966175c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Apr 2020 17:00:53 +0200 Subject: [PATCH 04/42] macOS: Move translations to their respective source files lupdate can deal with Objective-C++ sources nowadays, most likely due to appending them to SOURCES instead of the deprecated OBJECTIVE_SOURCES. Task-number: QTBUG-30125 Change-Id: Ifc6b06f13e0f679a011d999f11c2e6d25dcf27ed Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/cocoa/cocoa.pro | 4 +- src/plugins/platforms/cocoa/messages.cpp | 115 ------------------ src/plugins/platforms/cocoa/messages.h | 69 ----------- src/plugins/platforms/cocoa/qcocoamenuitem.h | 12 ++ src/plugins/platforms/cocoa/qcocoamenuitem.mm | 60 ++++++++- .../platforms/cocoa/qcocoamenuloader.mm | 1 - src/plugins/platforms/cocoa/qcocoatheme.mm | 5 +- 7 files changed, 74 insertions(+), 192 deletions(-) delete mode 100644 src/plugins/platforms/cocoa/messages.cpp delete mode 100644 src/plugins/platforms/cocoa/messages.h diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index a919963cf46..a059dcebe79 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -31,8 +31,7 @@ SOURCES += main.mm \ qcocoaintrospection.mm \ qcocoakeymapper.mm \ qcocoamimetypes.mm \ - qiosurfacegraphicsbuffer.mm \ - messages.cpp + qiosurfacegraphicsbuffer.mm HEADERS += qcocoaintegration.h \ qcocoascreen.h \ @@ -63,7 +62,6 @@ HEADERS += qcocoaintegration.h \ qcocoasystemtrayicon.h \ qcocoaintrospection.h \ qcocoakeymapper.h \ - messages.h \ qiosurfacegraphicsbuffer.h \ qcocoamimetypes.h diff --git a/src/plugins/platforms/cocoa/messages.cpp b/src/plugins/platforms/cocoa/messages.cpp deleted file mode 100644 index 06e3dd454ee..00000000000 --- a/src/plugins/platforms/cocoa/messages.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 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 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. -** -** 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$ -** -****************************************************************************/ - -#include "messages.h" - -#include -#include - -// Translatable messages should go into this .cpp file for them to be picked up by lupdate. - -QT_BEGIN_NAMESPACE - -QString msgAboutQt() -{ - return QCoreApplication::translate("QCocoaMenuItem", "About Qt"); -} - -static const char *application_menu_strings[] = -{ - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"), - QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1") -}; - -QString qt_mac_applicationmenu_string(int type) -{ - QString menuString = QString::fromLatin1(application_menu_strings[type]); - const QString translated = QCoreApplication::translate("QMenuBar", application_menu_strings[type]); - if (translated != menuString) { - return translated; - } else { - return QCoreApplication::translate("MAC_APPLICATION_MENU", application_menu_strings[type]); - } -} - -QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption) -{ - QString captionNoAmpersand(caption); - captionNoAmpersand.remove(QLatin1Char('&')); - const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About"); - if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) - || captionNoAmpersand.endsWith(aboutString, Qt::CaseInsensitive)) { - static const QRegularExpression qtRegExp(QLatin1String("qt$"), QRegularExpression::CaseInsensitiveOption); - if (captionNoAmpersand.contains(qtRegExp)) - return QPlatformMenuItem::AboutQtRole; - return QPlatformMenuItem::AboutRole; - } - if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) { - return QPlatformMenuItem::PreferencesRole; - } - if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Quit"), Qt::CaseInsensitive) - || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Exit"), Qt::CaseInsensitive)) { - return QPlatformMenuItem::QuitRole; - } - if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Cut"), Qt::CaseInsensitive)) - return QPlatformMenuItem::CutRole; - if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Copy"), Qt::CaseInsensitive)) - return QPlatformMenuItem::CopyRole; - if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Paste"), Qt::CaseInsensitive)) - return QPlatformMenuItem::PasteRole; - if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Select All"), Qt::CaseInsensitive)) - return QPlatformMenuItem::SelectAllRole; - return QPlatformMenuItem::NoRole; -} - -QString msgDialogButtonDiscard() -{ - return QCoreApplication::translate("QCocoaTheme", "Don't Save"); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/messages.h b/src/plugins/platforms/cocoa/messages.h deleted file mode 100644 index 3a9eaf604e1..00000000000 --- a/src/plugins/platforms/cocoa/messages.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $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 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 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. -** -** 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$ -** -****************************************************************************/ - -#ifndef MESSAGES_H -#define MESSAGES_H - -#include -#include - -QT_BEGIN_NAMESPACE - -enum { - AboutAppMenuItem = 0, - PreferencesAppMenuItem, - ServicesAppMenuItem, - HideAppMenuItem, - HideOthersAppMenuItem, - ShowAllAppMenuItem, - QuitAppMenuItem -}; - - -QString msgAboutQt(); - -QString qt_mac_applicationmenu_string(int type); - -QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption); - -QString msgDialogButtonDiscard(); - -QT_END_NAMESPACE - -#endif // MESSAGES_H diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.h b/src/plugins/platforms/cocoa/qcocoamenuitem.h index c842b08d52f..029d29be9dc 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.h +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h @@ -53,6 +53,18 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSView); QT_BEGIN_NAMESPACE +enum { + AboutAppMenuItem = 0, + PreferencesAppMenuItem, + ServicesAppMenuItem, + HideAppMenuItem, + HideOthersAppMenuItem, + ShowAllAppMenuItem, + QuitAppMenuItem +}; + +QString qt_mac_applicationmenu_string(int type); + class QCocoaMenu; class QCocoaMenuObject diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 5aa41eeb225..c4e2dd0e922 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -45,18 +45,40 @@ #include "qcocoansmenu.h" #include "qcocoamenu.h" #include "qcocoamenubar.h" -#include "messages.h" #include "qcocoahelpers.h" #include "qt_mac_p.h" #include "qcocoaapplication.h" // for custom application category #include "qcocoamenuloader.h" #include +#include #include #include QT_BEGIN_NAMESPACE +static const char *application_menu_strings[] = +{ + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1") +}; + +QString qt_mac_applicationmenu_string(int type) +{ + QString menuString = QString::fromLatin1(application_menu_strings[type]); + const QString translated = QCoreApplication::translate("QMenuBar", application_menu_strings[type]); + if (translated != menuString) { + return translated; + } else { + return QCoreApplication::translate("MAC_APPLICATION_MENU", application_menu_strings[type]); + } +} + static quint32 constructModifierMask(quint32 accel_key) { quint32 ret = 0; @@ -226,6 +248,40 @@ void QCocoaMenuItem::setNativeContents(WId item) m_itemView.needsDisplay = YES; } +static QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption) +{ + QString captionNoAmpersand(caption); + captionNoAmpersand.remove(QLatin1Char('&')); + const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About"); + if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) + || captionNoAmpersand.endsWith(aboutString, Qt::CaseInsensitive)) { + static const QRegularExpression qtRegExp(QLatin1String("qt$"), QRegularExpression::CaseInsensitiveOption); + if (captionNoAmpersand.contains(qtRegExp)) + return QPlatformMenuItem::AboutQtRole; + return QPlatformMenuItem::AboutRole; + } + if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) { + return QPlatformMenuItem::PreferencesRole; + } + if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Quit"), Qt::CaseInsensitive) + || captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Exit"), Qt::CaseInsensitive)) { + return QPlatformMenuItem::QuitRole; + } + if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Cut"), Qt::CaseInsensitive)) + return QPlatformMenuItem::CutRole; + if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Copy"), Qt::CaseInsensitive)) + return QPlatformMenuItem::CopyRole; + if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Paste"), Qt::CaseInsensitive)) + return QPlatformMenuItem::PasteRole; + if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Select All"), Qt::CaseInsensitive)) + return QPlatformMenuItem::SelectAllRole; + return QPlatformMenuItem::NoRole; +} + NSMenuItem *QCocoaMenuItem::sync() { if (m_isSeparator != m_native.separatorItem) { @@ -354,7 +410,7 @@ QString QCocoaMenuItem::mergeText() return qt_mac_applicationmenu_string(AboutAppMenuItem).arg(qt_mac_applicationName()); } else if (m_native== [loader aboutQtMenuItem]) { if (m_text == QString("About Qt")) - return msgAboutQt(); + return QCoreApplication::translate("QCocoaMenuItem", "About Qt"); else return m_text; } else if (m_native == [loader preferencesMenuItem]) { diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm index d384078e91b..a7c17fc1775 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm @@ -39,7 +39,6 @@ #include "qcocoamenuloader.h" -#include "messages.h" #include "qcocoahelpers.h" #include "qcocoansmenu.h" #include "qcocoamenubar.h" diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index a76ba300e9b..d73b028afb1 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -40,7 +40,6 @@ #import #include "qcocoatheme.h" -#include "messages.h" #include #include @@ -547,7 +546,9 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const QString QCocoaTheme::standardButtonText(int button) const { - return button == QPlatformDialogHelper::Discard ? msgDialogButtonDiscard() : QPlatformTheme::standardButtonText(button); + return button == QPlatformDialogHelper::Discard ? + QCoreApplication::translate("QCocoaTheme", "Don't Save") + : QPlatformTheme::standardButtonText(button); } QKeySequence QCocoaTheme::standardButtonShortcut(int button) const From 504b37e39955f223ccd80188bd1badbd197286e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 6 Apr 2020 14:50:38 +0200 Subject: [PATCH 05/42] syncqt: Ignore deprecation macros when resolving class names Otherwise we will fail to resolve the symbol and will not create a forwarding header for the class. Change-Id: I34922d8458bdb994a194108183ac9b9d14530c5e Reviewed-by: Simon Hausmann --- bin/syncqt.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/syncqt.pl b/bin/syncqt.pl index 72996a526e7..7ede34cf1d1 100755 --- a/bin/syncqt.pl +++ b/bin/syncqt.pl @@ -231,7 +231,6 @@ sub classNames { $line .= ";" if($line =~ m/^Q_[A-Z_0-9]*\(.*\)[\r\n]*$/); #qt macro $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE(_[A-Z]+)*[\r\n]*$/); #qt macro - $line .= ";" if($line =~ m/^QT_DEPRECATED_X\(.*\)[\r\n]*$/); #qt macro $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro $line .= ";" if($line =~ m/^QT_WARNING_(PUSH|POP|DISABLE_\w+\(.*\))[\r\n]*$/); # qt macros $$requires = $1 if ($line =~ m/^QT_REQUIRE_CONFIG\((.*)\);[\r\n]*$/); @@ -298,6 +297,7 @@ sub classNames { if($definition) { $definition =~ s=[\n\r]==g; + $definition =~ s/QT_DEPRECATED_X\s*\(\s*".*?"\s*\)//g; my @symbols; my $post_kw = qr/Q_DECL_FINAL|final|sealed/; # add here macros and keywords that go after the class-name of a class definition if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) { From e7eff98401723ff7e4e8d962405f9af1b53b9759 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 4 Mar 2020 13:36:27 +0100 Subject: [PATCH 06/42] Android: Only check for uri permissions when it is a file or content This amends f36b042e2b66a3ad32980b21e9fafc1bd9b0c7c1 to only check permissions for uris that are going to be local to the device itself. Other uris, such as http, https etc, should go through fine without a check. Change-Id: If05caadb6e0712d9db8f57185ef017d724d9e172 Reviewed-by: Assam Boudjelthia --- .../jar/src/org/qtproject/qt5/android/QtNative.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 a8bf4c15e13..76ecbe043b8 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -160,8 +160,13 @@ public class QtNative private static Uri getUriWithValidPermission(Context context, String uri, String openMode) { try { + Uri parsedUri = Uri.parse(uri); + String scheme = parsedUri.getScheme(); + // We only want to check permissions for files and content Uris + if (scheme.compareTo("file") != 0 && scheme.compareTo("content") != 0) + return parsedUri; List permissions = context.getContentResolver().getPersistedUriPermissions(); - String uriStr = Uri.parse(uri).getPath(); + String uriStr = parsedUri.getPath(); for (int i = 0; i < permissions.size(); ++i) { Uri iterUri = permissions.get(i).getUri(); From 9ba09e26d7fc667355d48a7d26361be6fb20612d Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 14 Apr 2020 09:36:04 +0200 Subject: [PATCH 07/42] QSettings: Read past UTF-8 BOM even without textcodec support Try to read past an UTF-8 BOM even if no textcodec support is available, but do set the status to FormatError then. This is in line with the general 'best effort' approach in QSettings. It also allows qmake (that is built without textcodec support) to gracefully load qt.conf files with a UTF-8 BOM, though non-Latin1 characters might still be misrepresented. Fixes: QTBUG-83456 Change-Id: I31b45dc5a8adf7950910897a2b33ae16990d3818 Reviewed-by: Thiago Macieira Reviewed-by: Joerg Bornemann --- src/corelib/io/qsettings.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index b191397e7ee..c69ec908edc 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1673,14 +1673,16 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, int sectionPosition = 0; bool ok = true; -#if QT_CONFIG(textcodec) // detect utf8 BOM const uchar *dd = (const uchar *)data.constData(); if (data.size() >= 3 && dd[0] == 0xef && dd[1] == 0xbb && dd[2] == 0xbf) { +#if QT_CONFIG(textcodec) iniCodec = QTextCodec::codecForName("UTF-8"); +#else + ok = false; +#endif dataPos = 3; } -#endif while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) { char ch = data.at(lineStart); From c2efc16126a9706d83f8b80133d46342baaa3265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Apr 2020 14:55:56 +0200 Subject: [PATCH 08/42] macOS: Replace foreach with ranged for loops Change-Id: I9d0dbb60e05e4ef85219740465bb941ef8d8eb0f Reviewed-by: Simon Hausmann --- src/plugins/platforms/cocoa/cocoa.pro | 2 ++ src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 2 +- src/plugins/platforms/cocoa/qcocoaintegration.mm | 2 +- src/plugins/platforms/cocoa/qcocoamenubar.mm | 2 +- src/plugins/platforms/cocoa/qcocoaprintdevice.mm | 4 ++-- src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm | 2 +- src/plugins/platforms/cocoa/qcocoawindow.mm | 2 +- src/plugins/platforms/cocoa/qmultitouch_mac.mm | 2 +- src/plugins/platforms/cocoa/qprintengine_mac.mm | 4 ++-- 9 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index a059dcebe79..6b93b1acf06 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -92,6 +92,8 @@ RESOURCES += qcocoaresources.qrc LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups +DEFINES += QT_NO_FOREACH + QT += \ core-private gui-private \ clipboard_support-private theme_support-private \ diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 3560c9d9b5e..d86191ffa96 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -547,7 +547,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of return nsActions; const QStringList &supportedActionNames = QAccessibleBridgeUtils::effectiveActionNames(iface); - foreach (const QString &qtAction, supportedActionNames) { + for (const QString &qtAction : supportedActionNames) { NSString *nsAction = QCocoaAccessible::getTranslatedAction(qtAction); if (nsAction) [nsActions addObject : nsAction]; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index deddcd3f989..245db429c54 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -116,7 +116,7 @@ class QFontEngineFT; static QCocoaIntegration::Options parseOptions(const QStringList ¶mList) { QCocoaIntegration::Options options; - foreach (const QString ¶m, paramList) { + for (const QString ¶m : paramList) { #ifndef QT_NO_FREETYPE if (param == QLatin1String("fontengine=freetype")) options |= QCocoaIntegration::UseFreeTypeFontEngine; diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 363defdd280..a2a8535547f 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -191,7 +191,7 @@ void QCocoaMenuBar::syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate) QMacAutoReleasePool pool; QCocoaMenu *cocoaMenu = static_cast(menu); - Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items()) + for (QCocoaMenuItem *item : cocoaMenu->items()) cocoaMenu->syncMenuItem_helper(item, menubarUpdate); BOOL shouldHide = YES; diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm index 7605dc9d1af..6f7f29bb5e1 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm @@ -117,7 +117,7 @@ QCocoaPrintDevice::~QCocoaPrintDevice() { if (m_ppd) ppdClose(m_ppd); - foreach (PMPaper paper, m_macPapers) + for (PMPaper paper : m_macPapers) PMRelease(paper); // Releasing the session appears to also release the printer if (m_session) @@ -171,7 +171,7 @@ QPageSize QCocoaPrintDevice::createPageSize(const PMPaper &paper) const void QCocoaPrintDevice::loadPageSizes() const { m_pageSizes.clear(); - foreach (PMPaper paper, m_macPapers) + for (PMPaper paper : m_macPapers) PMRelease(paper); m_macPapers.clear(); m_printableMargins.clear(); diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 8e7c86a0ef5..0e48318141b 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -162,7 +162,7 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon) qreal devicePixelRatio = qApp->devicePixelRatio(); const int maxPixmapHeight = maxImageHeight * devicePixelRatio; QSize selectedSize; - Q_FOREACH (const QSize& size, sortByHeight(icon.availableSizes())) { + for (const QSize& size : sortByHeight(icon.availableSizes())) { // Select a pixmap based on the height. We want the largest pixmap // with a height smaller or equal to maxPixmapHeight. The pixmap // may rectangular; assume it has a reasonable size. If there is diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c539afbfcd1..79dfe58a4e2 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1833,7 +1833,7 @@ qreal QCocoaWindow::devicePixelRatio() const QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint) { QWindow *targetWindow = window(); - foreach (QObject *child, targetWindow->children()) + for (QObject *child : targetWindow->children()) if (QWindow *childWindow = qobject_cast(child)) if (QPlatformWindow *handle = childWindow->handle()) if (handle->isExposed() && childWindow->geometry().contains(windowPoint)) diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac.mm b/src/plugins/platforms/cocoa/qmultitouch_mac.mm index 10652dc6a1b..95256657fe2 100644 --- a/src/plugins/platforms/cocoa/qmultitouch_mac.mm +++ b/src/plugins/platforms/cocoa/qmultitouch_mac.mm @@ -184,7 +184,7 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) if (_touchCount != _currentTouches.size()) { // Remove all instances, and basically start from scratch: touchPoints.clear(); - foreach (QCocoaTouch *qcocoaTouch, _currentTouches) { + for (QCocoaTouch *qcocoaTouch : _currentTouches) { if (!_updateInternalStateOnly) { qcocoaTouch->_touchPoint.state = Qt::TouchPointReleased; touchPoints.insert(qcocoaTouch->_touchPoint.id, qcocoaTouch->_touchPoint); diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index dcb9a85a3c7..5833d097fd1 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -485,7 +485,7 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va int bestResolution = 0; int dpi = value.toInt(); int bestDistance = INT_MAX; - foreach (int resolution, d->m_printDevice->supportedResolutions()) { + for (int resolution : d->m_printDevice->supportedResolutions()) { if (dpi == resolution) { bestResolution = resolution; break; @@ -758,7 +758,7 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const } case PPK_SupportedResolutions: { QList list; - foreach (int resolution, d->m_printDevice->supportedResolutions()) + for (int resolution : d->m_printDevice->supportedResolutions()) list << resolution; ret = list; break; From eaada70d4e76d0c35afcb36930154818a1eb1e49 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 26 Mar 2020 13:48:27 +0100 Subject: [PATCH 09/42] Fix deprecation warnings in QCocoaCursor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explicitly use the Qt APIs that return QPixmap and QBitmap by value, and fix the API taking those to use const references rather than pointers or const values. Change-Id: I2bb7ad1edb3b65f806f0475fca383e5b9bdb61f3 Reviewed-by: Morten Johan Sørvig (cherry picked from commit b61ea367a5f8d07afda36b49b039b2375142d7f4) Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/cocoa/qcocoacursor.h | 4 ++-- src/plugins/platforms/cocoa/qcocoacursor.mm | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h index 5b008eff355..6589891ef2d 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.h +++ b/src/plugins/platforms/cocoa/qcocoacursor.h @@ -63,8 +63,8 @@ private: QHash m_cursors; NSCursor *convertCursor(QCursor *cursor); NSCursor *createCursorData(QCursor * cursor); - NSCursor *createCursorFromBitmap(const QBitmap *bitmap, const QBitmap *mask, const QPoint hotspot = QPoint()); - NSCursor *createCursorFromPixmap(const QPixmap pixmap, const QPoint hotspot = QPoint()); + NSCursor *createCursorFromBitmap(const QBitmap &bitmap, const QBitmap &mask, const QPoint hotspot = QPoint()); + NSCursor *createCursorFromPixmap(const QPixmap &pixmap, const QPoint hotspot = QPoint()); }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index c10ada1ada2..8ca72ec6192 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -243,7 +243,7 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor) switch (cursor->shape()) { case Qt::BitmapCursor: { if (cursor->pixmap().isNull()) - return createCursorFromBitmap(cursor->bitmap(), cursor->mask(), hotspot); + return createCursorFromBitmap(cursor->bitmap(Qt::ReturnByValue), cursor->mask(Qt::ReturnByValue), hotspot); else return createCursorFromPixmap(cursor->pixmap(), hotspot); break; } @@ -301,17 +301,17 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor) if (cursorData) { QBitmap bitmap(QBitmap::fromData(QSize(16, 16), cursorData, QImage::Format_Mono)); QBitmap mask(QBitmap::fromData(QSize(16, 16), cursorMaskData, QImage::Format_Mono)); - return (createCursorFromBitmap(&bitmap, &mask, hotspot)); + return (createCursorFromBitmap(bitmap, mask, hotspot)); } return nil; // should not happen, all cases covered above } -NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap *bitmap, const QBitmap *mask, const QPoint hotspot) +NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap &bitmap, const QBitmap &mask, const QPoint hotspot) { - QImage finalCursor(bitmap->size(), QImage::Format_ARGB32); - QImage bmi = bitmap->toImage().convertToFormat(QImage::Format_RGB32); - QImage bmmi = mask->toImage().convertToFormat(QImage::Format_RGB32); + QImage finalCursor(bitmap.size(), QImage::Format_ARGB32); + QImage bmi = bitmap.toImage().convertToFormat(QImage::Format_RGB32); + QImage bmmi = mask.toImage().convertToFormat(QImage::Format_RGB32); for (int row = 0; row < finalCursor.height(); ++row) { QRgb *bmData = reinterpret_cast(bmi.scanLine(row)); QRgb *bmmData = reinterpret_cast(bmmi.scanLine(row)); @@ -332,7 +332,7 @@ NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap *bitmap, const QBit return createCursorFromPixmap(QPixmap::fromImage(finalCursor), hotspot); } -NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap pixmap, const QPoint hotspot) +NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap &pixmap, const QPoint hotspot) { NSPoint hotSpot = NSMakePoint(hotspot.x(), hotspot.y()); auto *image = [NSImage imageFromQImage:pixmap.toImage()]; From d6fe9c2160f70c2135a45a135f92c847508fb43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 3 Apr 2020 15:00:58 +0200 Subject: [PATCH 10/42] Deprecate QMacNativeWidget and QMacCocoaViewContainer Change-Id: I489870f97dcf7b54a4427ead3a9e627dd938f4ca Reviewed-by: Timur Pocheptsov --- src/corelib/global/qcompilerdetection.h | 8 ++++++++ src/widgets/widgets/qmaccocoaviewcontainer_mac.h | 5 ++++- src/widgets/widgets/qmaccocoaviewcontainer_mac.mm | 2 +- src/widgets/widgets/qmacnativewidget_mac.h | 5 ++++- src/widgets/widgets/qmenu.cpp | 2 +- src/widgets/widgets/qmenu_mac.mm | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index aa38ef18c0a..ebffe74188a 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1306,6 +1306,14 @@ # define QT_WARNING_DISABLE_DEPRECATED #endif +#ifndef QT_IGNORE_DEPRECATIONS +#define QT_IGNORE_DEPRECATIONS(statement) \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_DEPRECATED \ + statement \ + QT_WARNING_POP +#endif + /* Proper for-scoping in MIPSpro CC */ diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h index 0de39891671..a9d075638f1 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h @@ -47,8 +47,10 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSView); QT_BEGIN_NAMESPACE +#if QT_DEPRECATED_SINCE(5, 15) class QMacCocoaViewContainerPrivate; -class Q_WIDGETS_EXPORT QMacCocoaViewContainer : public QWidget +class QT_DEPRECATED_X("Use QWindow::fromWinId and QWidget::createWindowContainer instead") +Q_WIDGETS_EXPORT QMacCocoaViewContainer : public QWidget { Q_OBJECT public: @@ -61,6 +63,7 @@ public: private: Q_DECLARE_PRIVATE(QMacCocoaViewContainer) }; +#endif QT_END_NAMESPACE diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm index f261314c644..d56c6ab68b8 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm @@ -114,7 +114,7 @@ QT_BEGIN_NAMESPACE class QMacCocoaViewContainerPrivate : public QWidgetPrivate { - Q_DECLARE_PUBLIC(QMacCocoaViewContainer) + QT_IGNORE_DEPRECATIONS(Q_DECLARE_PUBLIC(QMacCocoaViewContainer)) public: NSView *nsview; QMacCocoaViewContainerPrivate(); diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h index 6fd90516ac0..751f5209348 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.h +++ b/src/widgets/widgets/qmacnativewidget_mac.h @@ -47,7 +47,9 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSView); QT_BEGIN_NAMESPACE -class Q_WIDGETS_EXPORT QMacNativeWidget : public QWidget +#if QT_DEPRECATED_SINCE(5, 15) +class QT_DEPRECATED_X("Use QWidget::winId instead") +Q_WIDGETS_EXPORT QMacNativeWidget : public QWidget { Q_OBJECT public: @@ -60,6 +62,7 @@ public: protected: bool event(QEvent *ev) override; }; +#endif QT_END_NAMESPACE diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 86978cb6814..865e3b2fb6c 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -3549,7 +3549,7 @@ void QMenu::actionEvent(QActionEvent *e) if (QWidget *widget = d->widgetItems.value(wa)) { #ifdef Q_OS_MACOS QWidget *p = widget->parentWidget(); - if (p != this && qobject_cast(p)) { + if (p != this && QT_IGNORE_DEPRECATIONS(qobject_cast(p))) { // This widget was reparented into a native Mac view // (see QMenuPrivate::moveWidgetToPlatformItem). // Reset the parent and delete the native widget. diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm index 0872da803dd..81a98f2d140 100644 --- a/src/widgets/widgets/qmenu_mac.mm +++ b/src/widgets/widgets/qmenu_mac.mm @@ -125,7 +125,7 @@ void QMenu::setAsDockMenu() void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem* item) { - QMacNativeWidget *container = new QMacNativeWidget; + auto *container = new QT_IGNORE_DEPRECATIONS(QMacNativeWidget); QObject::connect(platformMenu, SIGNAL(destroyed()), container, SLOT(deleteLater())); container->resize(widget->sizeHint()); widget->setParent(container); From 6e0591437a3174aa1d0a20f71e429126a3958c4f Mon Sep 17 00:00:00 2001 From: Lars Schmertmann Date: Fri, 3 Apr 2020 08:51:28 +0200 Subject: [PATCH 11/42] Add information for macOS to qsystemdetection.h Change-Id: Ibc99b5481709b1b99cdbbdd94ad544175871cbae Reviewed-by: Alex Blasche Reviewed-by: Thiago Macieira --- src/corelib/global/qsystemdetection.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index a020788b113..fe7d7d880b6 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -76,6 +76,8 @@ The following operating systems have variants: LINUX - both Q_OS_LINUX and Q_OS_ANDROID are defined when building for Android - only Q_OS_LINUX is defined if building for other Linux systems + MACOS - both Q_OS_BSD4 and Q_OS_IOS are defined when building for iOS + - both Q_OS_BSD4 and Q_OS_MACOS are defined when building for macOS FREEBSD - Q_OS_FREEBSD is defined only when building for FreeBSD with a BSD userland - Q_OS_FREEBSD_KERNEL is always defined on FreeBSD, even if the userland is from GNU */ From c034089fa697e6dc22f04b3209768a9dc1abcb9c Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Mon, 17 Feb 2020 11:08:30 +1000 Subject: [PATCH 12/42] wasm: do not try to resume main thread if mainloop has not started yet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit d928beb024c240b37d35d2c53f25648c99a484b4) Fixes: QTBUG-83293 Change-Id: Ibd891629d1d023e47d196dd60821cc5c583a178d Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmeventdispatcher.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp index ca8db9b2154..2e1b0835573 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp @@ -194,7 +194,8 @@ void QWasmEventDispatcher::wakeUp() { #ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD if (!emscripten_is_main_runtime_thread()) - emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, (void*)(&QWasmEventDispatcher::mainThreadWakeUp), this); + if (m_hasMainLoop) + emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, (void*)(&QWasmEventDispatcher::mainThreadWakeUp), this); #endif QEventDispatcherUNIX::wakeUp(); } From 5e3b32b60813cbdb4ceba42d33a9b7738e313cbf Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Thu, 9 Apr 2020 21:42:48 +0200 Subject: [PATCH 13/42] Fuzzing: Add fuzz target for QTextStream's extraction operator Change-Id: Ia5fa2e36f5439ebcc323d6d18c33c2dd58404aba Reviewed-by: Albert Astals Cid --- .../extractionoperator-float.pro | 10 ++++++ .../extractionoperator-float/main.cpp | 36 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro create mode 100644 tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp diff --git a/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro new file mode 100644 index 00000000000..6c988c24342 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/extractionoperator-float.pro @@ -0,0 +1,10 @@ +QT -= gui +CONFIG += console +CONFIG -= app_bundle +SOURCES += main.cpp +FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) +isEmpty(FUZZ_ENGINE) { + QMAKE_LFLAGS += -fsanitize=fuzzer +} else { + LIBS += $$FUZZ_ENGINE +} diff --git a/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp new file mode 100644 index 00000000000..10d5c3222e2 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qtextstream/extractionoperator-float/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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$ +** +****************************************************************************/ + +#include + +extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + QTextStream qts(QByteArray::fromRawData(Data, Size)); + float f; + qts >> f; + return 0; +} From c92fedd761206231f13838528943619b84df55bf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Apr 2020 08:09:04 +0200 Subject: [PATCH 14/42] Windows QPA: Fix restoring from fullscreen in High DPI setups The logic for checking whether the saved geometry (native pixels) is still within a screen compared them against logical coordinates. Work with the platform screen geometry instead. Fixes: QTBUG-83448 Change-Id: Ib68f967d1a33a490f88a7bec6dcc788788a10389 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 322eae7a064..01f6bef42e1 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2287,8 +2287,10 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowStates newState) if (!screen) screen = QGuiApplication::primaryScreen(); // That area of the virtual desktop might not be covered by a screen anymore. - if (!screen->geometry().intersects(m_savedFrameGeometry)) - m_savedFrameGeometry.moveTo(screen->geometry().topLeft()); + if (const auto platformScreen = screen->handle()) { + if (!platformScreen->geometry().intersects(m_savedFrameGeometry)) + m_savedFrameGeometry.moveTo(platformScreen->geometry().topLeft()); + } if (newState & Qt::WindowMinimized) { setMinimizedGeometry(m_data.hwnd, m_savedFrameGeometry); From 18fa1ed74745931c15d525703ac05bbf3f2c9c5b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Apr 2020 12:25:07 +0200 Subject: [PATCH 15/42] Windows QPA: Fix showing translucent windows maximized/full screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Translucent (layered) windows require an additional expose event. This was sent with the wrong size since the order of handleGeometryChange(), handleWindowStateChange() in handleResized was wrong. Fixes: QTBUG-83449 Change-Id: Iafd3fa8c0893aa28079201f73b7eb529087ba079 Reviewed-by: André de la Rocha Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 01f6bef42e1..429e30728fa 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1904,12 +1904,13 @@ void QWindowsWindow::handleResized(int wParam) handleWindowStateChange(m_windowState | Qt::WindowMinimized); return; case SIZE_MAXIMIZED: + handleGeometryChange(); if (!testFlag(WithinSetStyle) && !testFlag(WithinSetGeometry)) handleWindowStateChange(Qt::WindowMaximized | (isFullScreen_sys() ? Qt::WindowFullScreen : Qt::WindowNoState)); - handleGeometryChange(); break; case SIZE_RESTORED: + handleGeometryChange(); if (!testFlag(WithinSetStyle) && !testFlag(WithinSetGeometry)) { if (isFullScreen_sys()) handleWindowStateChange( @@ -1918,7 +1919,6 @@ void QWindowsWindow::handleResized(int wParam) else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen)) handleWindowStateChange(Qt::WindowNoState); } - handleGeometryChange(); break; } } From 8907635da59c2ae0e8db01f27b24a841b830e655 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 13 Apr 2020 20:31:34 +0200 Subject: [PATCH 16/42] OpenSSL: handle SSL_shutdown's errors properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not call SSL_shutdown on a session that is in handshake state (SSL_in_init(s) returns 1). Also, do not call SSL_shutdown if a session encountered a fatal error (SSL_ERROR_SYSCALL or SSL_ERROR_SSL was found before). If SSL_shutdown was unsuccessful (returned code != 1), we have to clear the error(s) it queued. Fixes: QTBUG-83450 Change-Id: I6326119f4e79605429263045ac20605c30dccca3 Reviewed-by: Mårten Nordheim --- src/network/ssl/qsslsocket.cpp | 2 +- src/network/ssl/qsslsocket_openssl.cpp | 23 ++++++++++++++----- .../ssl/qsslsocket_openssl_symbols.cpp | 2 ++ .../ssl/qsslsocket_openssl_symbols_p.h | 1 + src/network/ssl/qsslsocket_p.h | 1 + 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 8f1d5d377d4..f4117320365 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -2241,7 +2241,7 @@ void QSslSocketPrivate::init() pendingClose = false; flushTriggered = false; ocspResponses.clear(); - + systemOrSslErrorDetected = false; // we don't want to clear the ignoreErrorsList, so // that it is possible setting it before connecting // ignoreErrorsList.clear(); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 9b28d52e211..859216d0975 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -649,10 +649,16 @@ bool QSslSocketBackendPrivate::initSslContext() void QSslSocketBackendPrivate::destroySslContext() { if (ssl) { - // We do not send a shutdown alert here. Just mark the session as - // resumable for qhttpnetworkconnection's "optimization", otherwise - // OpenSSL won't start a session resumption. - q_SSL_shutdown(ssl); + if (!q_SSL_in_init(ssl) && !systemOrSslErrorDetected) { + // We do not send a shutdown alert here. Just mark the session as + // resumable for qhttpnetworkconnection's "optimization", otherwise + // OpenSSL won't start a session resumption. + if (q_SSL_shutdown(ssl) != 1) { + // Some error may be queued, clear it. + const auto errors = getErrorsFromOpenSsl(); + Q_UNUSED(errors); + } + } q_SSL_free(ssl); ssl = nullptr; } @@ -1126,6 +1132,7 @@ void QSslSocketBackendPrivate::transmit() case SSL_ERROR_SSL: // error in the SSL library // we do not know exactly what the error is, nor whether we can recover from it, // so just return to prevent an endless loop in the outer "while" statement + systemOrSslErrorDetected = true; { const ScopedBool bg(inSetAndEmitError, true); setErrorAndEmit(QAbstractSocket::SslInternalError, @@ -1777,8 +1784,12 @@ bool QSslSocketBackendPrivate::checkOcspStatus() void QSslSocketBackendPrivate::disconnectFromHost() { if (ssl) { - if (!shutdown) { - q_SSL_shutdown(ssl); + if (!shutdown && !q_SSL_in_init(ssl) && !systemOrSslErrorDetected) { + if (q_SSL_shutdown(ssl) != 1) { + // Some error may be queued, clear it. + const auto errors = getErrorsFromOpenSsl(); + Q_UNUSED(errors); + } shutdown = true; transmit(); } diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 6fe602a79ec..627ae31651f 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -373,6 +373,7 @@ DEFINEFUNC3(void, SSL_set_bio, SSL *a, a, BIO *b, b, BIO *c, c, return, DUMMYARG DEFINEFUNC(void, SSL_set_accept_state, SSL *a, a, return, DUMMYARG) DEFINEFUNC(void, SSL_set_connect_state, SSL *a, a, return, DUMMYARG) DEFINEFUNC(int, SSL_shutdown, SSL *a, a, return -1, return) +DEFINEFUNC(int, SSL_in_init, const SSL *a, a, return 0, return) DEFINEFUNC(int, SSL_get_shutdown, const SSL *ssl, ssl, return 0, return) DEFINEFUNC2(int, SSL_set_session, SSL* to, to, SSL_SESSION *session, session, return -1, return) DEFINEFUNC(void, SSL_SESSION_free, SSL_SESSION *ses, ses, return, DUMMYARG) @@ -1065,6 +1066,7 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(SSL_set_bio) RESOLVEFUNC(SSL_set_connect_state) RESOLVEFUNC(SSL_shutdown) + RESOLVEFUNC(SSL_in_init) RESOLVEFUNC(SSL_get_shutdown) RESOLVEFUNC(SSL_set_session) RESOLVEFUNC(SSL_SESSION_free) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index f35e0ba22be..e8f6b7e752a 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -516,6 +516,7 @@ void q_SSL_set_bio(SSL *a, BIO *b, BIO *c); void q_SSL_set_accept_state(SSL *a); void q_SSL_set_connect_state(SSL *a); int q_SSL_shutdown(SSL *a); +int q_SSL_in_init(const SSL *s); int q_SSL_get_shutdown(const SSL *ssl); int q_SSL_set_session(SSL *to, SSL_SESSION *session); void q_SSL_SESSION_free(SSL_SESSION *ses); diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index 1abd18bb32a..87179c8083a 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -207,6 +207,7 @@ protected: bool verifyErrorsHaveBeenIgnored(); bool paused; bool flushTriggered; + bool systemOrSslErrorDetected = false; QVector ocspResponses; }; From 4bb803477bacc70f756b1aaea9e048b2bae0fa6a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Apr 2020 11:03:32 +0200 Subject: [PATCH 17/42] Windows QPA: Fix geometry when firing a full expose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are several places in the code where a full expose event is fired, but the geometry in logical coordinates is used (pre-dating High DPI scaling). Fix by introducing a helper function for it. Task-number: QTBUG-83449 Change-Id: Ie8bb306de0b9b2b85306ed1bb6ba71181b76a958 Reviewed-by: André de la Rocha Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 13 +++++++++---- src/plugins/platforms/windows/qwindowswindow.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 429e30728fa..6b53e3d4c48 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1401,6 +1401,11 @@ void QWindowsWindow::fireExpose(const QRegion ®ion, bool force) QWindowSystemInterface::handleExposeEvent(window(), region); } +void QWindowsWindow::fireFullExpose(bool force) +{ + fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), force); +} + void QWindowsWindow::destroyWindow() { qCDebug(lcQpaWindows) << __FUNCTION__ << this << window() << m_data.hwnd; @@ -1561,7 +1566,7 @@ void QWindowsWindow::setVisible(bool visible) // over the rendering of the window // There is nobody waiting for this, so we don't need to flush afterwards. if (isLayered()) - fireExpose(QRect(0, 0, win->width(), win->height())); + fireFullExpose(); // QTBUG-44928, QTBUG-7386: This is to resolve the problem where popups are // opened from the system tray and not being implicitly activated @@ -1966,7 +1971,7 @@ void QWindowsWindow::handleGeometryChange() && m_data.geometry.size() != previousGeometry.size() // Exclude plain move // One dimension grew -> Windows will send expose, no need to synthesize. && !(m_data.geometry.width() > previousGeometry.width() || m_data.geometry.height() > previousGeometry.height())) { - fireExpose(QRect(QPoint(0, 0), m_data.geometry.size()), true); + fireFullExpose(true); } const bool wasSync = testFlag(SynchronousGeometryChangeEvent); @@ -2165,7 +2170,7 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state) QWindow *w = window(); bool exposeEventsSent = false; if (isLayered()) { - fireExpose(QRegion(0, 0, w->width(), w->height())); + fireFullExpose(); exposeEventsSent = true; } const QWindowList allWindows = QGuiApplication::allWindows(); @@ -2173,7 +2178,7 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state) if (child != w && child->isVisible() && child->transientParent() == w) { QWindowsWindow *platformWindow = QWindowsWindow::windowsWindowOf(child); if (platformWindow && platformWindow->isLayered()) { - platformWindow->fireExpose(QRegion(0, 0, child->width(), child->height())); + platformWindow->fireFullExpose(); exposeEventsSent = true; } } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index b35081d41da..cd6179bf03f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -373,6 +373,7 @@ private: void handleWindowStateChange(Qt::WindowStates state); inline void destroyIcon(); void fireExpose(const QRegion ®ion, bool force=false); + void fireFullExpose(bool force=false); void calculateFullFrameMargins(); mutable QWindowsWindowData m_data; From 7fd271e733cb30cbc9062206e36076497edbc2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Apr 2020 14:58:22 +0200 Subject: [PATCH 18/42] macOS: Clean up header includes to use quotes or brackets as appropriate The includes can be sorted and unified even more, but that's left for another rainy day. Change-Id: I4d5670d6d8389f69d2631b83b8f421d1f685a0f9 Reviewed-by: Volker Hilsheimer --- .../cocoa/qcocoaaccessibilityelement.mm | 3 ++- .../platforms/cocoa/qcocoaapplication.h | 4 ++-- .../platforms/cocoa/qcocoaeventdispatcher.mm | 21 +++++++++++-------- .../platforms/cocoa/qcocoanativeinterface.mm | 6 +++--- src/plugins/platforms/cocoa/qcocoansmenu.h | 2 +- .../platforms/cocoa/qcocoasessionmanager.cpp | 2 +- .../platforms/cocoa/qcocoasystemtrayicon.h | 4 ++-- src/plugins/platforms/cocoa/qmacclipboard.mm | 16 +++++++------- src/plugins/platforms/cocoa/qnsview.h | 2 +- src/plugins/platforms/cocoa/qnsview_menus.mm | 10 ++++----- .../platforms/cocoa/qpaintengine_mac_p.h | 10 ++++----- src/plugins/platforms/cocoa/qt_mac_p.h | 15 +++++++------ 12 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index d86191ffa96..ad40c6b0cb9 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -41,7 +41,8 @@ #include "qcocoahelpers.h" #include "qcocoawindow.h" #include "qcocoascreen.h" -#include "private/qaccessiblecache_p.h" + +#include #include #include diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.h b/src/plugins/platforms/cocoa/qcocoaapplication.h index 15530d82818..4314a01ca1e 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.h +++ b/src/plugins/platforms/cocoa/qcocoaapplication.h @@ -83,8 +83,8 @@ // We mean it. // -#include "qglobal.h" -#include "private/qcore_mac_p.h" +#include +#include #import diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 94b9e62eab2..338a5516d91 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -73,18 +73,21 @@ #include "qcocoaeventdispatcher.h" #include "qcocoawindow.h" - #include "qcocoahelpers.h" -#include "qguiapplication.h" -#include "qevent.h" -#include "qmutex.h" -#include "qsocketnotifier.h" + +#include +#include +#include + +#include +#include +#include +#include + #include #include -#include "private/qthread_p.h" -#include "private/qguiapplication_p.h" -#include -#include + +#include #include diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 450329f5696..90e124b7902 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -50,13 +50,13 @@ #include #include #include -#include "qsurfaceformat.h" +#include #ifndef QT_NO_OPENGL #include -#include "qopenglcontext.h" +#include #include "qcocoaglcontext.h" #endif -#include "qguiapplication.h" +#include #include #if !defined(QT_NO_WIDGETS) && defined(QT_PRINTSUPPORT_LIB) diff --git a/src/plugins/platforms/cocoa/qcocoansmenu.h b/src/plugins/platforms/cocoa/qcocoansmenu.h index 0c77e2f1aad..bd0334e0613 100644 --- a/src/plugins/platforms/cocoa/qcocoansmenu.h +++ b/src/plugins/platforms/cocoa/qcocoansmenu.h @@ -53,7 +53,7 @@ #import -#include +#include "qcocoahelpers.h" QT_FORWARD_DECLARE_CLASS(QCocoaMenu); QT_FORWARD_DECLARE_CLASS(QCocoaMenuItem); diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp index 74e318b5be1..725fc5acc0e 100644 --- a/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp +++ b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include "qcocoasessionmanager.h" #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h index 7999438ca52..141995d1b14 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.h @@ -46,8 +46,8 @@ #if QT_CONFIG(systemtrayicon) -#include "QtCore/qstring.h" -#include "QtGui/qpa/qplatformsystemtrayicon.h" +#include +#include #include "qcocoamenu.h" diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index 654647b35ac..99b378be68d 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -38,14 +38,14 @@ ****************************************************************************/ #include "qmacclipboard.h" -#include "qclipboard.h" -#include "qguiapplication.h" -#include "qbitmap.h" -#include "qdatetime.h" -#include "qdebug.h" -#include "qguiapplication.h" -#include "qevent.h" -#include "qurl.h" +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include "qcocoahelpers.h" diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 74d0735b4c4..0a18afe3a64 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -43,7 +43,7 @@ #include #include -#include "private/qcore_mac_p.h" +#include QT_BEGIN_NAMESPACE class QCocoaWindow; diff --git a/src/plugins/platforms/cocoa/qnsview_menus.mm b/src/plugins/platforms/cocoa/qnsview_menus.mm index b6cd8322823..7ae274ab04d 100644 --- a/src/plugins/platforms/cocoa/qnsview_menus.mm +++ b/src/plugins/platforms/cocoa/qnsview_menus.mm @@ -39,11 +39,11 @@ // This file is included from qnsview.mm, and only used to organize the code -#include -#include -#include -#include -#include +#include "qcocoaapplicationdelegate.h" +#include "qcocoansmenu.h" +#include "qcocoamenuitem.h" +#include "qcocoamenu.h" +#include "qcocoamenubar.h" static bool selectorIsCutCopyPaste(SEL selector) { diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac_p.h b/src/plugins/platforms/cocoa/qpaintengine_mac_p.h index 14163867454..acf72c7456b 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac_p.h +++ b/src/plugins/platforms/cocoa/qpaintengine_mac_p.h @@ -51,11 +51,11 @@ // We mean it. // -#include "QtGui/qpaintengine.h" -#include "private/qpaintengine_p.h" -#include "private/qpolygonclipper_p.h" -#include "private/qfont_p.h" -#include "QtCore/qhash.h" +#include +#include +#include +#include +#include #include "qt_mac_p.h" diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h index fdcf3bcdd38..8a0513139a3 100644 --- a/src/plugins/platforms/cocoa/qt_mac_p.h +++ b/src/plugins/platforms/cocoa/qt_mac_p.h @@ -60,15 +60,14 @@ #include -#include "QtCore/qglobal.h" -#include "QtCore/qvariant.h" -#include "QtCore/qmimedata.h" -#include "QtCore/qpointer.h" -#include "QtCore/qloggingcategory.h" -#include "private/qcore_mac_p.h" +#include +#include +#include +#include +#include +#include - -#include "QtGui/qpainter.h" +#include QT_BEGIN_NAMESPACE class QWidget; From c61b81c3856d4019880d4350f5138d968ce4bd96 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 15 Apr 2020 11:13:23 +0200 Subject: [PATCH 19/42] Refine deprecation warning for QMetaProperty::isEditable Following up on header review. Change-Id: I88553fdaa56364fe93e7eac5d2b062402c760be4 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetaobject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index e4018740b8c..351fd5de101 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -263,7 +263,7 @@ public: bool isScriptable(const QObject *obj = nullptr) const; bool isStored(const QObject *obj = nullptr) const; #if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED bool isEditable(const QObject *obj = nullptr) const; + QT_DEPRECATED_VERSION_5_15 bool isEditable(const QObject *obj = nullptr) const; #endif bool isUser(const QObject *obj = nullptr) const; bool isConstant() const; From e38e1d02cca8056c9efcf2ab186a76396a60f21f Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 15 Apr 2020 11:14:22 +0200 Subject: [PATCH 20/42] Add QButtonGroup::idClicked/Pressed/Released/Toggled signals Following the deprecation of the signal overloads, the remaining signals did not provide equivalent functionality for connecting a slot expecting an integer. The mapping from QAbstractButton* to the ID is comparatively cumbersome to do in the connected slot. Add uniquely named signals that emit the ID of the button directly. [ChangeLog][QtWidgets][QButtonGroup] Added signals idClicked/Pressed/Released/Toggled that replace the deprecated signal overloads. Change-Id: I77215e4f815c4fb7dd6326e1f431230e6601e8f8 Reviewed-by: Lars Knoll --- src/widgets/widgets/qabstractbutton.cpp | 20 ++++++++-- src/widgets/widgets/qbuttongroup.cpp | 39 +++++++++++++++++++ src/widgets/widgets/qbuttongroup.h | 12 ++++-- .../widgets/qbuttongroup/tst_qbuttongroup.cpp | 8 ++-- 4 files changed, 67 insertions(+), 12 deletions(-) diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index badeec37ee6..a128b239506 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -415,13 +415,16 @@ void QAbstractButtonPrivate::emitClicked() emit q->clicked(checked); #if QT_CONFIG(buttongroup) if (guard && group) { + const int id = group->id(q); + emit group->idClicked(id); #if QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED - emit group->buttonClicked(group->id(q)); if (guard && group) + emit group->buttonClicked(id); QT_WARNING_POP #endif + if (guard && group) emit group->buttonClicked(q); } #endif @@ -434,13 +437,16 @@ void QAbstractButtonPrivate::emitPressed() emit q->pressed(); #if QT_CONFIG(buttongroup) if (guard && group) { + const int id = group->id(q); + emit group->idPressed(id); #if QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED - emit group->buttonPressed(group->id(q)); if (guard && group) + emit group->buttonPressed(id); QT_WARNING_POP #endif + if (guard && group) emit group->buttonPressed(q); } #endif @@ -453,13 +459,16 @@ void QAbstractButtonPrivate::emitReleased() emit q->released(); #if QT_CONFIG(buttongroup) if (guard && group) { + const int id = group->id(q); + emit group->idReleased(id); #if QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED - emit group->buttonReleased(group->id(q)); if (guard && group) + emit group->buttonReleased(id); QT_WARNING_POP #endif + if (guard && group) emit group->buttonReleased(q); } #endif @@ -472,13 +481,16 @@ void QAbstractButtonPrivate::emitToggled(bool checked) emit q->toggled(checked); #if QT_CONFIG(buttongroup) if (guard && group) { + const int id = group->id(q); + emit group->idToggled(id, checked); #if QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED - emit group->buttonToggled(group->id(q), checked); if (guard && group) + emit group->buttonToggled(id, checked); QT_WARNING_POP #endif + if (guard && group) emit group->buttonToggled(q, checked); } #endif diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index 9162029cdbc..5b407fc0f03 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -172,6 +172,16 @@ void QButtonGroup::setExclusive(bool exclusive) \sa checkedButton(), QAbstractButton::clicked() */ +/*! + \fn void QButtonGroup::idClicked(int id) + \since 5.15 + + This signal is emitted when a button with the given \a id is + clicked. + + \sa checkedButton(), QAbstractButton::clicked() +*/ + /*! \fn void QButtonGroup::buttonPressed(QAbstractButton *button) \since 4.2 @@ -192,6 +202,16 @@ void QButtonGroup::setExclusive(bool exclusive) \sa QAbstractButton::pressed() */ +/*! + \fn void QButtonGroup::idPressed(int id) + \since 5.15 + + This signal is emitted when a button with the given \a id is + pressed down. + + \sa QAbstractButton::pressed() +*/ + /*! \fn void QButtonGroup::buttonReleased(QAbstractButton *button) \since 4.2 @@ -212,6 +232,16 @@ void QButtonGroup::setExclusive(bool exclusive) \sa QAbstractButton::released() */ +/*! + \fn void QButtonGroup::idReleased(int id) + \since 5.15 + + This signal is emitted when a button with the given \a id is + released. + + \sa QAbstractButton::released() +*/ + /*! \fn void QButtonGroup::buttonToggled(QAbstractButton *button, bool checked) \since 5.2 @@ -233,6 +263,15 @@ void QButtonGroup::setExclusive(bool exclusive) \sa QAbstractButton::toggled() */ +/*! + \fn void QButtonGroup::idToggled(int id, bool checked) + \since 5.15 + + This signal is emitted when a button with the given \a id is toggled. + \a checked is true if the button is checked, or false if the button is unchecked. + + \sa QAbstractButton::toggled() +*/ /*! Adds the given \a button to the button group. If \a id is -1, diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h index 2989dcb4ba1..b2e507f31c4 100644 --- a/src/widgets/widgets/qbuttongroup.h +++ b/src/widgets/widgets/qbuttongroup.h @@ -81,14 +81,18 @@ Q_SIGNALS: void buttonPressed(QAbstractButton *); void buttonReleased(QAbstractButton *); void buttonToggled(QAbstractButton *, bool); + void idClicked(int); + void idPressed(int); + void idReleased(int); + void idToggled(int, bool); #if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonClicked(QAbstractButton *) instead") + QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::idClicked(int) instead") void buttonClicked(int); - QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonPressed(QAbstractButton *) instead") + QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::idPressed(int) instead") void buttonPressed(int); - QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonReleased(QAbstractButton *) instead") + QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::idReleased(int) instead") void buttonReleased(int); - QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonToggled(QAbstractButton *, bool) instead") + QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::idToggled(int, bool) instead") void buttonToggled(int, bool); #endif diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp index 3b8bcf98c3c..7454acbec70 100644 --- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp @@ -365,11 +365,11 @@ void tst_QButtonGroup::testSignals() qRegisterMetaType("QAbstractButton *"); QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton*))); - QSignalSpy clickedIdSpy(&buttons, SIGNAL(buttonClicked(int))); + QSignalSpy clickedIdSpy(&buttons, SIGNAL(idClicked(int))); QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton*))); - QSignalSpy pressedIdSpy(&buttons, SIGNAL(buttonPressed(int))); + QSignalSpy pressedIdSpy(&buttons, SIGNAL(idPressed(int))); QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton*))); - QSignalSpy releasedIdSpy(&buttons, SIGNAL(buttonReleased(int))); + QSignalSpy releasedIdSpy(&buttons, SIGNAL(idReleased(int))); pb1.animateClick(); QTestEventLoop::instance().enterLoop(1); @@ -409,7 +409,7 @@ void tst_QButtonGroup::testSignals() QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool))); - QSignalSpy toggledIdSpy(&buttons, SIGNAL(buttonToggled(int, bool))); + QSignalSpy toggledIdSpy(&buttons, SIGNAL(idToggled(int, bool))); pb1.setCheckable(true); pb2.setCheckable(true); From c38e4db6b1f681ae81a2c213dbd9be18a1a9f6ad Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 15 Apr 2020 11:43:08 +0200 Subject: [PATCH 21/42] doc: Recommend the QSplashScreen constructor taking a QScreen* Amends 49362d064fffe350600f5324fb510b381578d04a Change-Id: If217af44cf6ebe8ebed37bbd927ac311b23d8c0e Reviewed-by: Lars Knoll --- src/widgets/widgets/qsplashscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index 70f05033ea6..328df6a8f2a 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -160,7 +160,7 @@ QSplashScreen::QSplashScreen(QScreen *screen, const QPixmap &pixmap, Qt::WindowF #if QT_DEPRECATED_SINCE(5, 15) /*! \overload - \obsolete + \obsolete Use the constructor taking a \c {QScreen *} instead This function allows you to specify a parent for your splashscreen. The typical use for this constructor is if you have a multiple screens and From c7e8ee4e622ad90c6860994a0bb8eaa9c8c80566 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 9 Apr 2020 11:26:43 +0200 Subject: [PATCH 22/42] Fix image scaling on WASM platform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently it has trouble with multi-threading from the main thread. Change-Id: Ib544d69270c2780d4a42bde6fd7f491e32f29cd2 Reviewed-by: Morten Johan Sørvig --- src/gui/painting/qimagescale.cpp | 246 ++++---------------------- src/gui/painting/qimagescale_neon.cpp | 86 +++------ src/gui/painting/qimagescale_sse4.cpp | 86 +++------ 3 files changed, 92 insertions(+), 326 deletions(-) diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp index ecb0230e715..2395c891cec 100644 --- a/src/gui/painting/qimagescale.cpp +++ b/src/gui/painting/qimagescale.cpp @@ -43,7 +43,7 @@ #include "qcolor.h" #include "qrgba64_p.h" -#if QT_CONFIG(thread) +#if QT_CONFIG(thread) && !defined(Q_OS_WASM) #include "qsemaphore.h" #include "qthreadpool.h" #endif @@ -301,6 +301,30 @@ void qt_qimageScaleAARGBA_down_xy_neon(QImageScaleInfo *isi, unsigned int *dest, int dw, int dh, int dow, int sow); #endif +template +static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, const T &scaleSection) +{ +#if QT_CONFIG(thread) && !defined(Q_OS_WASM) + int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); + segments = std::min(segments, dh); + if (segments > 1) { + QSemaphore semaphore; + int y = 0; + for (int i = 0; i < segments; ++i) { + int yn = (dh - y) / (segments - i); + QThreadPool::globalInstance()->start([&, y, yn]() { + scaleSection(y, y + yn); + semaphore.release(1); + }); + y += yn; + } + semaphore.acquire(segments); + return; + } +#endif + scaleSection(0, dh); +} + static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest, int dw, int dh, int dow, int sow) { @@ -339,25 +363,7 @@ static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest, } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } /* scale by area sampling - with alpha */ @@ -468,25 +474,7 @@ static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest, @@ -528,25 +516,7 @@ static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *dest, @@ -598,25 +568,7 @@ static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *des } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } #if QT_CONFIG(raster_64bit) @@ -665,25 +617,7 @@ static void qt_qimageScaleRgba64_up_xy(QImageScaleInfo *isi, QRgba64 *dest, } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } void qt_qimageScaleRgba64(QImageScaleInfo *isi, QRgba64 *dest, @@ -757,25 +691,7 @@ static void qt_qimageScaleRgba64_up_x_down_y(QImageScaleInfo *isi, QRgba64 *dest } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } static void qt_qimageScaleRgba64_down_x_up_y(QImageScaleInfo *isi, QRgba64 *dest, @@ -816,25 +732,7 @@ static void qt_qimageScaleRgba64_down_x_up_y(QImageScaleInfo *isi, QRgba64 *dest } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } static void qt_qimageScaleRgba64_down_xy(QImageScaleInfo *isi, QRgba64 *dest, @@ -884,25 +782,7 @@ static void qt_qimageScaleRgba64_down_xy(QImageScaleInfo *isi, QRgba64 *dest, } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } #endif @@ -1019,25 +899,7 @@ static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int * } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } static void qt_qimageScaleAARGB_down_x_up_y(QImageScaleInfo *isi, unsigned int *dest, @@ -1076,25 +938,7 @@ static void qt_qimageScaleAARGB_down_x_up_y(QImageScaleInfo *isi, unsigned int * } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest, @@ -1144,25 +988,7 @@ static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } QImage qSmoothScaleImage(const QImage &src, int dw, int dh) diff --git a/src/gui/painting/qimagescale_neon.cpp b/src/gui/painting/qimagescale_neon.cpp index 416155e1399..65fe3fac3cd 100644 --- a/src/gui/painting/qimagescale_neon.cpp +++ b/src/gui/painting/qimagescale_neon.cpp @@ -41,7 +41,7 @@ #include "qimage.h" #include -#if QT_CONFIG(thread) +#if QT_CONFIG(thread) && !defined(Q_OS_WASM) #include "qsemaphore.h" #include "qthreadpool.h" #endif @@ -52,6 +52,30 @@ QT_BEGIN_NAMESPACE using namespace QImageScale; +template +static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, const T &scaleSection) +{ +#if QT_CONFIG(thread) && !defined(Q_OS_WASM) + int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); + segments = std::min(segments, dh); + if (segments > 1) { + QSemaphore semaphore; + int y = 0; + for (int i = 0; i < segments; ++i) { + int yn = (dh - y) / (segments - i); + QThreadPool::globalInstance()->start([&, y, yn]() { + scaleSection(y, y + yn); + semaphore.release(1); + }); + y += yn; + } + semaphore.acquire(segments); + return; + } +#endif + scaleSection(0, dh); +} + inline static uint32x4_t qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step) { uint32x2_t vpix32 = vmov_n_u32(*pix); @@ -110,25 +134,7 @@ void qt_qimageScaleAARGBA_up_x_down_y_neon(QImageScaleInfo *isi, unsigned int *d } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } template @@ -170,25 +176,7 @@ void qt_qimageScaleAARGBA_down_x_up_y_neon(QImageScaleInfo *isi, unsigned int *d } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } template @@ -239,25 +227,7 @@ void qt_qimageScaleAARGBA_down_xy_neon(QImageScaleInfo *isi, unsigned int *dest, } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } template void qt_qimageScaleAARGBA_up_x_down_y_neon(QImageScaleInfo *isi, unsigned int *dest, diff --git a/src/gui/painting/qimagescale_sse4.cpp b/src/gui/painting/qimagescale_sse4.cpp index 902ae61ed2c..1760e72f65e 100644 --- a/src/gui/painting/qimagescale_sse4.cpp +++ b/src/gui/painting/qimagescale_sse4.cpp @@ -42,7 +42,7 @@ #include #include -#if QT_CONFIG(thread) +#if QT_CONFIG(thread) && !defined(Q_OS_WASM) #include "qsemaphore.h" #include "qthreadpool.h" #endif @@ -53,6 +53,30 @@ QT_BEGIN_NAMESPACE using namespace QImageScale; +template +static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, const T &scaleSection) +{ +#if QT_CONFIG(thread) && !defined(Q_OS_WASM) + int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); + segments = std::min(segments, dh); + if (segments > 1) { + QSemaphore semaphore; + int y = 0; + for (int i = 0; i < segments; ++i) { + int yn = (dh - y) / (segments - i); + QThreadPool::globalInstance()->start([&, y, yn]() { + scaleSection(y, y + yn); + semaphore.release(1); + }); + y += yn; + } + semaphore.acquire(segments); + return; + } +#endif + scaleSection(0, dh); +} + inline static __m128i Q_DECL_VECTORCALL qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step, const __m128i vxyap, const __m128i vCxy) { @@ -115,25 +139,7 @@ void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *d } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } template @@ -181,25 +187,7 @@ void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *d } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } template @@ -249,25 +237,7 @@ void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest, } } }; -#if QT_CONFIG(thread) - int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16); - segments = std::min(segments, dh); - if (segments > 1) { - QSemaphore semaphore; - int y = 0; - for (int i = 0; i < segments; ++i) { - int yn = (dh - y) / (segments - i); - QThreadPool::globalInstance()->start([&, y, yn]() { - scaleSection(y, y + yn); - semaphore.release(1); - }); - y += yn; - } - semaphore.acquire(segments); - return; - } -#endif - scaleSection(0, dh); + multithread_pixels_function(isi, dh, scaleSection); } template void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *dest, From 1bee5937bc51af45776c4ad9083f4a67afbaf109 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Mon, 13 Apr 2020 15:50:32 +0200 Subject: [PATCH 23/42] Windows: Make QStandardPaths::writableLocation low-integrity aware Return %USERPROFILE%\AppData\LocalLow instead of %USERPROFILE%\AppData\Local when running in a low-integrity process. [ChangeLog][QtCore][QStandardPaths] When used in a low-integrity process on Windows, QStandardPaths::writableLocation returns respective low-integrity paths. Fixes: QTBUG-83453 Change-Id: Ie5e4625a34d08e4ef54be4ba45b2dae9e60feb63 Reviewed-by: Volker Hilsheimer --- src/corelib/io/qstandardpaths_win.cpp | 57 ++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index c2c3b2702bf..5055f4020ca 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #ifndef QT_NO_STANDARDPATHS @@ -92,9 +93,36 @@ static inline void appendTestMode(QString &path) path += QLatin1String("/qttest"); } +static bool isProcessLowIntegrity() { +#ifdef Q_CC_MINGW + // GetCurrentProcessToken was introduced in MinGW w64 in v7 + // Disable function until Qt CI is updated + return false; +#else + HANDLE process_token = GetCurrentProcessToken(); // non-leaking pseudo-handle + + QVarLengthArray token_info_buf(256); + auto* token_info = reinterpret_cast(token_info_buf.data()); + DWORD token_info_length = token_info_buf.size(); + if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_info, token_info_length, &token_info_length)) { + // grow bufer and retry GetTokenInformation + token_info_buf.resize(token_info_length); + token_info = reinterpret_cast(token_info_buf.data()); + if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_info, token_info_length, &token_info_length)) + return false; // assume "normal" process + } + + // The GetSidSubAuthorityCount return-code is undefined on failure, so + // there's no point in checking before dereferencing + DWORD integrity_level = *GetSidSubAuthority(token_info->Label.Sid, *GetSidSubAuthorityCount(token_info->Label.Sid) - 1); + return (integrity_level < SECURITY_MANDATORY_MEDIUM_RID); +#endif +} + // Map QStandardPaths::StandardLocation to KNOWNFOLDERID of SHGetKnownFolderPath() static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type) { + // folders for medium & high integrity processes static const GUID folderIds[] = { FOLDERID_Desktop, // DesktopLocation FOLDERID_Documents, // DocumentsLocation @@ -114,9 +142,34 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type) FOLDERID_RoamingAppData,// AppDataLocation ("Roaming" path) FOLDERID_LocalAppData, // AppConfigLocation ("Local" path) }; - Q_STATIC_ASSERT(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::AppConfigLocation + 1)); - return size_t(type) < sizeof(folderIds) / sizeof(folderIds[0]) ? folderIds[type] : GUID(); + + // folders for low integrity processes + static const GUID folderIds_li[] = { + FOLDERID_Desktop, // DesktopLocation + FOLDERID_Documents, // DocumentsLocation + FOLDERID_Fonts, // FontsLocation + FOLDERID_Programs, // ApplicationsLocation + FOLDERID_Music, // MusicLocation + FOLDERID_Videos, // MoviesLocation + FOLDERID_Pictures, // PicturesLocation + GUID(), GUID(), // TempLocation/HomeLocation + FOLDERID_LocalAppDataLow,// AppLocalDataLocation ("Local" path), AppLocalDataLocation = DataLocation + GUID(), // CacheLocation + FOLDERID_LocalAppDataLow,// GenericDataLocation ("Local" path) + GUID(), // RuntimeLocation + FOLDERID_LocalAppDataLow,// ConfigLocation ("Local" path) + GUID(), GUID(), // DownloadLocation/GenericCacheLocation + FOLDERID_LocalAppDataLow,// GenericConfigLocation ("Local" path) + FOLDERID_RoamingAppData, // AppDataLocation ("Roaming" path) + FOLDERID_LocalAppDataLow,// AppConfigLocation ("Local" path) + }; + Q_STATIC_ASSERT(sizeof(folderIds_li) == sizeof(folderIds)); + + static bool low_integrity_process = isProcessLowIntegrity(); + if (size_t(type) < sizeof(folderIds) / sizeof(folderIds[0])) + return low_integrity_process ? folderIds_li[type] : folderIds[type]; + return GUID(); } // Convenience for SHGetKnownFolderPath(). From 8138c812cbd65233a61d6e2e2f783d060c02de60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 1 Apr 2020 16:12:18 +0200 Subject: [PATCH 24/42] macOS: Remove a bunch of dead (forward) declarations Change-Id: I402668a17b48c164658f775bacd832615a6d2587 Reviewed-by: Simon Hausmann --- .../cocoa/qcocoaaccessibilityelement.h | 2 +- .../cocoa/qcocoaapplicationdelegate.mm | 1 - .../platforms/cocoa/qcocoabackingstore.mm | 1 + .../platforms/cocoa/qcocoafiledialoghelper.mm | 1 - src/plugins/platforms/cocoa/qcocoahelpers.h | 5 +- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 1 - .../platforms/cocoa/qcocoaprintdevice.h | 2 - .../platforms/cocoa/qcocoaprintdevice.mm | 4 + .../platforms/cocoa/qcocoaprintersupport.h | 2 - .../platforms/cocoa/qcocoaprintersupport.mm | 4 + .../platforms/cocoa/qcocoasystemtrayicon.mm | 1 - src/plugins/platforms/cocoa/qcocoawindow.h | 1 - src/plugins/platforms/cocoa/qmacdefines_mac.h | 129 ------------------ src/plugins/platforms/cocoa/qnswindow.h | 2 +- .../platforms/cocoa/qpaintengine_mac.mm | 3 + .../platforms/cocoa/qpaintengine_mac_p.h | 4 +- .../platforms/cocoa/qprintengine_mac.mm | 4 + .../platforms/cocoa/qt_attribution.json | 2 +- src/plugins/platforms/cocoa/qt_mac_p.h | 126 ----------------- .../tst_qfontdialog_mac_helpers.mm | 1 - 20 files changed, 25 insertions(+), 271 deletions(-) delete mode 100644 src/plugins/platforms/cocoa/qmacdefines_mac.h delete mode 100644 src/plugins/platforms/cocoa/qt_mac_p.h diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h index 141ce6bf1a8..f74afb84404 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h @@ -41,7 +41,7 @@ #include -#include "qt_mac_p.h" +#include #ifndef QT_NO_ACCESSIBILITY diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 3fb9e83d35d..e8d789275c6 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -87,7 +87,6 @@ #include #include #include -#include "qt_mac_p.h" #include #include diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 2b4c71f2795..3b9df8da3a3 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -43,6 +43,7 @@ #include "qcocoahelpers.h" #include +#include #include diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 8b76e456167..15e83db48fe 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -48,7 +48,6 @@ #include #include -#include "qt_mac_p.h" #include "qcocoahelpers.h" #include "qcocoaeventdispatcher.h" #include diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index 95351f688bc..71e72dca4f8 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -50,9 +50,12 @@ // // We mean it. // -#include "qt_mac_p.h" + +#include + #include #include +#include #include #include diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index c4e2dd0e922..3b37e7c9c15 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -46,7 +46,6 @@ #include "qcocoamenu.h" #include "qcocoamenubar.h" #include "qcocoahelpers.h" -#include "qt_mac_p.h" #include "qcocoaapplication.h" // for custom application category #include "qcocoamenuloader.h" #include diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.h b/src/plugins/platforms/cocoa/qcocoaprintdevice.h index d267343b0e8..59a521e0b50 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.h +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.h @@ -55,8 +55,6 @@ #ifndef QT_NO_PRINTER -#include "qt_mac_p.h" - #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm index 6f7f29bb5e1..ab304d9c04b 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm @@ -37,6 +37,8 @@ ** ****************************************************************************/ +#include + #include "qcocoaprintdevice.h" #if QT_CONFIG(mimetype) @@ -44,6 +46,8 @@ #endif #include +#include + QT_BEGIN_NAMESPACE #ifndef QT_NO_PRINTER diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.h b/src/plugins/platforms/cocoa/qcocoaprintersupport.h index 40a638207a6..b1a9541c035 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintersupport.h +++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.h @@ -43,8 +43,6 @@ #include #ifndef QT_NO_PRINTER -#include "qt_mac_p.h" - QT_BEGIN_NAMESPACE class QCocoaPrinterSupport : public QPlatformPrinterSupport diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm index d7eaa469fb9..4c5c7aef889 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm @@ -41,6 +41,10 @@ #ifndef QT_NO_PRINTER +#include + +#include + #include "qcocoaprintdevice.h" #include "qprintengine_mac_p.h" diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 0e48318141b..704498acb1e 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -84,7 +84,6 @@ #include "qcocoamenu.h" -#include "qt_mac_p.h" #include "qcocoahelpers.h" #include "qcocoaintegration.h" #include "qcocoascreen.h" diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index b15c0ac31cb..291a27b15e0 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -51,7 +51,6 @@ #endif #include "qnsview.h" #include "qnswindow.h" -#include "qt_mac_p.h" #if QT_CONFIG(vulkan) #include diff --git a/src/plugins/platforms/cocoa/qmacdefines_mac.h b/src/plugins/platforms/cocoa/qmacdefines_mac.h deleted file mode 100644 index 9e229b8dcb3..00000000000 --- a/src/plugins/platforms/cocoa/qmacdefines_mac.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $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 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 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. -** -** 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$ -** -****************************************************************************/ - -/**************************************************************************** -** -** Copyright (c) 2007-2008, Apple, Inc. -** -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** -** * Neither the name of Apple, Inc. nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -****************************************************************************/ - -/* - * qmacdefines_mac_p.h - * All the defines you'll ever need for Qt/Mac :-) - */ - -/* This is just many defines. Therefore it doesn't need things like: -QT_BEGIN_NAMESPACE - - -QT_END_NAMESPACE - -Yes, it is an informative comment ;-) -*/ - -#include - -#ifdef __LP64__ -typedef signed int OSStatus; -#else -typedef signed long OSStatus; -#endif - -typedef struct OpaqueEventHandlerCallRef * EventHandlerCallRef; -typedef struct OpaqueEventRef * EventRef; -typedef struct OpaqueMenuRef * MenuRef; -typedef struct OpaquePasteboardRef* PasteboardRef; -typedef struct OpaqueRgnHandle * RgnHandle; -typedef const struct __HIShape *HIShapeRef; -typedef struct __HIShape *HIMutableShapeRef; -typedef struct CGRect CGRect; -typedef struct CGImage *CGImageRef; -typedef struct CGContext *CGContextRef; -typedef struct GDevice * GDPtr; -typedef GDPtr * GDHandle; -typedef struct OpaqueIconRef * IconRef; - -#ifdef __OBJC__ -typedef NSWindow* OSWindowRef; -typedef NSView *OSViewRef; -typedef NSMenu *OSMenuRef; -typedef NSEvent *OSEventRef; -#else -typedef void *OSWindowRef; -typedef void *OSViewRef; -typedef void *OSMenuRef; -typedef void *OSEventRef; -#endif - -typedef PasteboardRef OSPasteboardRef; -typedef struct AEDesc AEDescList; -typedef AEDescList AERecord; -typedef AERecord AppleEvent; - -#ifdef check -#undef check -#endif diff --git a/src/plugins/platforms/cocoa/qnswindow.h b/src/plugins/platforms/cocoa/qnswindow.h index 5fc48d826f7..3263df38624 100644 --- a/src/plugins/platforms/cocoa/qnswindow.h +++ b/src/plugins/platforms/cocoa/qnswindow.h @@ -42,7 +42,7 @@ #include #include -#include "qt_mac_p.h" +#include #include diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm index df71f766449..5ced962cb1b 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm @@ -37,6 +37,9 @@ ** ****************************************************************************/ +#include +#include + #include "qpaintengine_mac_p.h" #if defined(QT_PRINTSUPPORT_LIB) #include "qprintengine_mac_p.h" diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac_p.h b/src/plugins/platforms/cocoa/qpaintengine_mac_p.h index acf72c7456b..a52e9cbe1c8 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac_p.h +++ b/src/plugins/platforms/cocoa/qpaintengine_mac_p.h @@ -57,9 +57,9 @@ #include #include -#include "qt_mac_p.h" - typedef struct CGColorSpace *CGColorSpaceRef; +typedef struct CGContext *CGContextRef; + QT_BEGIN_NAMESPACE class QCoreGraphicsPaintEnginePrivate; diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index 5833d097fd1..9391f921ec1 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -37,6 +37,9 @@ ** ****************************************************************************/ +#include +#include + #include "qprintengine_mac_p.h" #include "qcocoaprintersupport.h" #include @@ -44,6 +47,7 @@ #include #include +#include #ifndef QT_NO_PRINTER diff --git a/src/plugins/platforms/cocoa/qt_attribution.json b/src/plugins/platforms/cocoa/qt_attribution.json index 37c0937f296..1da0d7e3708 100644 --- a/src/plugins/platforms/cocoa/qt_attribution.json +++ b/src/plugins/platforms/cocoa/qt_attribution.json @@ -3,7 +3,7 @@ "Name": "Cocoa Platform Plugin", "QDocModule": "qtgui", "QtUsage": "Code used in the Qt Platform Abstraction (QPA) for macOS.", - "Files": "qcocoaapplication.h qcocoaapplication.mm qcocoaapplicationdelegate.h qcocoaapplicationdelegate.mm qcocoaeventdispatcher.h qcocoaeventdispatcher.mm qcocoaintrospection.h qcocoaintrospection.mm qcocoasystemtrayicon.mm qmacdefines_mac.h", + "Files": "qcocoaapplication.h qcocoaapplication.mm qcocoaapplicationdelegate.h qcocoaapplicationdelegate.mm qcocoaeventdispatcher.h qcocoaeventdispatcher.mm qcocoaintrospection.h qcocoaintrospection.mm qcocoasystemtrayicon.mm", "Description": "Allows Qt to integrate into Apple's Cocoa API.", "LicenseId": "BSD-3-Clause", diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h deleted file mode 100644 index 8a0513139a3..00000000000 --- a/src/plugins/platforms/cocoa/qt_mac_p.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $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 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 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. -** -** 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$ -** -****************************************************************************/ - -#ifndef QT_MAC_P_H -#define QT_MAC_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifdef __OBJC__ -#include -#include -#endif - -#include "qmacdefines_mac.h" - -#include - -#include -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE -class QWidget; -class QDragMoveEvent; - -// Simple class to manage short-lived regions -class QMacSmartQuickDrawRegion -{ - RgnHandle qdRgn; - Q_DISABLE_COPY(QMacSmartQuickDrawRegion) -public: - explicit QMacSmartQuickDrawRegion(RgnHandle rgn) : qdRgn(rgn) {} - ~QMacSmartQuickDrawRegion() { - extern void qt_mac_dispose_rgn(RgnHandle); // qregion_mac.cpp - qt_mac_dispose_rgn(qdRgn); - } - operator RgnHandle() { - return qdRgn; - } -}; - -class QMacInternalPasteboardMime; -class QMimeData; - - -extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp - -extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.mm -extern OSViewRef qt_mac_nativeview_for(const QWidget *); //qwidget_mac.mm -extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt); //qwidget_mac.mm - -#ifdef check -# undef check -#endif - -struct QMacDndAnswerRecord { - QRect rect; - Qt::KeyboardModifiers modifiers; - Qt::MouseButtons buttons; - Qt::DropAction lastAction; - unsigned int lastOperation; - void clear() { - rect = QRect(); - modifiers = Qt::NoModifier; - buttons = Qt::NoButton; - lastAction = Qt::IgnoreAction; - lastOperation = 0; - } -}; -extern QMacDndAnswerRecord qt_mac_dnd_answer_rec; -void qt_mac_copy_answer_rect(const QDragMoveEvent &event); -bool qt_mac_mouse_inside_answer_rect(QPoint mouse); - -QT_END_NAMESPACE - -#endif // QT_MAC_P_H diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm index 44b6423f1cf..00cc6a879fc 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm @@ -26,7 +26,6 @@ ** ****************************************************************************/ -#include #include void click_cocoa_button() From 8ddffc6ba4f38bb8dbeb0cf61b6b10ee73505bbb Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 13 Apr 2020 20:31:34 +0200 Subject: [PATCH 25/42] OpenSSL: handle SSL_shutdown's errors properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not call SSL_shutdown on a session that is in handshake state (SSL_in_init(s) returns 1). Also, do not call SSL_shutdown if a session encountered a fatal error (SSL_ERROR_SYSCALL or SSL_ERROR_SSL was found before). If SSL_shutdown was unsuccessful (returned code != 1), we have to clear the error(s) it queued. Unfortunately, SSL_in_init was a macro in OpenSSL 1.0.x. We have to resolve SSL_state to implement SSL_in_init. Fixes: QTBUG-83450 Change-Id: I6326119f4e79605429263045ac20605c30dccca3 Reviewed-by: Mårten Nordheim (cherry picked from commit 8907635da59c2ae0e8db01f27b24a841b830e655) --- src/network/ssl/qsslsocket.cpp | 2 +- src/network/ssl/qsslsocket_openssl.cpp | 23 ++++++++++++++----- .../ssl/qsslsocket_openssl11_symbols_p.h | 7 ++++++ .../ssl/qsslsocket_openssl_symbols.cpp | 8 +++++++ .../ssl/qsslsocket_opensslpre11_symbols_p.h | 2 ++ src/network/ssl/qsslsocket_p.h | 1 + 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 4e9e9472631..5c9e589ec39 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -2166,7 +2166,7 @@ void QSslSocketPrivate::init() pendingClose = false; flushTriggered = false; ocspResponses.clear(); - + systemOrSslErrorDetected = false; // we don't want to clear the ignoreErrorsList, so // that it is possible setting it before connecting // ignoreErrorsList.clear(); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 51510f1c60b..855865209bc 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -648,10 +648,16 @@ bool QSslSocketBackendPrivate::initSslContext() void QSslSocketBackendPrivate::destroySslContext() { if (ssl) { - // We do not send a shutdown alert here. Just mark the session as - // resumable for qhttpnetworkconnection's "optimization", otherwise - // OpenSSL won't start a session resumption. - q_SSL_shutdown(ssl); + if (!q_SSL_in_init(ssl) && !systemOrSslErrorDetected) { + // We do not send a shutdown alert here. Just mark the session as + // resumable for qhttpnetworkconnection's "optimization", otherwise + // OpenSSL won't start a session resumption. + if (q_SSL_shutdown(ssl) != 1) { + // Some error may be queued, clear it. + const auto errors = getErrorsFromOpenSsl(); + Q_UNUSED(errors); + } + } q_SSL_free(ssl); ssl = nullptr; } @@ -1084,6 +1090,7 @@ void QSslSocketBackendPrivate::transmit() case SSL_ERROR_SSL: // error in the SSL library // we do not know exactly what the error is, nor whether we can recover from it, // so just return to prevent an endless loop in the outer "while" statement + systemOrSslErrorDetected = true; { const ScopedBool bg(inSetAndEmitError, true); setErrorAndEmit(QAbstractSocket::SslInternalError, @@ -1681,8 +1688,12 @@ bool QSslSocketBackendPrivate::checkOcspStatus() void QSslSocketBackendPrivate::disconnectFromHost() { if (ssl) { - if (!shutdown) { - q_SSL_shutdown(ssl); + if (!shutdown && !q_SSL_in_init(ssl) && !systemOrSslErrorDetected) { + if (q_SSL_shutdown(ssl) != 1) { + // Some error may be queued, clear it. + const auto errors = getErrorsFromOpenSsl(); + Q_UNUSED(errors); + } shutdown = true; transmit(); } diff --git a/src/network/ssl/qsslsocket_openssl11_symbols_p.h b/src/network/ssl/qsslsocket_openssl11_symbols_p.h index 0fe0899d4fd..b7193ad1807 100644 --- a/src/network/ssl/qsslsocket_openssl11_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl11_symbols_p.h @@ -192,4 +192,11 @@ typedef int (*q_SSL_psk_use_session_cb_func_t)(SSL *, const EVP_MD *, const unsi } void q_SSL_set_psk_use_session_callback(SSL *s, q_SSL_psk_use_session_cb_func_t); +#if OPENSSL_VERSION_NUMBER < 0x10101000L +// What a mess! +int q_SSL_in_init(SSL *s); +#else +int q_SSL_in_init(const SSL *s); +#endif // 1.1.1 or 1.1.0 + #endif diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 85029a6ff3f..d1bd84cf25f 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -160,6 +160,11 @@ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG) DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return) DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return) DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return) +#if OPENSSL_VERSION_NUMBER < 0x10101000L +DEFINEFUNC(int, SSL_in_init, SSL *a, a, return 0, return) +#else +DEFINEFUNC(int, SSL_in_init, const SSL *a, a, return 0, return) +#endif #ifdef TLS1_3_VERSION DEFINEFUNC2(int, SSL_CTX_set_ciphersuites, SSL_CTX *ctx, ctx, const char *str, str, return 0, return) DEFINEFUNC2(void, SSL_set_psk_use_session_callback, SSL *ssl, ssl, q_SSL_psk_use_session_cb_func_t callback, callback, return, DUMMYARG) @@ -242,6 +247,7 @@ DEFINEFUNC2(void, BIO_set_shutdown, BIO *a, a, int shut, shut, return, DUMMYARG) // Functions below are either deprecated or removed in OpenSSL >= 1.1: DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return nullptr, return) +DEFINEFUNC(int, SSL_state, const SSL *a, a, return 0, return) #ifdef SSLEAY_MACROS DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, return nullptr, return) @@ -971,6 +977,7 @@ bool q_resolveOpenSslSymbols() #if QT_CONFIG(opensslv11) RESOLVEFUNC(OPENSSL_init_ssl) + RESOLVEFUNC(SSL_in_init) RESOLVEFUNC(OPENSSL_init_crypto) RESOLVEFUNC(ASN1_STRING_get0_data) RESOLVEFUNC(EVP_CIPHER_CTX_reset) @@ -1066,6 +1073,7 @@ bool q_resolveOpenSslSymbols() #else // !opensslv11 RESOLVEFUNC(ASN1_STRING_data) + RESOLVEFUNC(SSL_state) #ifdef SSLEAY_MACROS RESOLVEFUNC(ASN1_dup) diff --git a/src/network/ssl/qsslsocket_opensslpre11_symbols_p.h b/src/network/ssl/qsslsocket_opensslpre11_symbols_p.h index f5626d5d164..92841017793 100644 --- a/src/network/ssl/qsslsocket_opensslpre11_symbols_p.h +++ b/src/network/ssl/qsslsocket_opensslpre11_symbols_p.h @@ -121,6 +121,8 @@ SSL_CTX *q_SSL_CTX_new(const SSL_METHOD *a); int q_SSL_library_init(); void q_SSL_load_error_strings(); +int q_SSL_state(const SSL *a); +#define q_SSL_in_init(a) (q_SSL_state(a) & SSL_ST_INIT) #if OPENSSL_VERSION_NUMBER >= 0x10001000L int q_SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index daa9be23f4a..350b1f1fc18 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -208,6 +208,7 @@ protected: bool verifyErrorsHaveBeenIgnored(); bool paused; bool flushTriggered; + bool systemOrSslErrorDetected = false; QVector ocspResponses; }; From b34158d7a1e89e5e7b32d3425c3df52aacedbb31 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 12 Feb 2020 11:01:51 +0100 Subject: [PATCH 26/42] Fix display-name calls in QAndroidTimeZonePrivate::init() Following up on commits 4fa8dfee5dd31433d22fdb449c1783e256931c8f and c20c7efea96046bebcb8ff7823d3a7e227f92e73, where I apparently got the call to Java's getDisplayName() method wrong. Use the same code as our own displayName() method used for this, pulled out as a function to be shared by the two callers. This requires a locale and it's not immediately obvious which to use, so try the three most plausible candidates: C locale because IANA IDs are typically in it; default because that's most likely what language a user-supplied locale name might be in; and system because the name may have come from the system, not the user. In the process fixed some loops that didn't visit all the values they thought they did. Fixes: QTBUG-81975 Change-Id: I7867ca6f46951315a41c389107439acb439eaf08 Reviewed-by: BogDan Vatra --- src/corelib/time/qtimezoneprivate_android.cpp | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/corelib/time/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp index fc3653752ac..ba87cf79fee 100644 --- a/src/corelib/time/qtimezoneprivate_android.cpp +++ b/src/corelib/time/qtimezoneprivate_android.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2014 Drew Parsons ** Contact: https://www.qt.io/licensing/ ** @@ -78,6 +78,26 @@ QAndroidTimeZonePrivate::~QAndroidTimeZonePrivate() { } +static QJNIObjectPrivate getDisplayName(QJNIObjectPrivate zone, jint style, jboolean dst, + const QLocale &locale) +{ + QJNIObjectPrivate jlanguage + = QJNIObjectPrivate::fromString(QLocale::languageToString(locale.language())); + QJNIObjectPrivate jcountry + = QJNIObjectPrivate::fromString(QLocale::countryToString(locale.country())); + QJNIObjectPrivate + jvariant = QJNIObjectPrivate::fromString(QLocale::scriptToString(locale.script())); + QJNIObjectPrivate jlocale("java.util.Locale", + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", + static_cast(jlanguage.object()), + static_cast(jcountry.object()), + static_cast(jvariant.object())); + + return zone.callObjectMethod("getDisplayName", + "(ZILjava/util/Locale;)Ljava/lang/String;", + dst, style, jlocale.object()); +} + void QAndroidTimeZonePrivate::init(const QByteArray &ianaId) { const QString iana = QString::fromUtf8(ianaId); @@ -99,10 +119,13 @@ void QAndroidTimeZonePrivate::init(const QByteArray &ianaId) // the zone object we got and ignore the zone if not. // Try checking ianaId against getID(), getDisplayName(): m_id = match(androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;")); - for (int style = 1; m_id.isEmpty() && style-- > 0;) { - for (int dst = 1; m_id.isEmpty() && dst-- > 0;) { - m_id = match(androidTimeZone.callObjectMethod( - "getDisplayName", "(ZI)Ljava/lang/String;", bool(dst), style)); + for (int style = 1; m_id.isEmpty() && style >= 0; --style) { + for (int dst = 1; m_id.isEmpty() && dst >= 0; --dst) { + for (int pick = 2; m_id.isEmpty() && pick >= 0; --pick) { + QLocale locale = (pick == 0 ? QLocale::system() + : pick == 1 ? QLocale() : QLocale::c()); + m_id = match(getDisplayName(androidTimeZone, style, jboolean(dst), locale)); + } } } } @@ -124,14 +147,7 @@ QString QAndroidTimeZonePrivate::displayName(QTimeZone::TimeType timeType, QTime // treat all NameTypes as java TimeZone style LONG (value 1), except of course QTimeZone::ShortName which is style SHORT (value 0); jint style = (nameType == QTimeZone::ShortName ? 0 : 1); - QJNIObjectPrivate jlanguage = QJNIObjectPrivate::fromString(QLocale::languageToString(locale.language())); - QJNIObjectPrivate jcountry = QJNIObjectPrivate::fromString(QLocale::countryToString(locale.country())); - QJNIObjectPrivate jvariant = QJNIObjectPrivate::fromString(QLocale::scriptToString(locale.script())); - QJNIObjectPrivate jlocale("java.util.Locale", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", static_cast(jlanguage.object()), static_cast(jcountry.object()), static_cast(jvariant.object())); - - QJNIObjectPrivate jname = androidTimeZone.callObjectMethod("getDisplayName", "(ZILjava/util/Locale;)Ljava/lang/String;", daylightTime, style, jlocale.object()); - - name = jname.toString(); + name = getDisplayName(androidTimeZone, style, daylightTime, locale).toString(); } return name; From 487dd80bce9c6006f349ccb09222e1c308200f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 24 Mar 2020 09:40:10 +0100 Subject: [PATCH 27/42] Introduce QSocketNotifier::activate(QSocketDescriptor, QSN::Type) The pre-existing overload passes an int, but this can mean the descriptor gets truncated in compilations where the descriptor is 64-bit. The old overload with int is visible when querying the metaobject system so string-based connects still work as before, and connecting to it will produce a deprecation warning in the output. At the same time the PMF-based connect will, on recompile, pick the QSocketDescriptor overload. As an added improvement it also comes with the notification type, removing the need for separate slots where the code would be mostly shared anyway. The QSocketDescriptor type can be implicitly converted to and from qintptr to ensure existing code still compiles. It can also be constructed from Qt::HANDLE on Windows. In this same patch I also update the existing string-based connects in this module, which then includes updating the parameters for some slots as well. [ChangeLog][QtCore][QSocketNotifier] Added QSocketNotifier::activated(QSocketDescriptor, QSocketNotifier::Type). This replaces the activated(int) signal which in 64-bit environments could truncate the socket descriptor. If you use "activated" with the string-based connect() then you need to update the parameter type of the signal and slot if it had one. If you use it with the pointer to member function based connect() then all you need to do is update your slot's parameter type if it has one. If you need to compile your source code with multiple versions of Qt then connect() to this function using pointer to member function and update the slot's parameter type if needed. Task-number: QTBUG-70441 Change-Id: Ic43d6bc4c5bcb4040867b2ffad8d36fb01eed8af Reviewed-by: Edward Welbourne --- src/corelib/io/qfilesystemwatcher_inotify.cpp | 2 +- src/corelib/io/qfilesystemwatcher_kqueue.cpp | 2 +- src/corelib/io/qprocess_unix.cpp | 8 +- src/corelib/kernel/qsocketnotifier.cpp | 85 +++++++++++++++++-- src/corelib/kernel/qsocketnotifier.h | 61 +++++++++++++ src/dbus/qdbusconnection_p.h | 6 +- src/dbus/qdbusintegrator.cpp | 4 +- src/network/socket/qlocalserver_unix.cpp | 4 +- src/network/socket/qlocalsocket_unix.cpp | 2 +- .../devicediscovery/qdevicediscovery_udev.cpp | 2 +- .../platforms/openwfd/qopenwfddevice.cpp | 2 +- .../platforms/qnx/qqnxbuttoneventnotifier.cpp | 2 +- .../qnx/qqnxnavigatoreventnotifier.cpp | 2 +- .../platforms/qnx/qqnxvirtualkeyboardpps.cpp | 2 +- .../platforms/xcb/qxcbsessionmanager.cpp | 6 +- src/plugins/sqldrivers/psql/qsql_psql.cpp | 10 +-- src/plugins/sqldrivers/psql/qsql_psql_p.h | 2 +- .../qsocketnotifier/tst_qsocketnotifier.cpp | 70 +++++++++++++-- 18 files changed, 234 insertions(+), 38 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp index 888af998a53..94d9d06bcb9 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp @@ -253,7 +253,7 @@ QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd, QObject notifier(fd, QSocketNotifier::Read, this) { fcntl(inotifyFd, F_SETFD, FD_CLOEXEC); - connect(¬ifier, SIGNAL(activated(int)), SLOT(readFromInotify())); + connect(¬ifier, SIGNAL(activated(QSocketDescriptor)), SLOT(readFromInotify())); } QInotifyFileSystemWatcherEngine::~QInotifyFileSystemWatcherEngine() diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp index c2028e3641f..06383a103a2 100644 --- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp +++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp @@ -77,7 +77,7 @@ QKqueueFileSystemWatcherEngine::QKqueueFileSystemWatcherEngine(int kqfd, QObject kqfd(kqfd), notifier(kqfd, QSocketNotifier::Read, this) { - connect(¬ifier, SIGNAL(activated(int)), SLOT(readFromKqueue())); + connect(¬ifier, SIGNAL(activated(QSocketDescriptor)), SLOT(readFromKqueue())); fcntl(kqfd, F_SETFD, FD_CLOEXEC); } diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 930007ff04f..e8efe6481ff 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -251,7 +251,7 @@ bool QProcessPrivate::openChannel(Channel &channel) channel.notifier = new QSocketNotifier(channel.pipe[1], QSocketNotifier::Write, q); channel.notifier->setEnabled(false); - QObject::connect(channel.notifier, SIGNAL(activated(int)), + QObject::connect(channel.notifier, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_canWrite())); } else { channel.notifier = new QSocketNotifier(channel.pipe[0], @@ -261,7 +261,7 @@ bool QProcessPrivate::openChannel(Channel &channel) receiver = SLOT(_q_canReadStandardOutput()); else receiver = SLOT(_q_canReadStandardError()); - QObject::connect(channel.notifier, SIGNAL(activated(int)), + QObject::connect(channel.notifier, SIGNAL(activated(QSocketDescriptor)), q, receiver); } } @@ -380,7 +380,7 @@ void QProcessPrivate::startProcess() if (threadData.loadRelaxed()->hasEventDispatcher()) { startupSocketNotifier = new QSocketNotifier(childStartedPipe[0], QSocketNotifier::Read, q); - QObject::connect(startupSocketNotifier, SIGNAL(activated(int)), + QObject::connect(startupSocketNotifier, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_startupNotification())); } @@ -531,7 +531,7 @@ void QProcessPrivate::startProcess() if (threadData.loadRelaxed()->eventDispatcher.loadAcquire()) { deathNotifier = new QSocketNotifier(forkfd, QSocketNotifier::Read, q); - QObject::connect(deathNotifier, SIGNAL(activated(int)), + QObject::connect(deathNotifier, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_processDied())); } } diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp index 78269ee605c..6c032d13ae4 100644 --- a/src/corelib/kernel/qsocketnotifier.cpp +++ b/src/corelib/kernel/qsocketnotifier.cpp @@ -37,23 +37,32 @@ ** ****************************************************************************/ +#define BUILDING_QSOCKETNOTIFIER #include "qsocketnotifier.h" +#undef BUILDING_QSOCKETNOTIFIER #include "qplatformdefs.h" #include "qabstracteventdispatcher.h" #include "qcoreapplication.h" +#include "qmetatype.h" + #include "qobject_p.h" #include +#include + QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(lcSocketNotifierDeprecation) +Q_LOGGING_CATEGORY(lcSocketNotifierDeprecation, "qt.core.socketnotifier_deprecation"); + class QSocketNotifierPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QSocketNotifier) public: - qintptr sockfd; + QSocketDescriptor sockfd; QSocketNotifier::Type sntype; bool snenabled; }; @@ -143,13 +152,17 @@ QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent) : QObject(*new QSocketNotifierPrivate, parent) { Q_D(QSocketNotifier); + + qRegisterMetaType(); + qRegisterMetaType(); + d->sockfd = socket; d->sntype = type; d->snenabled = true; auto thisThreadData = d->threadData.loadRelaxed(); - if (socket < 0) + if (!d->sockfd.isValid()) qWarning("QSocketNotifier: Invalid socket specified"); else if (!thisThreadData->hasEventDispatcher()) qWarning("QSocketNotifier: Can only be used with threads started with QThread"); @@ -169,6 +182,11 @@ QSocketNotifier::~QSocketNotifier() /*! \fn void QSocketNotifier::activated(int socket) + \obsolete To avoid unintended truncation of the descriptor, use + the QSocketDescriptor overload of this function. If you need + compatibility with versions older than 5.15 you need to change + the slot to accept qintptr if it currently accepts an int, and + then connect using Functor-Based Connection. This signal is emitted whenever the socket notifier is enabled and a socket event corresponding to its \l {Type}{type} occurs. @@ -178,6 +196,18 @@ QSocketNotifier::~QSocketNotifier() \sa type(), socket() */ +/*! + \fn void QSocketNotifier::activated(QSocketDescriptor socket, QSocketNotifier::Type type) + \since 5.15 + + This signal is emitted whenever the socket notifier is enabled and + a socket event corresponding to its \a type occurs. + + The socket identifier is passed in the \a socket parameter. + + \sa type(), socket() +*/ + /*! Returns the socket identifier specified to the constructor. @@ -187,7 +217,7 @@ QSocketNotifier::~QSocketNotifier() qintptr QSocketNotifier::socket() const { Q_D(const QSocketNotifier); - return d->sockfd; + return qintptr(d->sockfd); } /*! @@ -230,7 +260,7 @@ bool QSocketNotifier::isEnabled() const void QSocketNotifier::setEnabled(bool enable) { Q_D(QSocketNotifier); - if (d->sockfd < 0) + if (!d->sockfd.isValid()) return; if (d->snenabled == enable) // no change return; @@ -268,12 +298,57 @@ bool QSocketNotifier::event(QEvent *e) } QObject::event(e); // will activate filters if ((e->type() == QEvent::SockAct) || (e->type() == QEvent::SockClose)) { - emit activated(d->sockfd, QPrivateSignal()); + QPointer alive(this); + emit activated(d->sockfd, d->sntype, QPrivateSignal()); + // ### Qt7: Remove emission if the activated(int) signal is removed + if (alive) + emit activated(int(qintptr(d->sockfd)), QPrivateSignal()); + return true; } return false; } +/*! + \class QSocketDescriptor + \inmodule QtCore + \brief A class which holds a native socket descriptor. + + \ingroup network + \ingroup io + + \since 5.15 + + QSocketDescriptor makes it easier to handle native socket + descriptors in cross-platform code. + + On Windows it holds a \c {Qt::HANDLE} and on Unix it holds an \c int. + The class will implicitly convert between the class and the + native descriptor type. +*/ + +/*! + \fn QSocketDescriptor::QSocketDescriptor(DescriptorType descriptor) + + Construct a QSocketDescriptor from a native socket \a descriptor. +*/ + +/*! + \fn QSocketDescriptor::QSocketDescriptor(qintptr descriptor) + + Construct a QSocketDescriptor from a native socket \a descriptor. + + \note This constructor is only available on Windows. +*/ + +/*! + \fn Qt::HANDLE QSocketDescriptor::winHandle() const noexcept + + Returns the internal handle. + + \note This function is only available on Windows. +*/ + QT_END_NAMESPACE #include "moc_qsocketnotifier.cpp" diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h index 38e5f27247c..808931e04bc 100644 --- a/src/corelib/kernel/qsocketnotifier.h +++ b/src/corelib/kernel/qsocketnotifier.h @@ -44,6 +44,7 @@ QT_BEGIN_NAMESPACE +class QSocketDescriptor; class QSocketNotifierPrivate; class Q_CORE_EXPORT QSocketNotifier : public QObject { @@ -65,7 +66,23 @@ public Q_SLOTS: void setEnabled(bool); Q_SIGNALS: +#if defined(Q_MOC_RUN) + // Add default arguments during Q_MOC_RUN which makes moc generate "signals" which takes less + // parameters, but we won't actually allow emitting without all 3. This lets users use the + // string-based connect without specifying QSocketNotifier::Type as one of the parameters. + void activated(QSocketDescriptor socket, QSocketNotifier::Type activationEvent = Read, + QPrivateSignal = {}); +#else + void activated(QSocketDescriptor socket, QSocketNotifier::Type activationEvent, QPrivateSignal); +#endif + + // ### Qt7: consider removing it. + // The old signal is compiled internally, but hidden outside of this class. + // This means the PMF-based connect(..) will automatically, on recompile, pick up the new + // version while the old-style connect(..) can query the metaobject system for this version. +#if defined(Q_MOC_RUN) || defined(BUILDING_QSOCKETNOTIFIER) || defined(Q_QDOC) void activated(int socket, QPrivateSignal); +#endif protected: bool event(QEvent *) override; @@ -74,6 +91,50 @@ private: Q_DISABLE_COPY(QSocketNotifier) }; +class QSocketDescriptor +{ +public: +#if defined(Q_OS_WIN) + using DescriptorType = Qt::HANDLE; +#define Q_DECL_CONSTEXPR_NOT_WIN +#else + using DescriptorType = int; +#define Q_DECL_CONSTEXPR_NOT_WIN Q_DECL_CONSTEXPR +#endif + + /* implicit */ Q_DECL_CONSTEXPR_NOT_WIN + QSocketDescriptor(DescriptorType descriptor = DescriptorType(-1)) noexcept : sockfd(descriptor) + { + } + +#if defined(Q_OS_WIN) || defined(Q_QDOC) + /* implicit */ QSocketDescriptor(qintptr desc) noexcept : sockfd(DescriptorType(desc)) {} + operator qintptr() const noexcept { return qintptr(sockfd); } + Q_DECL_CONSTEXPR Qt::HANDLE winHandle() const noexcept { return sockfd; } +#endif + Q_DECL_CONSTEXPR operator DescriptorType() const noexcept { return sockfd; } + + Q_DECL_CONSTEXPR_NOT_WIN bool isValid() const noexcept { return *this != QSocketDescriptor(); } + + friend Q_DECL_CONSTEXPR_NOT_WIN bool operator==(QSocketDescriptor lhs, + QSocketDescriptor rhs) noexcept + { + return lhs.sockfd == rhs.sockfd; + } + friend Q_DECL_CONSTEXPR_NOT_WIN bool operator!=(QSocketDescriptor lhs, + QSocketDescriptor rhs) noexcept + { + return lhs.sockfd != rhs.sockfd; + } + +#undef Q_DECL_CONSTEXPR_NOT_WIN + +private: + DescriptorType sockfd; +}; + QT_END_NAMESPACE +Q_DECLARE_METATYPE(QSocketNotifier::Type) +Q_DECLARE_METATYPE(QSocketDescriptor) #endif // QSOCKETNOTIFIER_H diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index da67a6c5d4e..9bedbcc3a55 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -173,7 +173,7 @@ public: public: // typedefs - typedef QMultiHash WatcherHash; + typedef QMultiHash WatcherHash; typedef QHash TimeoutHash; typedef QVector PendingMessageList; @@ -283,8 +283,8 @@ public slots: // public slots void setDispatchEnabled(bool enable); void doDispatch(); - void socketRead(int); - void socketWrite(int); + void socketRead(qintptr); + void socketWrite(qintptr); void objectDestroyed(QObject *o); void relaySignal(QObject *obj, const QMetaObject *, int signalId, const QVariantList &args); bool addSignalHook(const QString &key, const SignalHook &hook); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 669b330f1db..b0a93425155 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1205,7 +1205,7 @@ void QDBusConnectionPrivate::doDispatch() } } -void QDBusConnectionPrivate::socketRead(int fd) +void QDBusConnectionPrivate::socketRead(qintptr fd) { WatcherHash::ConstIterator it = watchers.constFind(fd); while (it != watchers.constEnd() && it.key() == fd) { @@ -1219,7 +1219,7 @@ void QDBusConnectionPrivate::socketRead(int fd) doDispatch(); } -void QDBusConnectionPrivate::socketWrite(int fd) +void QDBusConnectionPrivate::socketWrite(qintptr fd) { WatcherHash::ConstIterator it = watchers.constFind(fd); while (it != watchers.constEnd() && it.key() == fd) { diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp index 88367d680d1..c4085b440e0 100644 --- a/src/network/socket/qlocalserver_unix.cpp +++ b/src/network/socket/qlocalserver_unix.cpp @@ -185,7 +185,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName) Q_ASSERT(!socketNotifier); socketNotifier = new QSocketNotifier(listenSocket, QSocketNotifier::Read, q); - q->connect(socketNotifier, SIGNAL(activated(int)), + q->connect(socketNotifier, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_onNewConnection())); socketNotifier->setEnabled(maxPendingConnections > 0); return true; @@ -227,7 +227,7 @@ bool QLocalServerPrivate::listen(qintptr socketDescriptor) Q_ASSERT(!socketNotifier); socketNotifier = new QSocketNotifier(listenSocket, QSocketNotifier::Read, q); - q->connect(socketNotifier, SIGNAL(activated(int)), + q->connect(socketNotifier, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_onNewConnection())); socketNotifier->setEnabled(maxPendingConnections > 0); return true; diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index d9b39a7752f..52067a265ce 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -308,7 +308,7 @@ void QLocalSocketPrivate::_q_connectToSocket() // Try again later, all of the sockets listening are full if (!delayConnect) { delayConnect = new QSocketNotifier(connectingSocket, QSocketNotifier::Write, q); - q->connect(delayConnect, SIGNAL(activated(int)), q, SLOT(_q_connectToSocket())); + q->connect(delayConnect, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_connectToSocket())); } if (!connectTimer) { connectTimer = new QTimer(q); diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp index 9cf5c9096e6..118940c634e 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp @@ -92,7 +92,7 @@ QDeviceDiscoveryUDev::QDeviceDiscoveryUDev(QDeviceTypes types, struct udev *udev m_udevMonitorFileDescriptor = udev_monitor_get_fd(m_udevMonitor); m_udevSocketNotifier = new QSocketNotifier(m_udevMonitorFileDescriptor, QSocketNotifier::Read, this); - connect(m_udevSocketNotifier, SIGNAL(activated(int)), this, SLOT(handleUDevNotification())); + connect(m_udevSocketNotifier, SIGNAL(activated(QSocketDescriptor)), this, SLOT(handleUDevNotification())); } QDeviceDiscoveryUDev::~QDeviceDiscoveryUDev() diff --git a/src/plugins/platforms/openwfd/qopenwfddevice.cpp b/src/plugins/platforms/openwfd/qopenwfddevice.cpp index 7a9d22e74d0..99896151b29 100644 --- a/src/plugins/platforms/openwfd/qopenwfddevice.cpp +++ b/src/plugins/platforms/openwfd/qopenwfddevice.cpp @@ -83,7 +83,7 @@ QOpenWFDDevice::QOpenWFDDevice(QOpenWFDIntegration *integration, WFDint device_e int fd = wfdDeviceEventGetFD(mDevice,mEvent); mEventSocketNotifier = new QSocketNotifier(fd,QSocketNotifier::Read,this); - connect(mEventSocketNotifier,SIGNAL(activated(int)),SLOT(readEvents())); + connect(mEventSocketNotifier,SIGNAL(activated(QSocketDescriptor)),SLOT(readEvents())); mCommitedDevice = true; commit(WFD_COMMIT_ENTIRE_DEVICE, handle()); diff --git a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp index a6236f23761..f0c4c385efb 100644 --- a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp @@ -96,7 +96,7 @@ void QQnxButtonEventNotifier::start() } m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); - QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(updateButtonStates())); + QObject::connect(m_readNotifier, SIGNAL(activated(QSocketDescriptor)), this, SLOT(updateButtonStates())); qButtonDebug("successfully connected to Navigator. fd = %d", m_fd); } diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp index 1f630863b7a..f7e8e7966c4 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp @@ -96,7 +96,7 @@ void QQnxNavigatorEventNotifier::start() } m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); - connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(readData())); + connect(m_readNotifier, SIGNAL(activated(QSocketDescriptor)), this, SLOT(readData())); } void QQnxNavigatorEventNotifier::parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id) diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp index 025c03c058e..6f496571fa4 100644 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp @@ -143,7 +143,7 @@ bool QQnxVirtualKeyboardPps::connect() return false; m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read); - QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(ppsDataReady())); + QObject::connect(m_readNotifier, SIGNAL(activated(QSocketDescriptor)), this, SLOT(ppsDataReady())); return true; } diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp index 2eb32c069ec..e9697f505be 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp @@ -61,11 +61,11 @@ public: QSmSocketReceiver(int socket) { QSocketNotifier* sn = new QSocketNotifier(socket, QSocketNotifier::Read, this); - connect(sn, SIGNAL(activated(int)), this, SLOT(socketActivated(int))); + connect(sn, SIGNAL(activated(QSocketDescriptor)), this, SLOT(socketActivated())); } public Q_SLOTS: - void socketActivated(int); + void socketActivated(); }; @@ -327,7 +327,7 @@ static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData) } -void QSmSocketReceiver::socketActivated(int) +void QSmSocketReceiver::socketActivated() { IceProcessMessages(SmcGetIceConnection(smcConnection), nullptr, nullptr); } diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 38bf355856b..c5895f281d8 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -279,7 +279,7 @@ void QPSQLDriverPrivate::checkPendingNotifications() const Q_Q(const QPSQLDriver); if (seid.size() && !pendingNotifyCheck) { pendingNotifyCheck = true; - QMetaObject::invokeMethod(const_cast(q), "_q_handleNotification", Qt::QueuedConnection, Q_ARG(int,0)); + QMetaObject::invokeMethod(const_cast(q), "_q_handleNotification", Qt::QueuedConnection); } } @@ -1246,7 +1246,7 @@ void QPSQLDriver::close() d->seid.clear(); if (d->sn) { - disconnect(d->sn, SIGNAL(activated(int)), this, SLOT(_q_handleNotification(int))); + disconnect(d->sn, SIGNAL(activated(QSocketDescriptor)), this, SLOT(_q_handleNotification())); delete d->sn; d->sn = nullptr; } @@ -1603,7 +1603,7 @@ bool QPSQLDriver::subscribeToNotification(const QString &name) if (!d->sn) { d->sn = new QSocketNotifier(socket, QSocketNotifier::Read); - connect(d->sn, SIGNAL(activated(int)), this, SLOT(_q_handleNotification(int))); + connect(d->sn, SIGNAL(activated(QSocketDescriptor)), this, SLOT(_q_handleNotification())); } } else { qWarning("QPSQLDriver::subscribeToNotificationImplementation: PQsocket didn't return a valid socket to listen on"); @@ -1639,7 +1639,7 @@ bool QPSQLDriver::unsubscribeFromNotification(const QString &name) d->seid.removeAll(name); if (d->seid.isEmpty()) { - disconnect(d->sn, SIGNAL(activated(int)), this, SLOT(_q_handleNotification(int))); + disconnect(d->sn, SIGNAL(activated(QSocketDescriptor)), this, SLOT(_q_handleNotification())); delete d->sn; d->sn = nullptr; } @@ -1653,7 +1653,7 @@ QStringList QPSQLDriver::subscribedToNotifications() const return d->seid; } -void QPSQLDriver::_q_handleNotification(int) +void QPSQLDriver::_q_handleNotification() { Q_D(QPSQLDriver); d->pendingNotifyCheck = false; diff --git a/src/plugins/sqldrivers/psql/qsql_psql_p.h b/src/plugins/sqldrivers/psql/qsql_psql_p.h index 9ac1fb50d79..22c07616674 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql_p.h +++ b/src/plugins/sqldrivers/psql/qsql_psql_p.h @@ -130,7 +130,7 @@ protected: bool rollbackTransaction() override; private Q_SLOTS: - void _q_handleNotification(int); + void _q_handleNotification(); }; QT_END_NAMESPACE diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp index e3f45df27d4..8ba3505d8b8 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp @@ -53,6 +53,7 @@ # undef min #endif // Q_CC_MSVC + class tst_QSocketNotifier : public QObject { Q_OBJECT @@ -63,6 +64,9 @@ private slots: void posixSockets(); #endif void asyncMultipleDatagram(); + void activationReason_data(); + void activationReason(); + void legacyConnect(); protected slots: void async_readDatagramSlot(); @@ -97,10 +101,10 @@ public: { QSocketNotifier *notifier1 = new QSocketNotifier(readEnd1->socketDescriptor(), QSocketNotifier::Read, this); - connect(notifier1, SIGNAL(activated(int)), SLOT(handleActivated())); + connect(notifier1, SIGNAL(activated(QSocketDescriptor)), SLOT(handleActivated())); QSocketNotifier *notifier2 = new QSocketNotifier(readEnd2->socketDescriptor(), QSocketNotifier::Read, this); - connect(notifier2, SIGNAL(activated(int)), SLOT(handleActivated())); + connect(notifier2, SIGNAL(activated(QSocketDescriptor)), SLOT(handleActivated())); } public slots: @@ -284,12 +288,12 @@ void tst_QSocketNotifier::posixSockets() { QSocketNotifier rn(posixSocket, QSocketNotifier::Read); - connect(&rn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); + connect(&rn, SIGNAL(activated(QSocketDescriptor)), &QTestEventLoop::instance(), SLOT(exitLoop())); QSignalSpy readSpy(&rn, &QSocketNotifier::activated); QVERIFY(readSpy.isValid()); // No write notifier, some systems trigger write notification on socket creation, but not all QSocketNotifier en(posixSocket, QSocketNotifier::Exception); - connect(&en, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); + connect(&en, SIGNAL(activated(QSocketDescriptor)), &QTestEventLoop::instance(), SLOT(exitLoop())); QSignalSpy errorSpy(&en, &QSocketNotifier::activated); QVERIFY(errorSpy.isValid()); @@ -306,7 +310,7 @@ void tst_QSocketNotifier::posixSockets() QCOMPARE(buffer, "hello"); QSocketNotifier wn(posixSocket, QSocketNotifier::Write); - connect(&wn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); + connect(&wn, SIGNAL(activated(QSocketDescriptor)), &QTestEventLoop::instance(), SLOT(exitLoop())); QSignalSpy writeSpy(&wn, &QSocketNotifier::activated); QVERIFY(writeSpy.isValid()); qt_safe_write(posixSocket, "goodbye", 8); @@ -385,5 +389,61 @@ void tst_QSocketNotifier::asyncMultipleDatagram() #endif // !Q_OS_WINRT } +void tst_QSocketNotifier::activationReason_data() +{ + QTest::addColumn("type"); + QTest::addRow("read") << QSocketNotifier::Read; + QTest::addRow("write") << QSocketNotifier::Write; + QTest::addRow("exception") << QSocketNotifier::Exception; +} +void tst_QSocketNotifier::activationReason() +{ + QSocketDescriptor fd = 15; + + QFETCH(QSocketNotifier::Type, type); + + QSocketNotifier notifier(fd, type); + auto activation = new QEvent(QEvent::SockAct); + QCoreApplication::postEvent(¬ifier, activation); + + QSocketNotifier::Type notifierType; + connect(¬ifier, &QSocketNotifier::activated, this, + [¬ifierType, fd](QSocketDescriptor sockfd, QSocketNotifier::Type sntype) { + if (sockfd == fd) + notifierType = sntype; + else + qWarning() << "Got an unexpected socket file descriptor:" << qintptr(sockfd); + }); + + QCoreApplication::processEvents(); + QCOMPARE(notifierType, type); +} + +// This test ensures that we can connect QSocketNotifier::activated to a slot taking an integer +// or qintptr. +void tst_QSocketNotifier::legacyConnect() +{ + qintptr fd = 15; + QSocketNotifier notifier(fd, QSocketNotifier::Read); + auto activation = new QEvent(QEvent::SockAct); + QCoreApplication::postEvent(¬ifier, activation); + + bool receivedQIntPtr = false; + connect(¬ifier, &QSocketNotifier::activated, this, [&receivedQIntPtr, fd](qintptr q){ + if (q == fd) + receivedQIntPtr = true; + }); + bool receivedInt = false; + connect(¬ifier, &QSocketNotifier::activated, this, [&receivedInt, fd](int q){ + if (q == fd) + receivedInt = true; + }); + + QCoreApplication::processEvents(); + QVERIFY(receivedQIntPtr); + QVERIFY(receivedInt); +} + + QTEST_MAIN(tst_QSocketNotifier) #include From 0c651768475aa882d606efe51d10fedc44b87566 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 15 Apr 2020 13:58:55 +0200 Subject: [PATCH 28/42] Docs: show more relevant and correct way of using Q_FLAG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The snippet didn't quote the QLibrary header correctly, and didn't register the flags type, but only the enum type with the meta object system. Update example to use QItemSelectionModel instead as a more relevant class for readers, and restructure the text a bit. Change-Id: I572e2aaac4601087e7aa6d2ea7a8f8fd65d82539 Fixes: QTBUG-83474 Reviewed-by: Topi Reiniö --- .../code/src_corelib_kernel_qobject.cpp | 24 ++++++++++++------- src/corelib/kernel/qobject.cpp | 9 ++++--- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp index 43bcc22720d..fddda64b197 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp @@ -403,20 +403,28 @@ public: //! [39] -class QLibrary : public QObject +class QItemSelectionModel : public QObject { Q_OBJECT public: ... - - enum LoadHint { - ResolveAllSymbolsHint = 0x01, - ExportExternalSymbolsHint = 0x02, - LoadArchiveMemberHint = 0x04 + enum SelectionFlag { + NoUpdate = 0x0000, + Clear = 0x0001, + Select = 0x0002, + Deselect = 0x0004, + Toggle = 0x0008, + Current = 0x0010, + Rows = 0x0020, + Columns = 0x0040, + SelectCurrent = Select | Current, + ToggleCurrent = Toggle | Current, + ClearAndSelect = Clear | Select }; - Q_DECLARE_FLAGS(LoadHints, LoadHint) - Q_FLAG(LoadHint) + + Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag) + Q_FLAG(SelectionFlags) ... } //! [39] diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8be10ed6011..23e4e1163c5 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4493,16 +4493,15 @@ QDebug operator<<(QDebug dbg, const QObject *o) that values of a given enum can be used as flags and combined using the bitwise OR operator. For namespaces use \l Q_FLAG_NS() instead. - The macro must be placed after the enum declaration. + The macro must be placed after the enum declaration. The declaration of + the flags type is done using the \l Q_DECLARE_FLAGS() macro. - For example, in QLibrary, the \l{QLibrary::LoadHints}{LoadHints} flag is + For example, in QItemSelectionModel, the + \l{QItemSelectionModel::SelectionFlags}{SelectionFlags} flag is declared in the following way: \snippet code/src_corelib_kernel_qobject.cpp 39 - The declaration of the flags themselves is performed in the public section - of the QLibrary class itself, using the \l Q_DECLARE_FLAGS() macro. - \note The Q_FLAG macro takes care of registering individual flag values with the meta-object system, so it is unnecessary to use Q_ENUM() in addition to this macro. From 33b1662f16e21a7e0f0b1ba809f16326aaa5f0ef Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Wed, 15 Apr 2020 19:46:33 +0200 Subject: [PATCH 29/42] Fuzzing: Add fuzz target for QCborStreamReader::next Change-Id: I8e7d90d89b66395370809935b1cb5bf144bded49 Reviewed-by: Thiago Macieira --- .../qcborstreamreader/next/main.cpp | 36 +++++++++++++++++++ .../qcborstreamreader/next/next.pro | 10 ++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp create mode 100644 tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro diff --git a/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp new file mode 100644 index 00000000000..118f402a15f --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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$ +** +****************************************************************************/ + +#include + +extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { + QCborStreamReader reader(QByteArray::fromRawData(Data, Size)); + while (reader.isValid()) + reader.next(1024); + return 0; +} diff --git a/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro new file mode 100644 index 00000000000..6c988c24342 --- /dev/null +++ b/tests/libfuzzer/corelib/serialization/qcborstreamreader/next/next.pro @@ -0,0 +1,10 @@ +QT -= gui +CONFIG += console +CONFIG -= app_bundle +SOURCES += main.cpp +FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) +isEmpty(FUZZ_ENGINE) { + QMAKE_LFLAGS += -fsanitize=fuzzer +} else { + LIBS += $$FUZZ_ENGINE +} From 300bd7fff8b25bfbdb025315331e5733c3346d98 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 15 Apr 2020 07:04:47 +0200 Subject: [PATCH 30/42] rcc: Always seed the hash with 0 That was already done to pass the auto tests, but the randomization also bites for reproducible builds. Change-Id: Ibf4da513059deb5a806d2ac1a83c1994edf09d4a Reviewed-by: Thiago Macieira --- src/tools/rcc/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index ac87e48e393..d8e243daead 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -435,11 +435,10 @@ int main(int argc, char *argv[]) { // rcc uses a QHash to store files in the resource system. // we must force a certain hash order when testing or tst_rcc will fail, see QTBUG-25078 - if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_RCC_TEST"))) { - qSetGlobalQHashSeed(0); - if (qGlobalQHashSeed() != 0) - qFatal("Cannot force QHash seed for testing as requested"); - } + // similar requirements exist for reproducibly builds. + qSetGlobalQHashSeed(0); + if (qGlobalQHashSeed() != 0) + qWarning("Cannot force QHash seed"); return QT_PREPEND_NAMESPACE(runRcc)(argc, argv); } From 23a64797157f50551d999a14b3f7ee96a37d57a0 Mon Sep 17 00:00:00 2001 From: Kimmo Ollila Date: Wed, 15 Apr 2020 10:37:06 +0300 Subject: [PATCH 31/42] Add mkspec for INTEGRITY Qualcomm SA8155P ADP Change-Id: I3430868fb88f357c3d2d1d3cd8e00088aa26649c Reviewed-by: Joerg Bornemann --- .../integrity-armv8-SA8155P/qmake.conf | 43 ++++++++++++++++++ .../integrity-armv8-SA8155P/qplatformdefs.h | 45 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 mkspecs/devices/integrity-armv8-SA8155P/qmake.conf create mode 100644 mkspecs/devices/integrity-armv8-SA8155P/qplatformdefs.h diff --git a/mkspecs/devices/integrity-armv8-SA8155P/qmake.conf b/mkspecs/devices/integrity-armv8-SA8155P/qmake.conf new file mode 100644 index 00000000000..892619cb376 --- /dev/null +++ b/mkspecs/devices/integrity-armv8-SA8155P/qmake.conf @@ -0,0 +1,43 @@ +# +# qmake configuration for INTEGRITY Qualcomm SA8155P ADP +# + +load(device_config) + +include(../../common/ghs-integrity-armv8.conf) + +QT_QPA_DEFAULT_PLATFORM = eglfs +EGLFS_DEVICE_INTEGRATION = eglfs_openwfd + +qc_multimedia_inc_directory = $$(QC_MULTIMEDIA_INC_DIR) +isEmpty(qc_multimedia_inc_directory): \ + error("This makespec requires the environment variable QC_MULTIMEDIA_INC_DIR to be set.") + +QMAKE_INCDIR += $$(QC_MULTIMEDIA_INC_DIR) + +QMAKE_LIBS_EGL += -lESXEGL_Adreno -lESXGLESv2_Adreno -ladreno_utils -lGSLUser -lOSUser -lpanel -livfs -lposix -lpmem -ltzbsp -lpaged_alloc -lglnext-llvm -lopenwfd -lplanedef -llogger -lnet -lsocket -lrfs_client -lshm_client -lmmosalrfs -lmmosalfile -lOSAbstraction + +QMAKE_LIBS_OPENGL_ES2 += $${QMAKE_LIBS_EGL} + +QMAKE_CFLAGS += -DINTEGRITY +QMAKE_CXXFLAGS += -DINTEGRITY + +QMAKE_CFLAGS += -bigswitch +QMAKE_CXXFLAGS += -bigswitch +QMAKE_LFLAGS += -bigswitch + +dirs = $$(GL_INC_DIR) +isEmpty(dirs): \ + error("This makespec requires the environment variable GL_INC_DIR to be set.") + +QMAKE_INCDIR_EGL = $$split(dirs, $$QMAKE_DIRLIST_SEP) +QMAKE_INCDIR_OPENGL_ES2 = $$QMAKE_INCDIR_EGL + +dirs = $$(GL_LIB_DIR) +isEmpty(dirs): \ + error("This makespec requires the environment variable GL_LIB_DIR to be set.") + +QMAKE_LIBDIR_EGL = $$split(dirs, $$QMAKE_DIRLIST_SEP) +QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_EGL + +load(qt_config) diff --git a/mkspecs/devices/integrity-armv8-SA8155P/qplatformdefs.h b/mkspecs/devices/integrity-armv8-SA8155P/qplatformdefs.h new file mode 100644 index 00000000000..d9f25081526 --- /dev/null +++ b/mkspecs/devices/integrity-armv8-SA8155P/qplatformdefs.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $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 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 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. +** +** 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$ +** +****************************************************************************/ + +#ifndef QPLATFORMDEFS_H +#define QPLATFORMDEFS_H + +#include "../../common/integrity/qplatformdefs.h" + +#endif // QPLATFORMDEFS_H From 5c04b83715c4c846d44dff4e4df3a0231f12a607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 17 Apr 2020 10:17:05 +0200 Subject: [PATCH 32/42] QSocketNotifier::activated(QSocketDescriptor...) doc fixup We agreed to make the type internal but somehow it slipped my mind to actually label them as such. Task-number: QTBUG-70441 Change-Id: Id90521ecc09bfa1db29601b96ba70bcdcb64d458 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qsocketnotifier.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp index 6c032d13ae4..6e1d2103bd1 100644 --- a/src/corelib/kernel/qsocketnotifier.cpp +++ b/src/corelib/kernel/qsocketnotifier.cpp @@ -313,6 +313,7 @@ bool QSocketNotifier::event(QEvent *e) \class QSocketDescriptor \inmodule QtCore \brief A class which holds a native socket descriptor. + \internal \ingroup network \ingroup io @@ -329,12 +330,14 @@ bool QSocketNotifier::event(QEvent *e) /*! \fn QSocketDescriptor::QSocketDescriptor(DescriptorType descriptor) + \internal Construct a QSocketDescriptor from a native socket \a descriptor. */ /*! \fn QSocketDescriptor::QSocketDescriptor(qintptr descriptor) + \internal Construct a QSocketDescriptor from a native socket \a descriptor. @@ -343,6 +346,7 @@ bool QSocketNotifier::event(QEvent *e) /*! \fn Qt::HANDLE QSocketDescriptor::winHandle() const noexcept + \internal Returns the internal handle. From cc106ce56550ebfc7e1808e1b9015f5618d9f5e5 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Wed, 8 Apr 2020 15:39:33 +0300 Subject: [PATCH 33/42] Android: update Android specific variables docs Android variable are missing from the list of QMake variables... Task-number: QTBUG-80390 Change-Id: Ic10f96687334eea99c0302d7137685b1bf6e56c6 Reviewed-by: BogDan Vatra Reviewed-by: Leena Miettinen --- .../externalsites/external-resources.qdoc | 16 ++ qmake/doc/src/qmake-manual.qdoc | 188 ++++++++++++++++++ 2 files changed, 204 insertions(+) diff --git a/doc/global/externalsites/external-resources.qdoc b/doc/global/externalsites/external-resources.qdoc index cbb4345bcd5..187c73da624 100644 --- a/doc/global/externalsites/external-resources.qdoc +++ b/doc/global/externalsites/external-resources.qdoc @@ -24,6 +24,22 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +/*! + \externalpage https://source.android.com/setup/start/build-numbers + \title Android: Build Numbers +*/ +/*! + \externalpage https://developer.android.com/guide/topics/manifest/uses-feature-element + \title Android: +*/ +/*! + \externalpage https://developer.android.com/guide/topics/manifest/uses-permission-element + \title Android: +*/ +/*! + \externalpage https://developer.android.com/studio/publish/versioning#appversioning + \title Android: App Versioning +*/ /*! \externalpage http://www.freedesktop.org/ \title freedesktop.org diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index c90092059f9..574722d08ac 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -905,6 +905,187 @@ to specify a list of libraries that each project needs to link against, and \c QMAKE_LIBS_X11 would be used to extend this list. + \target ANDROID_ABI + \section1 ANDROID_ABI + + \note This variable applies only to Android targets. + + Specifies the Android target ABI. Valid values are: armeabi-v7a, arm64-v8a, + x86, x86_64. + + \target ANDROID_ABIS + \section1 ANDROID_ABIS + + \note This variable applies only to Android targets. + + Specifies a list of Android target ABIs. Valid values are: armeabi-v7a, + arm64-v8a, x86, x86_64. + + \badcode + qmake ANDROID_ABIS="armeabi-v7a arm64-v8a" + \endcode + + \target ANDROID_API_VERSION + \section1 ANDROID_API_VERSION + + \note This variable applies only to Android targets. + + Specifies the Android API level number. For more information, see + \l{Android: Build Numbers}{Android Build Numbers}. + + \target ANDROID_BUNDLED_JAR_DEPENDENCIES + \section1 ANDROID_BUNDLED_JAR_DEPENDENCIES + + \note This variable applies only to Android modules. + + This is useful when writing a Qt module. It specifies a list of pre-bundled + dependencies used by the module in a \c .jar format, for example: + + \badcode + ANDROID_BUNDLED_JAR_DEPENDENCIES += jar/QtAndroid.jar + \endcode + + \target ANDROID_DEPLOYMENT_DEPENDENCIES + \section1 ANDROID_DEPLOYMENT_DEPENDENCIES + + \note This variable applies only to Android targets. + + By default, \l androiddeployqt will detect the dependencies of your + application. However, since run-time usage of plugins cannot be detected, + there could be false positives, as your application might depend on any + plugin that is a potential dependency. If you want to minimize the size of + your \c APK, it's possible to override the automatic detection using the + this variable. This should contain a list of all Qt files which need to be + included, with paths relative to the Qt install root. + + \note Only the Qt files specified with this variable are included. Failing + to include all the correct files can result in crashes. It's also important + to make sure the files are listed in the correct loading order. This variable + provides a way to override the automatic detection entirely, so if a library + is listed before its dependencies, it will fail to load on some devices. + + \target ANDROID_DEPLOYMENT_SETTINGS_FILE + \section1 ANDROID_DEPLOYMENT_SETTINGS_FILE + + \note This variable applies only to Android targets. + + Specifies the path to the \c {android-deployment-settings.json} file needed + by \l androiddeployqt and \c androidtestrunner. This overrides the path to + the settings file generated by qmake, thus you have to make sure to provide + a valid settings file. + + \target ANDROID_EXTRA_LIBS + \section1 ANDROID_EXTRA_LIBS + + \note This variable applies only to Android targets. + + A list of external libraries that will be copied into your application's + \c libs folder and loaded on start-up. This can be used, for instance, + to enable OpenSSL in your application. For more information, see + \l{Adding OpenSSL Support for Android}. + + \target ANDROID_EXTRA_PLUGINS + \section1 ANDROID_EXTRA_PLUGINS + + \note This variable applies only to Android targets. + + Specifies different resources that your application has to bundle but that + cannot be delivered through the assets system, such as QML plugins. With this + variable, \l androiddeployqt will make sure everything is packaged and + deployed properly. + + \target ANDROID_FEATURES + \section1 ANDROID_FEATURES + + \note This variable applies only to Android modules. + + Specifies a module's features list: + + \badcode + ANDROID_FEATURES += android.hardware.location.gps + \endcode + + For more information, see \l{Android: }{Android Docs}. + + \target ANDROID_LIB_DEPENDENCIES + \section1 ANDROID_LIB_DEPENDENCIES + + \note This variable applies only to Android modules. + + This is useful when writing a Qt module. It specifies a list of pre-built + dependencies used by the module, for example: + + \badcode + ANDROID_LIB_DEPENDENCIES += \ + plugins/libplugins_platforms_qtforandroid.so + \endcode + + \target ANDROID_MIN_SDK_VERSION + \section1 ANDROID_MIN_SDK_VERSION + + \note This variable applies only to Android targets. + + Specifies the minimum Android API level for the project. By default, this + variable is set to API level 21. + + \target ANDROID_PACKAGE_SOURCE_DIR + \section1 ANDROID_PACKAGE_SOURCE_DIR + + \note This variable applies only to Android targets. + + Specifies the path for a custom Android package template. The Android package + template contains: + \list + \li AndroidManifest.xml file + \li build.gradle file and other Gradle scripts + \li res/values/libs.xml file + \endlist + + The path specified by this variable can contain custom Java classes under + \c src directory. By default, the \l androiddeployqt tool copies the + application template from the Qt for Android installation path into your + project's build directory, then it copies the contents of the path specified + by this variable on top of that, overwriting any existing files. For + instance, you can make a custom \c {AndroidManifest.xml} for your application, + then place this directly into the directory specified by this variable. + + \target ANDROID_PERMISSIONS + \section1 ANDROID_PERMISSIONS + + \note This variable applies only to Android modules. + + Specifies a module's permissions list: + + \badcode + ANDROID_PERMISSIONS += android.permission.ACCESS_FINE_LOCATION + \endcode + + For more information, see \l{Android: }{Android Docs}. + + \target ANDROID_TARGET_SDK_VERSION + \section1 ANDROID_TARGET_SDK_VERSION + + \note This variable applies only to Android targets. + + Specifies the target Android API level for the project. By default, this + variable is set to API level 28. + + \target ANDROID_VERSION_CODE + \section1 ANDROID_VERSION_CODE + + \note This variable applies only to Android targets. + + Specifies the application's version number. For more information, see + \l{Android: App Versioning}{Android App Versioning}. + + \target ANDROID_VERSION_NAME + \section1 ANDROID_VERSION_NAME + + \note This variable applies only to Android targets. + + Specifies the application's version in as a human readable string. For more + information, see \l{Android: App Versioning}{Android App Versioning}. + \target CONFIG \section1 CONFIG @@ -1376,6 +1557,13 @@ This variable is also used to specify which additional files will be deployed to embedded devices. + \target JAVA_HOME + \section1 JAVA_HOME + + \note This variable is useful only to Android targets. + + Specifies the JDK/OpenJDK installation path used for building the project. + \target LEXIMPLS \section1 LEXIMPLS From 13873c6bc6e9514e4b6d4e11f7100863a439e33c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 14 Feb 2020 14:20:02 +0100 Subject: [PATCH 34/42] Add support for high resolution wheel events from Linux 5.0+ They come in as a different relative axis, and we need to ignore the old axis to not scroll double. Change-Id: I808cce95417ec9f8058dee26d0a2694dda27944d Reviewed-by: Gatis Paeglis --- .../input/evdevmouse/qevdevmousehandler.cpp | 35 +++++++++++++++++-- .../input/evdevmouse/qevdevmousehandler_p.h | 3 ++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp index a729eeb8515..0b1c5548c7f 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp @@ -113,6 +113,8 @@ QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool abs, if (m_abs) m_abs = getHardwareMaximum(); + detectHiResWheelSupport(); + // socket notifier for events on the mouse device m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); connect(m_notify, &QSocketNotifier::activated, @@ -125,6 +127,25 @@ QEvdevMouseHandler::~QEvdevMouseHandler() qt_safe_close(m_fd); } +void QEvdevMouseHandler::detectHiResWheelSupport() +{ +#if defined(REL_WHEEL_HI_RES) || defined(REL_HWHEEL_HI_RES) + // Check if we can expect hires events as we will get both + // legacy and hires event and needs to know if we should + // ignore the legacy events. + unsigned char relFeatures[(REL_MAX / 8) + 1]{}; + if (ioctl(m_fd, EVIOCGBIT(EV_REL, sizeof (relFeatures)), relFeatures) == -1) + return; + +#if defined(REL_WHEEL_HI_RES) + m_hiResWheel = TEST_BIT(relFeatures, REL_WHEEL_HI_RES); +#endif +#if defined(REL_HWHEEL_HI_RES) + m_hiResHWheel = TEST_BIT(relFeatures, REL_HWHEEL_HI_RES); +#endif +#endif +} + // Ask touch screen hardware for information on coordinate maximums // If any ioctls fail, revert to non abs mode bool QEvdevMouseHandler::getHardwareMaximum() @@ -243,14 +264,24 @@ void QEvdevMouseHandler::readMouseData() } else if (data->code == REL_Y) { m_y += data->value; posChanged = true; - } else if (data->code == ABS_WHEEL) { // vertical scroll + } else if (!m_hiResWheel && data->code == REL_WHEEL) { // data->value: positive == up, negative == down delta.setY(120 * data->value); emit handleWheelEvent(delta); - } else if (data->code == ABS_THROTTLE) { // horizontal scroll +#ifdef REL_WHEEL_HI_RES + } else if (data->code == REL_WHEEL_HI_RES) { + delta.setY(data->value); + emit handleWheelEvent(delta); +#endif + } else if (!m_hiResHWheel && data->code == REL_HWHEEL) { // data->value: positive == right, negative == left delta.setX(-120 * data->value); emit handleWheelEvent(delta); +#ifdef REL_HWHEEL_HI_RES + } else if (data->code == REL_HWHEEL_HI_RES) { + delta.setX(-data->value); + emit handleWheelEvent(delta); +#endif } } else if (data->type == EV_KEY && data->code == BTN_TOUCH) { // We care about touchpads only, not touchscreens -> don't map to button press. diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h index 93314e885fe..8fcf49200b9 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h @@ -81,6 +81,7 @@ private: void sendMouseEvent(); bool getHardwareMaximum(); + void detectHiResWheelSupport(); QString m_device; int m_fd; @@ -89,6 +90,8 @@ private: int m_prevx = 0, m_prevy = 0; bool m_abs; bool m_compression; + bool m_hiResWheel = false; + bool m_hiResHWheel = false; Qt::MouseButtons m_buttons; Qt::MouseButton m_button; QEvent::Type m_eventType; From a275d38385382b8630dbd7de4df352bd7defb7aa Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 17 Apr 2020 12:25:22 +0200 Subject: [PATCH 35/42] doc: AA_DisableSessionManager was added in 5.14 This amends 404bee752c5058506900c23faa9d577a38b300f1. Fixes: QTBUG-83611 Change-Id: Ic3379a646b9c70fb23fd1f3f4bebed6e0b485664 Reviewed-by: Paul Wicking --- src/corelib/global/qnamespace.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 31e1bcc0dad..ca3687a420f 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -291,7 +291,7 @@ application on supported platforms, use of a session manager may be redundant for system services. This attribute must be set before QGuiApplication is constructed. - This value was added in 5.13 + This value was added in 5.14 The following values are deprecated or obsolete: From 441ea6be15f68f46ecee2365a7e7ee7dd6f11ff3 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 20 Apr 2020 10:43:29 +0200 Subject: [PATCH 36/42] sqlite: Fix CVE-2020-11655 This was taken from 4a302b42c7bf5e11 in SQLite, ref: https://www3.sqlite.org/cgi/src/info/4a302b42c7bf5e11 [ChangeLog][QtSQL][sqlite] Fixed CVE-2020-11655 Task-number: QTBUG-83652 Change-Id: I5ead78d9ee63aa0f12f1c1014c79373728569f30 Reviewed-by: Volker Hilsheimer --- .../0002-sqlite-Fix-CVE-2020-11655.patch | 30 +++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 1 + 2 files changed, 31 insertions(+) create mode 100644 src/3rdparty/sqlite/patches/0002-sqlite-Fix-CVE-2020-11655.patch diff --git a/src/3rdparty/sqlite/patches/0002-sqlite-Fix-CVE-2020-11655.patch b/src/3rdparty/sqlite/patches/0002-sqlite-Fix-CVE-2020-11655.patch new file mode 100644 index 00000000000..c47e68c4a98 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0002-sqlite-Fix-CVE-2020-11655.patch @@ -0,0 +1,30 @@ +From fa3ea2350c0367aa7cfd796b31214e2dcf574360 Mon Sep 17 00:00:00 2001 +From: Andy Shaw +Date: Mon, 20 Apr 2020 10:43:29 +0200 +Subject: [PATCH] sqlite: Fix CVE-2020-11655 + +This was taken from 4a302b42c7bf5e11 in SQLite, ref: +https://www3.sqlite.org/cgi/src/info/4a302b42c7bf5e11 + +[ChangeLog][QtSQL][sqlite] Fixed CVE-2020-11655 + +Change-Id: I5ead78d9ee63aa0f12f1c1014c79373728569f30 +--- + src/3rdparty/sqlite/sqlite3.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index dfe5323a59..054be43d95 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -133226,6 +133226,7 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ + struct AggInfo_func *pFunc; + int nReg = pAggInfo->nFunc + pAggInfo->nColumn; + if( nReg==0 ) return; ++ if( pParse->nErr ) return; + #ifdef SQLITE_DEBUG + /* Verify that all AggInfo registers are within the range specified by + ** AggInfo.mnReg..AggInfo.mxReg */ +-- +2.24.2 (Apple Git-127) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index dfe5323a594..054be43d95f 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -133226,6 +133226,7 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ struct AggInfo_func *pFunc; int nReg = pAggInfo->nFunc + pAggInfo->nColumn; if( nReg==0 ) return; + if( pParse->nErr ) return; #ifdef SQLITE_DEBUG /* Verify that all AggInfo registers are within the range specified by ** AggInfo.mnReg..AggInfo.mxReg */ From 3e6089b695489d5ba513723230a54b4b5e8349ae Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 20 Apr 2020 10:49:57 +0200 Subject: [PATCH 37/42] sqlite: Fix CVE-2020-11656 This was taken from d09f8c3621d5f7f8 and b64674919f673602 in SQLite, ref: https://www3.sqlite.org/cgi/src/info/d09f8c3621d5f7f8 https://www.sqlite.org/cgi/src/info/b64674919f673602 [ChangeLog][QtSQL][sqlite] Fixed CVE-2020-11656 Fixes: QTBUG-83652 Change-Id: I99bd59dc10b753ff19822c902dff1fc339d330a8 Reviewed-by: Volker Hilsheimer --- .../0003-sqlite-Fix-CVE-2020-11656.patch | 63 +++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 18 +++++- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/3rdparty/sqlite/patches/0003-sqlite-Fix-CVE-2020-11656.patch diff --git a/src/3rdparty/sqlite/patches/0003-sqlite-Fix-CVE-2020-11656.patch b/src/3rdparty/sqlite/patches/0003-sqlite-Fix-CVE-2020-11656.patch new file mode 100644 index 00000000000..c5ceb0a00c1 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0003-sqlite-Fix-CVE-2020-11656.patch @@ -0,0 +1,63 @@ +From 99cdbed3bb5368ae2ec80d15635a2dd57961310c Mon Sep 17 00:00:00 2001 +From: Andy Shaw +Date: Mon, 20 Apr 2020 10:49:57 +0200 +Subject: [PATCH] sqlite: Fix CVE-2020-11656 + +This was taken from d09f8c3621d5f7f8 and b64674919f673602 in SQLite, +ref: https://www3.sqlite.org/cgi/src/info/d09f8c3621d5f7f8 +https://www.sqlite.org/cgi/src/info/b64674919f673602 + +[ChangeLog][QtSQL][sqlite] Fixed CVE-2020-11656 + +Fixes: QTBUG-83652 +Change-Id: I99bd59dc10b753ff19822c902dff1fc339d330a8 +--- + src/3rdparty/sqlite/sqlite3.c | 18 +++++++++++++++++- + 1 file changed, 17 insertions(+), 1 deletion(-) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index 054be43d95..6ff9ba42aa 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -97945,7 +97945,7 @@ static int resolveOrderByTermToExprList( + nc.nErr = 0; + db = pParse->db; + savedSuppErr = db->suppressErr; +- db->suppressErr = 1; ++ if( IN_RENAME_OBJECT==0 ) db->suppressErr = 1; + rc = sqlite3ResolveExprNames(&nc, pE); + db->suppressErr = savedSuppErr; + if( rc ) return 0; +@@ -105383,6 +105383,21 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){ + } + } + ++/* ++** Unmap all tokens in the IdList object passed as the second argument. ++*/ ++static void unmapColumnIdlistNames( ++ Parse *pParse, ++ IdList *pIdList ++){ ++ if( pIdList ){ ++ int ii; ++ for(ii=0; iinId; ii++){ ++ sqlite3RenameTokenRemap(pParse, 0, (void*)pIdList->a[ii].zName); ++ } ++ } ++} ++ + /* + ** Walker callback used by sqlite3RenameExprUnmap(). + */ +@@ -105404,6 +105419,7 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ + for(i=0; inSrc; i++){ + sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName); + if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort; ++ unmapColumnIdlistNames(pParse, pSrc->a[i].pUsing); + } + } + +-- +2.24.2 (Apple Git-127) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index 054be43d95f..6ff9ba42aab 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -97945,7 +97945,7 @@ static int resolveOrderByTermToExprList( nc.nErr = 0; db = pParse->db; savedSuppErr = db->suppressErr; - db->suppressErr = 1; + if( IN_RENAME_OBJECT==0 ) db->suppressErr = 1; rc = sqlite3ResolveExprNames(&nc, pE); db->suppressErr = savedSuppErr; if( rc ) return 0; @@ -105383,6 +105383,21 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){ } } +/* +** Unmap all tokens in the IdList object passed as the second argument. +*/ +static void unmapColumnIdlistNames( + Parse *pParse, + IdList *pIdList +){ + if( pIdList ){ + int ii; + for(ii=0; iinId; ii++){ + sqlite3RenameTokenRemap(pParse, 0, (void*)pIdList->a[ii].zName); + } + } +} + /* ** Walker callback used by sqlite3RenameExprUnmap(). */ @@ -105404,6 +105419,7 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ for(i=0; inSrc; i++){ sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName); if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort; + unmapColumnIdlistNames(pParse, pSrc->a[i].pUsing); } } From 7202df3689f98a43462dc6411c4593153d300ccd Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 17 Apr 2020 11:43:38 +0200 Subject: [PATCH 38/42] Replace QTime with QElapsedTimer in benchmarks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Various benchmarks were still using the deprecated timing API. One didn't even *use* the timer it implemented this way. One was just using start as a short-hand for assigning to currentTime(). Change-Id: If406d0fb606e454fec056f386bcd0aa6726ee96e Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira Reviewed-by: Mårten Nordheim --- .../corelib/io/qprocess/tst_bench_qprocess.cpp | 5 +++-- .../gui/painting/qtbench/tst_qtbench.cpp | 7 ++++--- .../qfile_vs_qnetworkaccessmanager/main.cpp | 9 +++++---- .../access/qnetworkreply/tst_qnetworkreply.cpp | 17 +++++++++-------- .../socket/qtcpserver/tst_qtcpserver.cpp | 9 +++++---- tests/benchmarks/opengl/main.cpp | 5 +++-- .../widgets/itemrecyclinglist.cpp | 8 ++++---- .../GraphicsViewBenchmark/widgets/mainview.cpp | 6 +++--- .../GraphicsViewBenchmark/widgets/mainview.h | 5 +++-- .../GraphicsViewBenchmark/widgets/scroller_p.h | 8 ++++---- .../widgets/simplelist.cpp | 8 ++++---- .../qgraphicsview/chiptester/chiptester.cpp | 3 +-- .../qgraphicsview/chiptester/chiptester.h | 4 +--- 13 files changed, 49 insertions(+), 45 deletions(-) diff --git a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp index 5bd4bc5520c..1fd3b9d5daa 100644 --- a/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp +++ b/tests/benchmarks/corelib/io/qprocess/tst_bench_qprocess.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -28,6 +28,7 @@ #include #include +#include class tst_QProcess : public QObject { @@ -50,7 +51,7 @@ void tst_QProcess::echoTest_performance() QVERIFY(process.waitForStarted()); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); qint64 totalBytes = 0; diff --git a/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp index c2ce15f720f..fb5b2cdc91d 100644 --- a/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp +++ b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -29,6 +29,7 @@ #include #include +#include #include #include "benchmarktests.h" @@ -44,7 +45,7 @@ public: qreal result() const { return m_result; } public: - QTime timer; + QElapsedTimer timer; Benchmark *m_benchmark; @@ -77,7 +78,7 @@ void BenchWidget::paintEvent(QPaintEvent *) ++m_iteration; - uint currentElapsed = timer.isNull() ? 0 : timer.elapsed(); + uint currentElapsed = timer.isValid() ? timer.elapsed() : 0; timer.restart(); m_total += currentElapsed; diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp index 46bb1791b48..b6a83546a88 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -32,6 +32,7 @@ #include #include #include +#include #include class qfile_vs_qnetworkaccessmanager : public QObject @@ -88,7 +89,7 @@ void qfile_vs_qnetworkaccessmanager::qnamFileRead_iteration(QNetworkAccessManage void qfile_vs_qnetworkaccessmanager::qnamFileRead() { QNetworkAccessManager manager; - QTime t; + QElapsedTimer t; QNetworkRequest request(QUrl::fromLocalFile(testFile.fileName())); // do 3 dry runs for cache warmup @@ -121,7 +122,7 @@ void qfile_vs_qnetworkaccessmanager::qnamImmediateFileRead_iteration(QNetworkAcc void qfile_vs_qnetworkaccessmanager::qnamImmediateFileRead() { QNetworkAccessManager manager; - QTime t; + QElapsedTimer t; QNetworkRequest request(QUrl::fromLocalFile(testFile.fileName())); // do 3 dry runs for cache warmup @@ -151,7 +152,7 @@ void qfile_vs_qnetworkaccessmanager::qfileFileRead_iteration() void qfile_vs_qnetworkaccessmanager::qfileFileRead() { - QTime t; + QElapsedTimer t; // do 3 dry runs for cache warmup qfileFileRead_iteration(); diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index bcd354ebeec..9b1f801044a 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -93,7 +94,7 @@ protected: QEventLoop eventLoop; QTimer::singleShot(timeout, &eventLoop, SLOT(quit())); - QTime timer; + QElapsedTimer timer; timer.start(); eventLoop.exec(); disconnect(client, SIGNAL(bytesWritten(qint64)), this, 0); @@ -187,7 +188,7 @@ protected: DataReader reader(client, false); QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - QTime timer; + QElapsedTimer timer; timer.start(); eventLoop.exec(); qint64 elapsed = timer.elapsed(); @@ -280,7 +281,7 @@ protected: DataReader reader(client, false); QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - QTime timer; + QElapsedTimer timer; timer.start(); eventLoop.exec(); qint64 elapsed = timer.elapsed(); @@ -639,7 +640,7 @@ void tst_qnetworkreply::downloadPerformance() QNetworkReplyPtr reply(manager.get(request)); DataReader reader(reply, false); - QTime loopTime; + QElapsedTimer loopTime; connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); loopTime.start(); QTestEventLoop::instance().enterLoop(40); @@ -682,7 +683,7 @@ void tst_qnetworkreply::httpUploadPerformance() connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTime time; + QElapsedTimer time; generator.start(); time.start(); QTestEventLoop::instance().enterLoop(40); @@ -710,7 +711,7 @@ void tst_qnetworkreply::performanceControlRate() sink.connectToHost("127.0.0.1", sender.serverPort()); DataReader reader(&sink, false); - QTime loopTime; + QElapsedTimer loopTime; connect(&sink, SIGNAL(disconnected()), &QTestEventLoop::instance(), SLOT(exitLoop())); loopTime.start(); QTestEventLoop::instance().enterLoop(40); @@ -748,7 +749,7 @@ void tst_qnetworkreply::httpDownloadPerformance() connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); HttpDownloadPerformanceClient client(reply.data()); - QTime time; + QElapsedTimer time; time.start(); QTestEventLoop::instance().enterLoop(40); QCOMPARE(reply->error(), QNetworkReply::NoError); diff --git a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp index a9f8634129c..f35e5cd3db9 100644 --- a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -27,6 +27,7 @@ ****************************************************************************/ #include +#include #include #include #include @@ -129,7 +130,7 @@ void tst_QTcpServer::ipv4LoopbackPerformanceTest() QVERIFY(clientB); QByteArray buffer(16384, '@'); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); qlonglong totalWritten = 0; while (stopWatch.elapsed() < 5000) { @@ -180,7 +181,7 @@ void tst_QTcpServer::ipv6LoopbackPerformanceTest() QVERIFY(clientB); QByteArray buffer(16384, '@'); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); qlonglong totalWritten = 0; while (stopWatch.elapsed() < 5000) { @@ -230,7 +231,7 @@ void tst_QTcpServer::ipv4PerformanceTest() QVERIFY(clientB); QByteArray buffer(16384, '@'); - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); qlonglong totalWritten = 0; while (stopWatch.elapsed() < 5000) { diff --git a/tests/benchmarks/opengl/main.cpp b/tests/benchmarks/opengl/main.cpp index 0886c0e55be..9462f35c387 100644 --- a/tests/benchmarks/opengl/main.cpp +++ b/tests/benchmarks/opengl/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -27,6 +27,7 @@ ****************************************************************************/ #include #include +#include #include @@ -400,7 +401,7 @@ void OpenGLBench::textureUpload() pb->makeCurrent(); QGLContext *context = const_cast(QGLContext::currentContext()); - QTime time; + QElapsedTimer time; time.start(); context->bindTexture(pixmap, GL_TEXTURE_2D, format, (QGLContext::BindOptions) flags); diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp index eabe3671e53..0aa73b9e26b 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/itemrecyclinglist.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -27,7 +27,7 @@ ****************************************************************************/ #include -#include +#include #include "itemrecyclinglist.h" #include "listitemcontainer.h" @@ -160,10 +160,10 @@ void ItemRecyclingList::themeChange() void ItemRecyclingList::keyPressEvent(QKeyEvent *event) { - static QTime keyPressInterval = QTime::currentTime(); + static QElapsedTimer keyPressInterval; static qreal step = 0.0; static bool repeat = false; - int interval = keyPressInterval.elapsed(); + int interval = keyPressInterval.isValid() ? keyPressInterval.elapsed() : 0; ScrollBar* sb = verticalScrollBar(); qreal currentValue = sb->sliderPosition(); diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp index 8f7736010de..93b8d860199 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -132,7 +132,7 @@ qreal MainView::fps() void MainView::fpsReset() { m_frameCount = 0; - m_fpsFirstTs.start(); + m_fpsFirstTs = QTime::currentTime(); m_fpsLatestTs = m_fpsFirstTs; m_fpsUpdated.start(); } @@ -201,7 +201,7 @@ void MainView::paintEvent (QPaintEvent *event) emit repainted(); m_frameCount++; - m_fpsLatestTs.start(); + m_fpsLatestTs = QTime::currentTime(); if(m_fpsUpdated.elapsed() > 2000) { updateFps(); m_fpsUpdated.start(); diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h index d7fe4040239..8237ff74698 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/mainview.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -31,6 +31,7 @@ #include #include +#include #include #include "settings.h" @@ -100,7 +101,7 @@ private: QTime m_fpsFirstTs; QTime m_fpsLatestTs; bool m_OutputFps; - QTime m_fpsUpdated; + QElapsedTimer m_fpsUpdated; QList m_Fpss; int m_angle; diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h index cf11c7fa024..c8769f59b27 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/scroller_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -42,7 +42,7 @@ #include #include -#include +#include #include "scroller.h" @@ -70,8 +70,8 @@ public: QPoint m_cursorPos; QPointF m_speed; State m_state; - QTime m_lastCursorTime; - QTime m_lastFrameTime; + QElapsedTimer m_lastCursorTime; + QElapsedTimer m_lastFrameTime; QTimer m_scrollTimer; int m_scrollSlowAccum; diff --git a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp index 941cab8c21c..d64f3ac38de 100644 --- a/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp +++ b/tests/benchmarks/widgets/graphicsview/functional/GraphicsViewBenchmark/widgets/simplelist.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include "simplelist.h" static const int MinItemWidth = 276; @@ -99,10 +99,10 @@ void SimpleList::setListItemCaching(bool enable) void SimpleList::keyPressEvent(QKeyEvent *event) { - static QTime keyPressInterval = QTime::currentTime(); + static QElapsedTimer keyPressInterval; static qreal step = 0.0; static bool repeat = false; - int interval = keyPressInterval.elapsed(); + int interval = keyPressInterval.isValid() ? keyPressInterval.elapsed() : 0; ScrollBar* sb = verticalScrollBar(); qreal currentValue = sb->sliderPosition(); diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.cpp index dfa08b68691..93bdc409dcb 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -72,7 +72,6 @@ void ChipTester::runBenchmark() { npaints = 0; timerId = startTimer(0); - stopWatch.start(); eventLoop.exec(); killTimer(timerId); } diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h index d85686c94ec..cc4a5cd2bec 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -31,7 +31,6 @@ #include #include -#include QT_FORWARD_DECLARE_CLASS(QGraphicsScene) QT_FORWARD_DECLARE_CLASS(QGraphicsView) @@ -67,7 +66,6 @@ private: int npaints; int timerId; QEventLoop eventLoop; - QTime stopWatch; Operation operation; }; From 559bd88bce66e673b5215a8b3ebf1d714a23c299 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Tue, 26 Mar 2019 15:17:59 +0200 Subject: [PATCH 39/42] Add option to select build target for Integrity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 11.7.6 onwards you need to select if your build is rel/dbg/chk/cov. Added env variable where you can add which build target to configure. Task-number: QTBUG-74716 Change-Id: I9ab3dd6177c5c5fa1da6aa7556784fa86d0d0348 Reviewed-by: Timo Aarnipuro Reviewed-by: Tomi Korpipää Reviewed-by: Joerg Bornemann --- mkspecs/common/ghs-integrity-armv8.conf | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mkspecs/common/ghs-integrity-armv8.conf b/mkspecs/common/ghs-integrity-armv8.conf index e454cfd2459..ac30b6c7af8 100644 --- a/mkspecs/common/ghs-integrity-armv8.conf +++ b/mkspecs/common/ghs-integrity-armv8.conf @@ -17,8 +17,16 @@ os_directory = $$(INTEGRITY_DIR) isEmpty(os_directory): \ error("This qmakespec requires $INTEGRITY_DIR to be set") -QMAKE_CC = cxintarm64 -bsp $$bsp_name -os_dir $$os_directory -non_shared -QMAKE_CXX = cxintarm64 -bsp $$bsp_name -os_dir $$os_directory -non_shared +iy_build_target = $$(INTEGRITY_BUILD_TARGET) +isEmpty(iy_build_target): \ + message("This qmakespec requires $INTEGRITY_BUILD_TARGET to be set [dbg|rel|chk|cov] for Integrity versions 11.7.6 and higher") + +start_name = $$(INTEGRITY_DIR)/libs/$$(INTEGRITY_BSP)/$$(INTEGRITY_BUILD_TARGET) +rtos_name= libs/$$(INTEGRITY_BSP)/$$(INTEGRITY_BUILD_TARGET) + +QMAKE_CC = cxintarm64 -bsp $$bsp_name -os_dir $$os_directory -non_shared -startfile_dir=$$start_name --rtos_library_directory=$$rtos_name --rtos_library_directory=libs/arm64/$$iy_build_target +QMAKE_CXX = cxintarm64 -bsp $$bsp_name -os_dir $$os_directory -non_shared -startfile_dir=$$start_name --rtos_library_directory=$$rtos_name --rtos_library_directory=libs/arm64/$$iy_build_target + QMAKE_LINK = $$QMAKE_CXX QMAKE_AR = $$QMAKE_CXX -archive -o From 0fcd782bd3690867f19420270bcc329325f04424 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Sun, 19 Apr 2020 00:39:32 +0200 Subject: [PATCH 40/42] Markdown writer: don't wrap code block, and detect its end The end of a code block nested in a list item is now detected; and if the text of the list item continues after the code block, it continues to be indented. Code blocks should never be word-wrapped. Fixes: QTBUG-80603 Change-Id: I4427f8b1d4807d819616f5cb971e2d006170d9be Reviewed-by: Volker Hilsheimer --- src/gui/text/qtextmarkdownwriter.cpp | 17 +++++++------ .../data/listsAndCodeBlocks.md | 24 +++++++++++++++++++ .../tst_qtextmarkdownwriter.cpp | 1 + 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index 7bd321beccc..17889998552 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -367,6 +367,14 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign const int ColumnLimit = 80; QTextBlockFormat blockFmt = block.blockFormat(); bool missedBlankCodeBlockLine = false; + const bool codeBlock = blockFmt.hasProperty(QTextFormat::BlockCodeFence) || + blockFmt.stringProperty(QTextFormat::BlockCodeLanguage).length() > 0; + if (m_fencedCodeBlock && !codeBlock) { + m_stream << m_linePrefix << QString(m_wrappedLineIndent, Space) + << m_codeBlockFence << Newline; + m_fencedCodeBlock = false; + m_codeBlockFence.clear(); + } if (block.textList()) { // it's a list-item auto fmt = block.textList()->format(); const int listLevel = fmt.indent(); @@ -427,7 +435,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign } else if (blockFmt.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) { m_stream << "- - -\n"; // unambiguous horizontal rule, not an underline under a heading return 0; - } else if (blockFmt.hasProperty(QTextFormat::BlockCodeFence) || blockFmt.stringProperty(QTextFormat::BlockCodeLanguage).length() > 0) { + } else if (codeBlock) { // It's important to preserve blank lines in code blocks. But blank lines in code blocks // inside block quotes are getting preserved anyway (along with the "> " prefix). if (!blockFmt.hasProperty(QTextFormat::BlockQuoteLevel)) @@ -442,13 +450,8 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign << Space << blockFmt.stringProperty(QTextFormat::BlockCodeLanguage) << Newline; m_fencedCodeBlock = true; } + wrap = false; } else if (!blockFmt.indent()) { - if (m_fencedCodeBlock) { - m_stream << m_linePrefix << QString(m_wrappedLineIndent, Space) - << m_codeBlockFence << Newline; - m_fencedCodeBlock = false; - m_codeBlockFence.clear(); - } m_wrappedLineIndent = 0; m_linePrefix.clear(); if (blockFmt.hasProperty(QTextFormat::BlockQuoteLevel)) { diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md b/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md new file mode 100644 index 00000000000..c65e01408b3 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md @@ -0,0 +1,24 @@ +- something happens in the debugger like this: + + ``` + 1 QQuickEventPoint::setGrabberItem qquickevents.cpp 869 0x7ffff7a963f2 + 2 QQuickItem::grabMouse qquickitem.cpp 7599 0x7ffff7abea29 + 3 QQuickWindowPrivate::deliverMatchingPointsToItem qquickwindow.cpp 2738 0x7ffff7aea34c + 4 QQuickWindowPrivate::deliverPressOrReleaseEvent qquickwindow.cpp 2692 0x7ffff7ae9e57 + 5 QQuickWindowPrivate::deliverMouseEvent qquickwindow.cpp 1911 0x7ffff7ae561b + 6 QQuickWindowPrivate::deliverPointerEvent qquickwindow.cpp 2454 0x7ffff7ae888c + 7 QQuickWindowPrivate::handleMouseEvent qquickwindow.cpp 2282 0x7ffff7ae7f1a + 8 QQuickWindow::mousePressEvent qquickwindow.cpp 2249 0x7ffff7ae7bf5 + 9 QQuickView::mousePressEvent qquickview.cpp 626 0x7ffff7bd6bad + 10 QWindow::event qwindow.cpp 2258 0x7ffff70b2c54 + ``` + and then I want to explain something about it. + +- something I tried to fix it: + + ``` + code goes here, probably c++ + ``` +- still didn't fix it, expecting a breakthrough any day now +- some sort of miracle +- profit! diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index 31592c7f0f9..84cf237ccc6 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -369,6 +369,7 @@ void tst_QTextMarkdownWriter::rewriteDocument_data() QTest::newRow("list items after headings") << "headingsAndLists.md"; QTest::newRow("word wrap") << "wordWrap.md"; QTest::newRow("links") << "links.md"; + QTest::newRow("lists and code blocks") << "listsAndCodeBlocks.md"; } void tst_QTextMarkdownWriter::rewriteDocument() From 51a348b2e24544f4d42aee10824c98df59062edc Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Sun, 19 Apr 2020 01:24:05 +0200 Subject: [PATCH 41/42] Markdown writer: omit space after opening code block fence The CommonMark spec shows that it's not necessary to have a space between the code fence and the language string: https://spec.commonmark.org/0.29/#example-112 This also avoids a needless trailing space after a code fence that does not include a language string. Change-Id: I2addd38a196045a7442150760b73269bfe4ffb22 Reviewed-by: Volker Hilsheimer --- src/gui/text/qtextmarkdownwriter.cpp | 2 +- tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md | 4 ++-- .../gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md | 6 +++--- .../text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index 17889998552..ae63fcb4dd0 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -447,7 +447,7 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign m_codeBlockFence = QString(3, fenceChar.at(0)); // A block quote can contain an indented code block, but not vice-versa. m_stream << m_linePrefix << QString(m_wrappedLineIndent, Space) << m_codeBlockFence - << Space << blockFmt.stringProperty(QTextFormat::BlockCodeLanguage) << Newline; + << blockFmt.stringProperty(QTextFormat::BlockCodeLanguage) << Newline; m_fencedCodeBlock = true; } wrap = false; diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md index 6336d0219f3..702ccef1346 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md @@ -20,7 +20,7 @@ MacFarlane writes: > equivalent sample of Markdown. Here is a sample of AsciiDoc from the AsciiDoc > manual: -> ``` AsciiDoc +> ```AsciiDoc > 1. List item one. > + > List item one continued with a second paragraph followed by an @@ -50,7 +50,7 @@ Now let's have an indented code block: } and end with a fenced code block: -~~~ pseudocode +~~~pseudocode #include #include diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md b/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md index c65e01408b3..54e3f25afa4 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/listsAndCodeBlocks.md @@ -1,6 +1,6 @@ - something happens in the debugger like this: - ``` + ``` 1 QQuickEventPoint::setGrabberItem qquickevents.cpp 869 0x7ffff7a963f2 2 QQuickItem::grabMouse qquickitem.cpp 7599 0x7ffff7abea29 3 QQuickWindowPrivate::deliverMatchingPointsToItem qquickwindow.cpp 2738 0x7ffff7aea34c @@ -16,8 +16,8 @@ - something I tried to fix it: - ``` - code goes here, probably c++ + ```c++ + item->ungrab(); ``` - still didn't fix it, expecting a breakthrough any day now - some sort of miracle diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index 84cf237ccc6..13449299cb2 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -432,7 +432,7 @@ void tst_QTextMarkdownWriter::fromHtml_data() "![foo](/url \"title\")\n\n"; QTest::newRow("code") << "
\n#include \"foo.h\"\n\nblock {\n    statement();\n}\n\n
" << - "``` pseudocode\n#include \"foo.h\"\n\nblock {\n statement();\n}\n```\n\n"; + "```pseudocode\n#include \"foo.h\"\n\nblock {\n statement();\n}\n```\n\n"; // TODO // QTest::newRow("escaped number and paren after double newline") << // "

(The first sentence of this paragraph is a line, the next paragraph has a number

13) but that's not part of an ordered list" << From e10e5318bc02a48a866b76b6f0b7f268d16af642 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 21 Apr 2020 13:09:10 +0200 Subject: [PATCH 42/42] Doc: Fix documentation warnings for Qt Core qsocketnotifier.h:113:69: error: cannot initialize return object of type 'Qt::HANDLE' (aka 'void *') with an lvalue of type 'const QSocketDescriptor::DescriptorType' (aka 'const int') qsortfilterproxymodel.cpp:2938: error: out-of-line definition of 'recursiveFilteringEnabledChanged' does not match any declaration in 'QSortFilterProxyModel' qline.cpp:376: (qdoc) warning: Cannot find 'QLineF::IntersectionType' specified with '\enum' in any header file Fixes: QTBUG-83676 Change-Id: I57b51f4ad15fdc50db88100ad5b1cb85ed394b7a Reviewed-by: Paul Wicking --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 2 +- src/corelib/kernel/qsocketnotifier.h | 2 +- src/corelib/tools/qline.cpp | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 35c97da5320..4f5593e0a01 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -2937,7 +2937,7 @@ void QSortFilterProxyModel::setFilterRole(int role) /*! \since 5.15 - \fn void QSortFilterProxyModel::recursiveFilteringEnabledChanged(int recursiveFilteringEnabled) + \fn void QSortFilterProxyModel::recursiveFilteringEnabledChanged(bool recursiveFilteringEnabled) \brief This signal is emitted when the recursive filter setting is changed to \a recursiveFilteringEnabled. */ diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h index 808931e04bc..528f58a1e19 100644 --- a/src/corelib/kernel/qsocketnotifier.h +++ b/src/corelib/kernel/qsocketnotifier.h @@ -94,7 +94,7 @@ private: class QSocketDescriptor { public: -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) || defined(Q_QDOC) using DescriptorType = Qt::HANDLE; #define Q_DECL_CONSTEXPR_NOT_WIN #else diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index 3afd23d76b4..40a69173c47 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -370,11 +370,18 @@ QDataStream &operator>>(QDataStream &stream, QLine &line) /*! \enum QLineF::IntersectType - \obsolete Use QLineF::IntersectionType instead + \obsolete Use QLineF::IntersectionType instead. + + \value NoIntersection + Lines do not intersect. + \value UnboundedIntersection + Lines intersect, but not within the range defined by their lengths. + \value BoundedIntersection + Lnes intersect within the range defined by their lengths. */ /*! - \enum QLineF::IntersectionType + \typealias QLineF::IntersectionType Describes the intersection between two lines.