summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.bat11
-rw-r--r--doc/global/template/style/offline-simple.css19
-rw-r--r--mkspecs/common/mac.conf2
-rw-r--r--mkspecs/features/create_cmake.prf4
-rw-r--r--mkspecs/features/file_copies.prf4
-rw-r--r--mkspecs/features/mac/sdk.prf4
-rw-r--r--mkspecs/features/qt_configure.prf2
-rw-r--r--mkspecs/winrt-arm-msvc2019/qmake.conf19
-rw-r--r--mkspecs/winrt-arm-msvc2019/qplatformdefs.h40
-rw-r--r--mkspecs/winrt-arm64-msvc2019/qmake.conf19
-rw-r--r--mkspecs/winrt-arm64-msvc2019/qplatformdefs.h40
-rw-r--r--mkspecs/winrt-x64-msvc2019/qmake.conf19
-rw-r--r--mkspecs/winrt-x64-msvc2019/qplatformdefs.h40
-rw-r--r--mkspecs/winrt-x86-msvc2019/qmake.conf18
-rw-r--r--mkspecs/winrt-x86-msvc2019/qplatformdefs.h40
-rw-r--r--qmake/generators/makefile.cpp4
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp29
-rw-r--r--qmake/generators/win32/msvc_vcproj.h1
-rw-r--r--qmake/generators/win32/winmakefile.cpp6
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java4
-rw-r--r--src/android/java/res/values-el/strings.xml1
-rw-r--r--src/android/java/res/values-es/strings.xml1
-rw-r--r--src/android/java/res/values-et/strings.xml1
-rw-r--r--src/android/java/res/values-fa/strings.xml1
-rw-r--r--src/android/java/res/values-in/strings.xml (renamed from src/android/java/res/values-id/strings.xml)1
-rw-r--r--src/android/java/res/values-it/strings.xml1
-rw-r--r--src/android/java/res/values-ja/strings.xml1
-rw-r--r--src/android/java/res/values-ms/strings.xml1
-rw-r--r--src/android/java/res/values-nb/strings.xml1
-rw-r--r--src/android/java/res/values-nl/strings.xml1
-rw-r--r--src/android/java/res/values-pl/strings.xml1
-rw-r--r--src/android/java/res/values-pt-rBR/strings.xml1
-rw-r--r--src/android/java/res/values-ro/strings.xml2
-rw-r--r--src/android/java/res/values-rs/strings.xml1
-rw-r--r--src/android/java/res/values-ru/strings.xml1
-rw-r--r--src/android/java/res/values-zh-rCN/strings.xml1
-rw-r--r--src/android/java/res/values-zh-rTW/strings.xml1
-rw-r--r--src/android/java/res/values/strings.xml2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp2
-rw-r--r--src/corelib/doc/snippets/signalsandslots/lcdnumber.h2
-rw-r--r--src/corelib/doc/src/objectmodel/signalsandslots.qdoc4
-rw-r--r--src/corelib/global/global.pri2
-rw-r--r--src/corelib/io/qloggingcategory.h49
-rw-r--r--src/corelib/io/qprocess_win.cpp22
-rw-r--r--src/corelib/io/qsettings.cpp8
-rw-r--r--src/corelib/io/qtemporaryfile.cpp22
-rw-r--r--src/corelib/kernel/qcore_mac.cpp23
-rw-r--r--src/corelib/kernel/qcore_mac_p.h1
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp4
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp10
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h7
-rw-r--r--src/corelib/kernel/qobject.cpp6
-rw-r--r--src/corelib/serialization/qcborstream.cpp29
-rw-r--r--src/corelib/thread/qthread.cpp10
-rw-r--r--src/corelib/tools/qcollator_win.cpp34
-rw-r--r--src/corelib/tools/qscopeguard.qdoc8
-rw-r--r--src/corelib/tools/qstring.cpp2
-rw-r--r--src/gui/Qt5GuiConfigExtras.cmake.in23
-rw-r--r--src/gui/configure.json2
-rw-r--r--src/gui/configure.pri11
-rw-r--r--src/gui/kernel/qopenglcontext.cpp2
-rw-r--r--src/gui/kernel/qplatformgraphicsbuffer.h2
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp20
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h1
-rw-r--r--src/gui/opengl/qopengltextureuploader.cpp31
-rw-r--r--src/gui/painting/qbezier.cpp5
-rw-r--r--src/gui/painting/qrasterizer.cpp4
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp2
-rw-r--r--src/network/access/http2/hpacktable.cpp209
-rw-r--r--src/network/access/http2/hpacktable_p.h11
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp5
-rw-r--r--src/network/access/qnetworkreplywasmimpl.cpp2
-rw-r--r--src/platformsupport/services/genericunix/qgenericunixservices.cpp52
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp16
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglwindow.cpp3
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm12
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h52
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm543
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm14
-rw-r--r--src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h77
-rw-r--r--src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm188
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm9
-rw-r--r--src/plugins/platforms/cocoa/qnsview_dragging.mm111
-rw-r--r--src/plugins/platforms/cocoa/qnsview_drawing.mm7
-rw-r--r--src/plugins/platforms/cocoa/qnsview_mouse.mm39
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen.cpp3
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow.cpp27
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow_p.h1
-rw-r--r--src/plugins/platforms/haiku/haiku.pro2
-rw-r--r--src/plugins/platforms/ios/qioscontext.mm3
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp23
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.h1
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp25
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp9
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp132
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.h2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h6
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_basic.h3
-rw-r--r--src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp5
-rw-r--r--src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp2
-rw-r--r--src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h2
-rw-r--r--src/testlib/qappletestlogger.cpp20
-rw-r--r--src/testlib/qappletestlogger_p.h17
-rw-r--r--src/testlib/qtestblacklist.cpp1
-rw-r--r--src/testlib/qtestcase.cpp31
-rw-r--r--src/testlib/qtestkeyboard.h4
-rw-r--r--src/testlib/qtestlog.cpp197
-rw-r--r--src/testlib/qtestlog_p.h11
-rw-r--r--src/tools/androiddeployqt/main.cpp4
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp2
-rw-r--r--src/widgets/dialogs/qdialog.cpp7
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp2
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp4
-rw-r--r--src/widgets/itemviews/qlistview.cpp4
-rw-r--r--src/widgets/itemviews/qlistview_p.h19
-rw-r--r--src/widgets/styles/qcommonstyle.cpp25
-rw-r--r--tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp1
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro2
-rw-r--r--tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp155
-rw-r--r--tests/auto/network/access/hpack/tst_hpack.cpp49
-rw-r--r--tests/auto/network/access/http2/http2srv.cpp14
-rw-r--r--tests/auto/network/access/http2/http2srv.h1
-rw-r--r--tests/auto/network/access/http2/tst_http2.cpp2
-rw-r--r--tests/auto/network/ssl/qsslkey/BLACKLIST4
-rw-r--r--tests/auto/other/other.pro2
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST11
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro5
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp46
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp54
-rw-r--r--tests/baselineserver/shared/baselineprotocol.cpp2
-rw-r--r--tests/manual/gestures/graphicsview/gestures.cpp2
-rw-r--r--tests/manual/qgraphicsitemgroup/widget.cpp2
-rw-r--r--tests/manual/qsysinfo/main.cpp22
-rw-r--r--tests/manual/qtabletevent/regular_widgets/main.cpp2
-rw-r--r--tests/manual/widgets/widgets/widgets.pro5
143 files changed, 2266 insertions, 778 deletions
diff --git a/configure.bat b/configure.bat
index 7cadd783ea..b34e146f5f 100644
--- a/configure.bat
+++ b/configure.bat
@@ -125,11 +125,8 @@ goto doneargs
:platform
shift
- if "%~1" == "win32-msvc2012" goto msvc
- if "%~1" == "win32-msvc2013" goto msvc
- if "%~1" == "win32-msvc2015" goto msvc
- if "%~1" == "win32-msvc2017" goto msvc
set PLATFORM=%~1
+ if "%PLATFORM:~0,10%" == "win32-msvc" goto msvc
goto nextarg
:msvc
echo. >&2
@@ -150,7 +147,7 @@ goto doneargs
:doneargs
rem Find various executables
-for %%C in (clang-cl.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C
+for %%C in (clang-cl.exe clang.exe cl.exe icl.exe g++.exe perl.exe jom.exe) do set %%C=%%~$PATH:C
rem Determine host spec
@@ -161,6 +158,8 @@ if "%PLATFORM%" == "" (
set PLATFORM=win32-msvc
) else if not "%clang-cl.exe%" == "" (
set PLATFORM=win32-clang-msvc
+ ) else if not "%clang.exe%" == "" (
+ set PLATFORM=win32-clang-g++
) else if not "%g++.exe%" == "" (
set PLATFORM=win32-g++
) else (
@@ -172,7 +171,7 @@ if not exist "%QTSRC%\mkspecs\%PLATFORM%\qmake.conf" (
echo Host platform '%PLATFORM%' is invalid. Aborting. >&2
exit /b 1
)
-if "%PLATFORM:win32-g++=%" == "%PLATFORM%" (
+if "%PLATFORM:g++=%" == "%PLATFORM%" (
if "%MAKE%" == "" (
if not "%jom.exe%" == "" (
set MAKE=jom
diff --git a/doc/global/template/style/offline-simple.css b/doc/global/template/style/offline-simple.css
index 82e99c42ac..b89ca5a808 100644
--- a/doc/global/template/style/offline-simple.css
+++ b/doc/global/template/style/offline-simple.css
@@ -1,5 +1,4 @@
pre, .LegaleseLeft {
- background-color: #f0f0f0;
font-family: Courier, monospace;
font-weight: 600;
vertical-align: top;
@@ -40,7 +39,6 @@ h1.title {
}
h2, p.h2 {
- background-color: #F2F3F4;
padding: 4px;
margin: 30px 0px 20px 10px;
}
@@ -67,10 +65,6 @@ ul li, ol li {
}
h3.fn, span.fn {
- border-width: 3px;
- border-style: solid;
- border-color: #aaaaaa;
- background-color: #eeeeee;
word-spacing: 3px;
padding: 5px;
text-decoration: none;
@@ -94,10 +88,6 @@ table td {
padding: 6px 10px 6px 10px;
}
-table tr.odd {
- background-color: #eeeeee;
-}
-
table.qmlname td {
padding: 0px;
margin-left: 6px;
@@ -144,19 +134,10 @@ span.naviSeparator {
margin: 0;
}
-.navigationbar table tr {
- background-color: #eeeeee;
-}
-
-td#buildversion {
- background-color: #ffffff;
-}
-
.footer, .footer p {
padding: 5px 0px 5px 0px;
margin: 45px 15px 5px 15px;
font-size: 8.5pt;
- background-color: #cccccc;
}
.footer p {
diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf
index b77494ec9b..f21ba5ec51 100644
--- a/mkspecs/common/mac.conf
+++ b/mkspecs/common/mac.conf
@@ -17,7 +17,7 @@ QMAKE_EXTENSION_SHLIB = dylib
QMAKE_EXTENSIONS_AUX_SHLIB = tbd
QMAKE_LIBDIR =
-# sdk.prf will prefix the proper SDK sysroot
+# qtConfLibrary_openglMakeSpec will prefix the proper SDK sysroot
QMAKE_INCDIR_OPENGL = \
/System/Library/Frameworks/OpenGL.framework/Headers \
/System/Library/Frameworks/AGL.framework/Headers/
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 2ed708e085..6bf1380716 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -200,7 +200,9 @@ CMAKE_QT5_MODULE_DEPS = $$join(lib_deps, ";")
CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
-CMAKE_QT_STEM = Qt$$QT_MAJOR_VERSION$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}
+# TARGET here is the one changed at the end of qt_module.prf,
+# which already contains the Qt5 prefix and QT_LIBINFIX suffix
+CMAKE_QT_STEM = $${TARGET}
mac {
!isEmpty(CMAKE_STATIC_TYPE) {
diff --git a/mkspecs/features/file_copies.prf b/mkspecs/features/file_copies.prf
index 58e07bd393..8a718d8a81 100644
--- a/mkspecs/features/file_copies.prf
+++ b/mkspecs/features/file_copies.prf
@@ -44,7 +44,9 @@ for (cp, COPIES) {
$${pfx}.output = $$path/${QMAKE_FUNC_FILE_IN_qtStripSrcDir_$$cp}
}
$${pfx}.input = $${pfx}.files
- $${pfx}.commands = $(QINSTALL) ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
+ contains(TEMPLATE, "vc.*"): copycommand = $$QMAKE_QMAKE -install qinstall
+ else: copycommand = $(QINSTALL)
+ $${pfx}.commands = $$copycommand ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
$${pfx}.name = COPY ${QMAKE_FILE_IN}
$${pfx}.CONFIG = no_link no_clean target_predeps
QMAKE_EXTRA_COMPILERS += $${pfx}
diff --git a/mkspecs/features/mac/sdk.prf b/mkspecs/features/mac/sdk.prf
index 8360dd8b38..50a41657d8 100644
--- a/mkspecs/features/mac/sdk.prf
+++ b/mkspecs/features/mac/sdk.prf
@@ -33,10 +33,6 @@ QMAKE_MAC_SDK_PATH = $$xcodeSDKInfo(Path)
QMAKE_MAC_SDK_PLATFORM_PATH = $$xcodeSDKInfo(PlatformPath)
QMAKE_MAC_SDK_VERSION = $$xcodeSDKInfo(SDKVersion)
-sysrootified =
-for(val, QMAKE_INCDIR_OPENGL): sysrootified += $${QMAKE_MAC_SDK_PATH}$$val
-QMAKE_INCDIR_OPENGL = $$sysrootified
-
QMAKESPEC_NAME = $$basename(QMAKESPEC)
# Resolve SDK version of various tools
diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf
index 7ca65c92b3..e845bf1577 100644
--- a/mkspecs/features/qt_configure.prf
+++ b/mkspecs/features/qt_configure.prf
@@ -338,7 +338,7 @@ defineTest(qtConfParseCommandLine) {
qtConfAddWarning("Command line option -skip is only effective in top-level builds.")
skipOptionWarningAdded = 1
}
- $$qtConfGetNextCommandlineArg()
+ val = $$qtConfGetNextCommandlineArg()
next()
}
diff --git a/mkspecs/winrt-arm-msvc2019/qmake.conf b/mkspecs/winrt-arm-msvc2019/qmake.conf
new file mode 100644
index 0000000000..fe30a843eb
--- /dev/null
+++ b/mkspecs/winrt-arm-msvc2019/qmake.conf
@@ -0,0 +1,19 @@
+#
+# qmake configuration for winrt-arm-msvc2019
+#
+# Written for Microsoft Visual C++ 2019
+#
+
+include(../common/winrt_winphone/qmake.conf)
+DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 ARM __ARM__ __arm__
+
+QMAKE_CFLAGS += -FS
+QMAKE_CXXFLAGS += -FS
+QMAKE_LFLAGS += /MACHINE:ARM /NODEFAULTLIB:kernel32.lib
+
+QMAKE_LIBS += windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib
+
+VCPROJ_ARCH = ARM
+WINSDK_VER = 10.0
+WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/10.0/AppxManifest.xml.in
+WINRT_MANIFEST.architecture = arm
diff --git a/mkspecs/winrt-arm-msvc2019/qplatformdefs.h b/mkspecs/winrt-arm-msvc2019/qplatformdefs.h
new file mode 100644
index 0000000000..4222bca8e1
--- /dev/null
+++ b/mkspecs/winrt-arm-msvc2019/qplatformdefs.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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$
+**
+****************************************************************************/
+
+#include "../common/winrt_winphone/qplatformdefs.h"
diff --git a/mkspecs/winrt-arm64-msvc2019/qmake.conf b/mkspecs/winrt-arm64-msvc2019/qmake.conf
new file mode 100644
index 0000000000..8c16e93d26
--- /dev/null
+++ b/mkspecs/winrt-arm64-msvc2019/qmake.conf
@@ -0,0 +1,19 @@
+#
+# qmake configuration for winrt-arm64-msvc2019
+#
+# Written for Microsoft Visual C++ 2019
+#
+
+include(../common/winrt_winphone/qmake.conf)
+DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 arm64 __arm64__ __arm64__
+
+QMAKE_CFLAGS += -FS
+QMAKE_CXXFLAGS += -FS
+QMAKE_LFLAGS += /MACHINE:arm64 /NODEFAULTLIB:kernel32.lib
+
+QMAKE_LIBS += windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib
+
+VCPROJ_ARCH = arm64
+WINSDK_VER = 10.0
+WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/10.0/AppxManifest.xml.in
+WINRT_MANIFEST.architecture = arm64
diff --git a/mkspecs/winrt-arm64-msvc2019/qplatformdefs.h b/mkspecs/winrt-arm64-msvc2019/qplatformdefs.h
new file mode 100644
index 0000000000..4222bca8e1
--- /dev/null
+++ b/mkspecs/winrt-arm64-msvc2019/qplatformdefs.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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$
+**
+****************************************************************************/
+
+#include "../common/winrt_winphone/qplatformdefs.h"
diff --git a/mkspecs/winrt-x64-msvc2019/qmake.conf b/mkspecs/winrt-x64-msvc2019/qmake.conf
new file mode 100644
index 0000000000..0d3b6d2196
--- /dev/null
+++ b/mkspecs/winrt-x64-msvc2019/qmake.conf
@@ -0,0 +1,19 @@
+#
+# qmake configuration for winrt-x64-msvc2019
+#
+# Written for Microsoft Visual C++ 2019
+#
+
+include(../common/winrt_winphone/qmake.conf)
+DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X64 __X64__ __x64__
+
+QMAKE_CFLAGS += -FS
+QMAKE_CXXFLAGS += -FS
+QMAKE_LFLAGS += /MACHINE:X64 /NODEFAULTLIB:kernel32.lib
+
+QMAKE_LIBS += windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib
+
+VCPROJ_ARCH = x64
+WINSDK_VER = 10.0
+WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/10.0/AppxManifest.xml.in
+WINRT_MANIFEST.architecture = x64
diff --git a/mkspecs/winrt-x64-msvc2019/qplatformdefs.h b/mkspecs/winrt-x64-msvc2019/qplatformdefs.h
new file mode 100644
index 0000000000..4222bca8e1
--- /dev/null
+++ b/mkspecs/winrt-x64-msvc2019/qplatformdefs.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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$
+**
+****************************************************************************/
+
+#include "../common/winrt_winphone/qplatformdefs.h"
diff --git a/mkspecs/winrt-x86-msvc2019/qmake.conf b/mkspecs/winrt-x86-msvc2019/qmake.conf
new file mode 100644
index 0000000000..8948e20ab1
--- /dev/null
+++ b/mkspecs/winrt-x86-msvc2019/qmake.conf
@@ -0,0 +1,18 @@
+#
+# qmake configuration for winrt-x86-msvc2019
+#
+# Written for Microsoft Visual C++ 2019
+#
+
+include(../common/winrt_winphone/qmake.conf)
+DEFINES += WINAPI_FAMILY=WINAPI_FAMILY_PC_APP WINAPI_PARTITION_PHONE_APP=1 X86 __X86__ __x86__
+
+QMAKE_CFLAGS += -FS
+QMAKE_CXXFLAGS += -FS
+QMAKE_LFLAGS += /SAFESEH /MACHINE:X86 /NODEFAULTLIB:kernel32.lib
+
+QMAKE_LIBS += windowscodecs.lib WindowsApp.lib runtimeobject.lib OneCore.lib
+VCPROJ_ARCH = Win32
+WINSDK_VER = 10.0
+WINRT_MANIFEST = $$PWD/../common/winrt_winphone/manifests/10.0/AppxManifest.xml.in
+WINRT_MANIFEST.architecture = x86
diff --git a/mkspecs/winrt-x86-msvc2019/qplatformdefs.h b/mkspecs/winrt-x86-msvc2019/qplatformdefs.h
new file mode 100644
index 0000000000..4222bca8e1
--- /dev/null
+++ b/mkspecs/winrt-x86-msvc2019/qplatformdefs.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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$
+**
+****************************************************************************/
+
+#include "../common/winrt_winphone/qplatformdefs.h"
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 7762e47f41..ab261d02f1 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -532,7 +532,7 @@ MakefileGenerator::init()
QStack<int> state;
enum { IN_CONDITION, MET_CONDITION, PENDING_CONDITION };
for (int count = 1; !in.atEnd(); ++count) {
- QString line = QString::fromUtf8(in.readLine());
+ QString line = QString::fromLatin1(in.readLine());
if (line.startsWith("!!IF ")) {
if (state.isEmpty() || state.top() == IN_CONDITION) {
QString test = line.mid(5, line.length()-(5+1));
@@ -578,7 +578,7 @@ MakefileGenerator::init()
contents += project->expand(line, in.fileName(), count);
}
}
- contentBytes = contents.toUtf8();
+ contentBytes = contents.toLatin1();
}
QFile out(outn);
QFileInfo outfi(out);
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 713a55d16b..be0b67a9e6 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1350,7 +1350,7 @@ void VcprojGenerator::initWinDeployQtTool()
// structure manually by invoking windeployqt a second time, so that
// the MDILXapCompile call succeeds and deployment continues.
conf.windeployqt.CommandLine += commandLine
- + QStringLiteral(" -list relative -dir \"$(MSBuildProjectDirectory)\" \"$(OutDir)\\$(TargetName).exe\" > ")
+ + QStringLiteral(" -list relative -dir \"$(MSBuildProjectDirectory)\" \"$(OutDir)\\$(TargetFileName)\" > ")
+ MakefileGenerator::shellQuote(conf.windeployqt.Record);
conf.windeployqt.config = &vcProject.Configuration;
conf.windeployqt.ExcludedFromBuild = false;
@@ -1447,6 +1447,7 @@ void VcprojGenerator::initTranslationFiles()
vcProject.TranslationFiles.Guid = _GUIDTranslationFiles;
vcProject.TranslationFiles.addFiles(project->values("TRANSLATIONS"));
+ vcProject.TranslationFiles.addFiles(project->values("EXTRA_TRANSLATIONS"));
vcProject.TranslationFiles.Project = this;
vcProject.TranslationFiles.Config = &(vcProject.Configuration);
@@ -1569,7 +1570,7 @@ void VcprojGenerator::initExtraCompilerOutputs()
const ProStringList &tmp_in = project->values(project->first(ProKey(*it + ".input")).toKey());
for (int i = 0; i < tmp_in.count(); ++i) {
const QString &filename = tmp_in.at(i).toQString();
- if (extraCompilerSources.contains(filename))
+ if (extraCompilerSources.contains(filename) && !otherFiltersContain(filename))
extraCompile.addFile(Option::fixPathToTargetOS(
replaceExtraCompilerVariables(filename, tmp_out, QString(), NoShell), false));
}
@@ -1585,7 +1586,7 @@ void VcprojGenerator::initExtraCompilerOutputs()
const ProStringList &tmp_in = project->values(inputVar.toKey());
for (int i = 0; i < tmp_in.count(); ++i) {
const QString &filename = tmp_in.at(i).toQString();
- if (extraCompilerSources.contains(filename))
+ if (extraCompilerSources.contains(filename) && !otherFiltersContain(filename))
extraCompile.addFile(Option::fixPathToTargetOS(
replaceExtraCompilerVariables(filename, QString(), QString(), NoShell), false));
}
@@ -1599,6 +1600,28 @@ void VcprojGenerator::initExtraCompilerOutputs()
}
}
+bool VcprojGenerator::otherFiltersContain(const QString &fileName) const
+{
+ auto filterFileMatches = [&fileName] (const VCFilterFile &ff)
+ {
+ return ff.file == fileName;
+ };
+ for (const VCFilter *filter : { &vcProject.RootFiles,
+ &vcProject.SourceFiles,
+ &vcProject.HeaderFiles,
+ &vcProject.GeneratedFiles,
+ &vcProject.LexYaccFiles,
+ &vcProject.TranslationFiles,
+ &vcProject.FormFiles,
+ &vcProject.ResourceFiles,
+ &vcProject.DeploymentFiles,
+ &vcProject.DistributionFiles}) {
+ if (std::any_of(filter->Files.cbegin(), filter->Files.cend(), filterFileMatches))
+ return true;
+ }
+ return false;
+}
+
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
index 6af5ec7007..0b9770e962 100644
--- a/qmake/generators/win32/msvc_vcproj.h
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -131,6 +131,7 @@ private:
ProString firstInputFileName(const ProString &extraCompilerName) const;
QString firstExpandedOutputFileName(const ProString &extraCompilerName);
void createCustomBuildToolFakeFile(const QString &cbtFilePath, const QString &realOutFilePath);
+ bool otherFiltersContain(const QString &fileName) const;
friend class VCFilter;
};
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index 6046e5791e..208af1327f 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -84,6 +84,7 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
if (impexts.isEmpty())
impexts = project->values("QMAKE_EXTENSION_STATICLIB");
QList<QMakeLocalFileName> dirs;
+ int libidx = 0;
for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
dirs.append(QMakeLocalFileName(dlib.toQString()));
static const char * const lflags[] = { "LIBS", "LIBS_PRIVATE",
@@ -96,11 +97,12 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
LibFlagType type = parseLibFlag(opt, &arg);
if (type == LibFlagPath) {
QMakeLocalFileName lp(arg.toQString());
- if (dirs.contains(lp)) {
+ int idx = dirs.indexOf(lp);
+ if (idx >= 0 && idx < libidx) {
it = l.erase(it);
continue;
}
- dirs.append(lp);
+ dirs.insert(libidx++, lp);
(*it) = "-L" + lp.real();
} else if (type == LibFlagLib) {
QString lib = arg.toQString();
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index 4b87c25787..350c6eee96 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -346,7 +346,9 @@ public class QtActivityDelegate
}
} else if ((inputHints & ImhHiddenText) != 0) {
inputType |= android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD;
- } else if ((inputHints & ImhSensitiveData) != 0 || (inputHints & ImhNoPredictiveText) != 0) {
+ } else if ((inputHints & ImhSensitiveData) != 0 ||
+ ((inputHints & ImhNoPredictiveText) != 0 &&
+ System.getenv("QT_ANDROID_ENABLE_WORKAROUND_TO_DISABLE_PREDICTIVE_TEXT") != null)) {
inputType |= android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
}
diff --git a/src/android/java/res/values-el/strings.xml b/src/android/java/res/values-el/strings.xml
index 3cab212f2b..42b2b3b49d 100644
--- a/src/android/java/res/values-el/strings.xml
+++ b/src/android/java/res/values-el/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Δεν ήταν δυνατή η εύρεση της υπηρεσίας Ministro. Δεν είναι δυνατή η εκκίνηση της εφαρμογής.</string>
<string name="ministro_needed_msg">Η εφαρμογή απαιτεί την υπηρεσία Ministro. Να εγκατασταθεί η υπηρεσία?</string>
<string name="fatal_error_msg">Παρουσιάστηκε ένα κρίσιμο σφάλμα και η εφαρμογή δεν μπορεί να συνεχίσει.</string>
+ <string name="unsupported_android_version">Αυτή η έκδοση του Android δεν υποστηρίζεται.</string>
</resources>
diff --git a/src/android/java/res/values-es/strings.xml b/src/android/java/res/values-es/strings.xml
index cf0b54d0b0..1da33a6444 100644
--- a/src/android/java/res/values-es/strings.xml
+++ b/src/android/java/res/values-es/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Servicio Ministro inesistente. Imposible ejecutar la aplicación.</string>
<string name="ministro_needed_msg">Esta aplicación requiere el servicio Ministro. Instalarlo?</string>
<string name="fatal_error_msg">La aplicación ha causado un error grave y no es posible continuar.</string>
+ <string name="unsupported_android_version">Esta versión de Android no es compatible.</string>
</resources>
diff --git a/src/android/java/res/values-et/strings.xml b/src/android/java/res/values-et/strings.xml
index d55a3c1471..9620fd2bc8 100644
--- a/src/android/java/res/values-et/strings.xml
+++ b/src/android/java/res/values-et/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Ei suuda leida Ministro teenust.\nProgrammi ei saa käivitada.</string>
<string name="ministro_needed_msg">See programm vajab Ministro teenust.\nKas soovite paigaldada?</string>
<string name="fatal_error_msg">Programmiga juhtus fataalne viga.\nKahjuks ei saa jätkata.</string>
+ <string name="unsupported_android_version">Seda Androidi versiooni ei toetata.</string>
</resources>
diff --git a/src/android/java/res/values-fa/strings.xml b/src/android/java/res/values-fa/strings.xml
index a8d1b87444..d1ee06118a 100644
--- a/src/android/java/res/values-fa/strings.xml
+++ b/src/android/java/res/values-fa/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">سرویس Ministro را پیدا نمی‌کند. برنامه نمی‌تواند آغاز شود.</string>
<string name="ministro_needed_msg">این نرم‌افزار به سرویس Ministro احتیاج دارد. آیا دوست دارید آن را نصب کنید؟</string>
<string name="fatal_error_msg">خطایی اساسی در برنامه‌تان رخ داد و اجرای برنامه نمی‌تواند ادامه یابد.</string>
+ <string name="unsupported_android_version">این نسخه از Android پشتیبانی نمی شود</string>
</resources>
diff --git a/src/android/java/res/values-id/strings.xml b/src/android/java/res/values-in/strings.xml
index aaa5bda0de..b25f568ee9 100644
--- a/src/android/java/res/values-id/strings.xml
+++ b/src/android/java/res/values-in/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Layanan Ministro tidak bisa ditemukan.\nAplikasi tidak bisa dimulai.</string>
<string name="ministro_needed_msg">Aplikasi ini membutuhkan layanan Ministro. Apakah Anda ingin menginstalnya?</string>
<string name="fatal_error_msg">Aplikasi Anda mengalami kesalahan fatal dan tidak dapat melanjutkan.</string>
+ <string name="unsupported_android_version">Versi Android ini tidak didukung.</string>
</resources>
diff --git a/src/android/java/res/values-it/strings.xml b/src/android/java/res/values-it/strings.xml
index 4773419c44..9ba5fe2b1c 100644
--- a/src/android/java/res/values-it/strings.xml
+++ b/src/android/java/res/values-it/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Servizio Ministro inesistente. Impossibile eseguire \nl\'applicazione.</string>
<string name="ministro_needed_msg">Questa applicazione richiede il servizio Ministro.Installarlo?</string>
<string name="fatal_error_msg">L\'applicazione ha provocato un errore grave e non puo\' continuare.</string>
+ <string name="unsupported_android_version">Questa versione di Android non è supportata.</string>
</resources>
diff --git a/src/android/java/res/values-ja/strings.xml b/src/android/java/res/values-ja/strings.xml
index ba1cfda9ec..40da7dce48 100644
--- a/src/android/java/res/values-ja/strings.xml
+++ b/src/android/java/res/values-ja/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Ministroサービスが見つかりません。\nアプリケーションが起動できません。</string>
<string name="ministro_needed_msg">このアプリケーションにはMinistroサービスが必要です。 インストールしてもよろしいですか?</string>
<string name="fatal_error_msg">アプリケーションで致命的なエラーが発生したため続行できません。</string>
+ <string name="unsupported_android_version">このバージョンのAndroidはサポートされていません。</string>
</resources>
diff --git a/src/android/java/res/values-ms/strings.xml b/src/android/java/res/values-ms/strings.xml
index 6e3952eaec..bd27890eb2 100644
--- a/src/android/java/res/values-ms/strings.xml
+++ b/src/android/java/res/values-ms/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Tidak jumpa servis Ministro.\nAplikasi tidak boleh dimulakan.</string>
<string name="ministro_needed_msg">Aplikasi ini memerlukan servis Ministro. Adakah anda ingin pasang servis itu?</string>
<string name="fatal_error_msg">Aplikasi anda menemui ralat muat dan tidak boleh diteruskan.</string>
+ <string name="unsupported_android_version">Versi Android ini tidak disokong.</string>
</resources>
diff --git a/src/android/java/res/values-nb/strings.xml b/src/android/java/res/values-nb/strings.xml
index 8a550e99a2..53529b7f52 100644
--- a/src/android/java/res/values-nb/strings.xml
+++ b/src/android/java/res/values-nb/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Kan ikke finne tjenesten Ministro. Applikasjonen kan ikke starte.</string>
<string name="ministro_needed_msg">Denne applikasjonen krever tjenesten Ministro. Vil du installere denne?</string>
<string name="fatal_error_msg">Applikasjonen fikk en kritisk feil og kan ikke fortsette</string>
+ <string name="unsupported_android_version">Denne versjonen av Android støttes ikke.</string>
</resources>
diff --git a/src/android/java/res/values-nl/strings.xml b/src/android/java/res/values-nl/strings.xml
index 8a45a724ff..7e54587f61 100644
--- a/src/android/java/res/values-nl/strings.xml
+++ b/src/android/java/res/values-nl/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">De Ministro service is niet gevonden.\nDe applicatie kan niet starten.</string>
<string name="ministro_needed_msg">Deze applicatie maakt gebruik van de Ministro service. Wilt u deze installeren?</string>
<string name="fatal_error_msg">Er is een fatale fout in de applicatie opgetreden. De applicatie kan niet verder gaan.</string>
+ <string name="unsupported_android_version">Deze versie van Android wordt niet ondersteund.</string>
</resources>
diff --git a/src/android/java/res/values-pl/strings.xml b/src/android/java/res/values-pl/strings.xml
index 9fefc92dcd..e7feb01392 100644
--- a/src/android/java/res/values-pl/strings.xml
+++ b/src/android/java/res/values-pl/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Usługa Ministro nie została znaleziona.\nAplikacja nie może zostać uruchomiona.</string>
<string name="ministro_needed_msg">Aplikacja wymaga usługi Ministro. Czy chcesz ją zainstalować?</string>
<string name="fatal_error_msg">Wystąpił błąd krytyczny. Aplikacja zostanie zamknięta.</string>
+ <string name="unsupported_android_version">Ta wersja Androida nie jest obsługiwana.</string>
</resources>
diff --git a/src/android/java/res/values-pt-rBR/strings.xml b/src/android/java/res/values-pt-rBR/strings.xml
index 67ac3f9f98..4bac77c784 100644
--- a/src/android/java/res/values-pt-rBR/strings.xml
+++ b/src/android/java/res/values-pt-rBR/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Não foi possível encontrar o serviço Ministro.\nA aplicação não pode iniciar.</string>
<string name="ministro_needed_msg">Essa aplicação requer o serviço Ministro. Gostaria de instalá-lo?</string>
<string name="fatal_error_msg">Sua aplicação encontrou um erro fatal e não pode continuar.</string>
+ <string name="unsupported_android_version">Esta versão do Android não é suportada.</string>
</resources>
diff --git a/src/android/java/res/values-ro/strings.xml b/src/android/java/res/values-ro/strings.xml
index fef52ad3bd..d55c5b5c38 100644
--- a/src/android/java/res/values-ro/strings.xml
+++ b/src/android/java/res/values-ro/strings.xml
@@ -3,5 +3,5 @@
<string name="ministro_not_found_msg">Serviciul Ministro nu poate fi găsit.\nAplicaţia nu poate porni.</string>
<string name="ministro_needed_msg">Această aplicaţie necesită serviciul Ministro.\nDoriţi să-l instalaţi?</string>
<string name="fatal_error_msg">Aplicaţia dumneavoastră a întâmpinat o eroare fatală şi nu poate continua.</string>
- <string name="unsupported_android_version">Versiune Android nesuportată.</string>
+ <string name="unsupported_android_version">Această versiune de Android nu este suportată.</string>
</resources>
diff --git a/src/android/java/res/values-rs/strings.xml b/src/android/java/res/values-rs/strings.xml
index 3194ce9022..2a1e8284ce 100644
--- a/src/android/java/res/values-rs/strings.xml
+++ b/src/android/java/res/values-rs/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Ministro servise nije pronađen. Aplikacija ne može biti pokrenuta.</string>
<string name="ministro_needed_msg">Ova aplikacija zahteva Ministro servis. Želite li da ga instalirate?</string>
<string name="fatal_error_msg">Vaša aplikacija je naišla na fatalnu grešku i ne može nastaviti sa radom.</string>
+ <string name="unsupported_android_version">Ova verzija Android-a nije podržana.</string>
</resources>
diff --git a/src/android/java/res/values-ru/strings.xml b/src/android/java/res/values-ru/strings.xml
index d3cee80f9d..ec853d22f9 100644
--- a/src/android/java/res/values-ru/strings.xml
+++ b/src/android/java/res/values-ru/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">Сервис Ministro не найден.\nПриложение нельзя запустить.</string>
<string name="ministro_needed_msg">Этому приложению необходим сервис Ministro. Вы хотите его установить?</string>
<string name="fatal_error_msg">Ваше приложение столкнулось с фатальной ошибкой и не может более работать.</string>
+ <string name="unsupported_android_version">Эта версия Android не поддерживается.</string>
</resources>
diff --git a/src/android/java/res/values-zh-rCN/strings.xml b/src/android/java/res/values-zh-rCN/strings.xml
index 2eb1269880..58cdd89946 100644
--- a/src/android/java/res/values-zh-rCN/strings.xml
+++ b/src/android/java/res/values-zh-rCN/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">无法找到Ministro服务。\n应用程序无法启动。</string>
<string name="ministro_needed_msg">此应用程序需要Ministro服务。您想安装它吗?</string>
<string name="fatal_error_msg">您的应用程序遇到一个致命错误导致它无法继续。</string>
+ <string name="unsupported_android_version">这个版本的安卓系统不被支持。</string>
</resources>
diff --git a/src/android/java/res/values-zh-rTW/strings.xml b/src/android/java/res/values-zh-rTW/strings.xml
index f6e68efa52..81d2bebdee 100644
--- a/src/android/java/res/values-zh-rTW/strings.xml
+++ b/src/android/java/res/values-zh-rTW/strings.xml
@@ -3,4 +3,5 @@
<string name="ministro_not_found_msg">無法找到Ministro服務。\n應用程序無法啟動。</string>
<string name="ministro_needed_msg">此應用程序需要Ministro服務。您想安裝它嗎?</string>
<string name="fatal_error_msg">您的應用程序遇到一個致命錯誤導致它無法繼續。</string>
+ <string name="unsupported_android_version">這個版本的安卓系統不被支持。</string>
</resources>
diff --git a/src/android/java/res/values/strings.xml b/src/android/java/res/values/strings.xml
index 95b3385924..0110948dcf 100644
--- a/src/android/java/res/values/strings.xml
+++ b/src/android/java/res/values/strings.xml
@@ -4,5 +4,5 @@
<string name="ministro_not_found_msg">Can\'t find Ministro service.\nThe application can\'t start.</string>
<string name="ministro_needed_msg">This application requires Ministro service. Would you like to install it?</string>
<string name="fatal_error_msg">Your application encountered a fatal error and cannot continue.</string>
- <string name="unsupported_android_version">Unsupported Android version.</string>
+ <string name="unsupported_android_version">This version of Android is not supported.</string>
</resources>
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp
index c8c5f694c6..2fa4f88011 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qscopeguard.cpp
@@ -57,7 +57,7 @@ void myComplexCodeWithMultipleReturnPoints(int v)
if (v == -1)
return;
- int v2 = code_that_might_through_exceptions();
+ int v2 = code_that_might_throw_exceptions();
if (v2 == -1)
return;
diff --git a/src/corelib/doc/snippets/signalsandslots/lcdnumber.h b/src/corelib/doc/snippets/signalsandslots/lcdnumber.h
index fbd31b08cf..b311586e8f 100644
--- a/src/corelib/doc/snippets/signalsandslots/lcdnumber.h
+++ b/src/corelib/doc/snippets/signalsandslots/lcdnumber.h
@@ -69,7 +69,7 @@ class LcdNumber : public QFrame
//! [6]
public:
//! [6] //! [7]
- LcdNumber(QWidget *parent = 0);
+ LcdNumber(QWidget *parent = nullptr);
//! [7]
//! [8]
diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
index fcf091458a..85fe4df2ce 100644
--- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
+++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
@@ -330,7 +330,7 @@
arguments can have default values. Consider QObject::destroyed():
\code
- void destroyed(QObject* = 0);
+ void destroyed(QObject* = nullptr);
\endcode
When a QObject is deleted, it emits this QObject::destroyed()
@@ -339,7 +339,7 @@
A suitable slot signature might be:
\code
- void objectDestroyed(QObject* obj = 0);
+ void objectDestroyed(QObject* obj = nullptr);
\endcode
To connect the signal to the slot, we use QObject::connect().
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index a4d132a4f4..029357ff43 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -131,7 +131,7 @@ qtPrepareTool(QMAKE_QFLOAT16_TABLES, qfloat16-tables)
qfloat16_tables.commands = $$QMAKE_QFLOAT16_TABLES ${QMAKE_FILE_OUT}
qfloat16_tables.output = global/qfloat16tables.cpp
-qfloat16_tables.depends = $$QMAKE_QFLOAT16_TABLES
+qfloat16_tables.depends = $$QMAKE_QFLOAT16_TABLES_EXE
qfloat16_tables.input = QMAKE_QFLOAT16_TABLES_GENERATE
qfloat16_tables.variable_out = SOURCES
QMAKE_EXTRA_COMPILERS += qfloat16_tables
diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h
index 489e250087..91e3144300 100644
--- a/src/corelib/io/qloggingcategory.h
+++ b/src/corelib/io/qloggingcategory.h
@@ -120,15 +120,30 @@ private:
return category; \
}
-#define qCDebug(category, ...) \
+#if !defined(QT_NO_DEBUG_OUTPUT)
+# define qCDebug(category, ...) \
for (bool qt_category_enabled = category().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).debug(__VA_ARGS__)
-#define qCInfo(category, ...) \
+#else
+# define qCDebug(category, ...) QT_NO_QDEBUG_MACRO()
+#endif
+
+#if !defined(QT_NO_INFO_OUTPUT)
+# define qCInfo(category, ...) \
for (bool qt_category_enabled = category().isInfoEnabled(); qt_category_enabled; qt_category_enabled = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).info(__VA_ARGS__)
-#define qCWarning(category, ...) \
+#else
+# define qCInfo(category, ...) QT_NO_QDEBUG_MACRO()
+#endif
+
+#if !defined(QT_NO_WARNING_OUTPUT)
+# define qCWarning(category, ...) \
for (bool qt_category_enabled = category().isWarningEnabled(); qt_category_enabled; qt_category_enabled = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).warning(__VA_ARGS__)
+#else
+# define qCWarning(category, ...) QT_NO_QDEBUG_MACRO()
+#endif
+
#define qCCritical(category, ...) \
for (bool qt_category_enabled = category().isCriticalEnabled(); qt_category_enabled; qt_category_enabled = false) \
QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, category().categoryName()).critical(__VA_ARGS__)
@@ -144,26 +159,28 @@ private:
}
// check for enabled category inside QMessageLogger.
-#define qCDebug qDebug
-#define qCInfo qInfo
-#define qCWarning qWarning
-#define qCCritical qCritical
-
-#endif // Q_COMPILER_VARIADIC_MACROS || defined(Q_MOC_RUN)
-
-#if defined(QT_NO_DEBUG_OUTPUT)
-# undef qCDebug
+#if !defined(QT_NO_DEBUG_OUTPUT)
+# define qCDebug qDebug
+#else
# define qCDebug(category) QT_NO_QDEBUG_MACRO()
#endif
-#if defined(QT_NO_INFO_OUTPUT)
-# undef qCInfo
+
+#if !defined(QT_NO_INFO_OUTPUT)
+# define qCInfo qInfo
+#else
# define qCInfo(category) QT_NO_QDEBUG_MACRO()
#endif
-#if defined(QT_NO_WARNING_OUTPUT)
-# undef qCWarning
+
+#if !defined(QT_NO_WARNING_OUTPUT)
+# define qCWarning qWarning
+#else
# define qCWarning(category) QT_NO_QDEBUG_MACRO()
#endif
+#define qCCritical qCritical
+
+#endif // Q_COMPILER_VARIADIC_MACROS || defined(Q_MOC_RUN)
+
QT_END_NAMESPACE
#endif // QLOGGINGCATEGORY_H
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index cb4b2f9f91..3ba86063e3 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -362,16 +362,22 @@ void QProcessPrivate::destroyPipe(Q_PIPE pipe[2])
}
}
+template <class T>
+void deleteWorker(T *&worker)
+{
+ if (!worker)
+ return;
+ worker->stop();
+ worker->deleteLater();
+ worker = nullptr;
+}
+
void QProcessPrivate::closeChannel(Channel *channel)
{
- if (channel == &stdinChannel) {
- delete stdinChannel.writer;
- stdinChannel.writer = 0;
- } else if (channel->reader) {
- channel->reader->stop();
- channel->reader->deleteLater();
- channel->reader = 0;
- }
+ if (channel == &stdinChannel)
+ deleteWorker(channel->writer);
+ else
+ deleteWorker(channel->reader);
destroyPipe(channel->pipe);
}
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 0d2bd72d75..ed61c4aca0 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -2167,6 +2167,9 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
\snippet settings/settings.cpp 15
+ Note that type information is not preserved when reading settings from INI
+ files; all values will be returned as QString.
+
The \l{tools/settingseditor}{Settings Editor} example lets you
experiment with different settings location and with fallbacks
turned on or off.
@@ -2448,7 +2451,10 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
On 32-bit Windows or from a 64-bit application on 64-bit Windows,
this works the same as specifying NativeFormat.
This enum value was added in Qt 5.7.
- \value IniFormat Store the settings in INI files.
+ \value IniFormat Store the settings in INI files. Note that type information
+ is not preserved when reading settings from INI files;
+ all values will be returned as QString.
+
\value InvalidFormat Special value returned by registerFormat().
\omitvalue CustomFormat1
\omitvalue CustomFormat2
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 7e3be9ef36..35bb465a04 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -912,16 +912,20 @@ QTemporaryFile *QTemporaryFile::createNativeFile(QFile &file)
file.open(QIODevice::ReadOnly);
//dump data
QTemporaryFile *ret = new QTemporaryFile;
- ret->open();
- file.seek(0);
- char buffer[1024];
- while(true) {
- qint64 len = file.read(buffer, 1024);
- if(len < 1)
- break;
- ret->write(buffer, len);
+ if (ret->open()) {
+ file.seek(0);
+ char buffer[1024];
+ while (true) {
+ qint64 len = file.read(buffer, 1024);
+ if (len < 1)
+ break;
+ ret->write(buffer, len);
+ }
+ ret->seek(0);
+ } else {
+ delete ret;
+ ret = nullptr;
}
- ret->seek(0);
//restore
if(wasOpen)
file.seek(old_off);
diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp
index e78b2d1171..b048576f5b 100644
--- a/src/corelib/kernel/qcore_mac.cpp
+++ b/src/corelib/kernel/qcore_mac.cpp
@@ -65,6 +65,19 @@ QCFString::operator CFStringRef() const
#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
+bool AppleUnifiedLogger::willMirrorToStderr()
+{
+ // When running under Xcode or LLDB, one or more of these variables will
+ // be set, which triggers libsystem_trace.dyld to log messages to stderr
+ // as well, via_os_log_impl_mirror_to_stderr. Un-setting these variables
+ // is not an option, as that would silence normal NSLog or os_log calls,
+ // so instead we skip our own stderr output. See rdar://36919139.
+ static bool willMirror = qEnvironmentVariableIsSet("OS_ACTIVITY_DT_MODE")
+ || qEnvironmentVariableIsSet("ACTIVITY_LOG_STDERR")
+ || qEnvironmentVariableIsSet("CFLOG_FORCE_STDERR");
+ return willMirror;
+}
+
QT_MAC_WEAK_IMPORT(_os_log_default);
bool AppleUnifiedLogger::messageHandler(QtMsgType msgType, const QMessageLogContext &context,
const QString &message, const QString &optionalSubsystem)
@@ -103,15 +116,7 @@ bool AppleUnifiedLogger::messageHandler(QtMsgType msgType, const QMessageLogCont
// system from redacting our log message.
os_log_with_type(log, logType, "%{public}s", qPrintable(message));
- // When running under Xcode or LLDB, one or more of these variables will
- // be set, which triggers libsystem_trace.dyld to log messages to stderr
- // as well, via_os_log_impl_mirror_to_stderr. Un-setting these variables
- // is not an option, as that would silence normal NSLog or os_log calls,
- // so instead we skip our own stderr output. See rdar://36919139.
- static bool mirroredToStderr = qEnvironmentVariableIsSet("OS_ACTIVITY_DT_MODE")
- || qEnvironmentVariableIsSet("ACTIVITY_LOG_STDERR")
- || qEnvironmentVariableIsSet("CFLOG_FORCE_STDERR");
- return mirroredToStderr;
+ return willMirrorToStderr();
}
os_log_type_t AppleUnifiedLogger::logTypeForMessageType(QtMsgType msgType)
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index acb87f8a3c..f96e7358a2 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -202,6 +202,7 @@ class Q_CORE_EXPORT AppleUnifiedLogger
public:
static bool messageHandler(QtMsgType msgType, const QMessageLogContext &context, const QString &message,
const QString &subsystem = QString());
+ static bool willMirrorToStderr();
private:
static os_log_type_t logTypeForMessageType(QtMsgType msgType);
static os_log_t cachedLog(const QString &subsystem, const QString &category);
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index b6b4da3885..c637f0c1c9 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2668,9 +2668,9 @@ QStringList QCoreApplication::libraryPaths()
QStringList *app_libpaths = new QStringList;
coreappdata()->app_libpaths.reset(app_libpaths);
- const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
+ QString libPathEnv = qEnvironmentVariable("QT_PLUGIN_PATH");
if (!libPathEnv.isEmpty()) {
- QStringList paths = QFile::decodeName(libPathEnv).split(QDir::listSeparator(), QString::SkipEmptyParts);
+ QStringList paths = libPathEnv.split(QDir::listSeparator(), QString::SkipEmptyParts);
for (QStringList::const_iterator it = paths.constBegin(); it != paths.constEnd(); ++it) {
QString canonicalPath = QDir(*it).canonicalPath();
if (!canonicalPath.isEmpty()
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 0bddf89b15..b3b6b1be20 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -95,7 +95,7 @@ class QEventDispatcherWin32Private;
LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
- : threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0),
+ : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0),
getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0),
wakeUps(0), activateNotifiersPosted(false), winEventNotifierActivatedEvent(NULL)
{
@@ -552,7 +552,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
wakeUp(); // trigger a call to sendPostedEvents()
}
- d->interrupt = false;
+ d->interrupt.store(false);
emit awake();
bool canWait;
@@ -568,7 +568,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
pHandles = &d->winEventNotifierActivatedEvent;
}
QVarLengthArray<MSG> processedTimers;
- while (!d->interrupt) {
+ while (!d->interrupt.load()) {
MSG msg;
bool haveMessage;
@@ -649,7 +649,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
// still nothing - wait for message or signalled objects
canWait = (!retVal
- && !d->interrupt
+ && !d->interrupt.load()
&& (flags & QEventLoop::WaitForMoreEvents));
if (canWait) {
emit aboutToBlock();
@@ -1016,7 +1016,7 @@ void QEventDispatcherWin32::wakeUp()
void QEventDispatcherWin32::interrupt()
{
Q_D(QEventDispatcherWin32);
- d->interrupt = true;
+ d->interrupt.store(true);
wakeUp();
}
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index a7ed8dda8a..3bb618153b 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -165,8 +165,7 @@ public:
DWORD threadId;
- bool interrupt;
- bool closingDown;
+ QAtomicInt interrupt;
// internal window handle used for socketnotifiers/timers/etc
HWND internalHwnd;
@@ -193,9 +192,11 @@ public:
void postActivateSocketNotifiers();
void doWsaAsyncSelect(int socket, long event);
+ bool closingDown = false;
+
+ bool winEventNotifierListModified = false;
HANDLE winEventNotifierActivatedEvent;
QList<QWinEventNotifier *> winEventNotifierList;
- bool winEventNotifierListModified = false;
void activateEventNotifier(QWinEventNotifier * wen);
QList<MSG> queuedUserInputEvents;
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index b4e885e407..cf838b6947 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -2171,8 +2171,10 @@ void QObject::removeEventFilter(QObject *obj)
Note that entering and leaving a new event loop (e.g., by opening a modal
dialog) will \e not perform the deferred deletion; for the object to be
- deleted, the control must return to the event loop from which
- deleteLater() was called.
+ deleted, the control must return to the event loop from which deleteLater()
+ was called. This does not apply to objects deleted while a previous, nested
+ event loop was still running: the Qt event loop will delete those objects
+ as soon as the new nested event loop starts.
\b{Note:} It is safe to call this function more than once; when the
first deferred deletion event is delivered, any pending events for the
diff --git a/src/corelib/serialization/qcborstream.cpp b/src/corelib/serialization/qcborstream.cpp
index d7b81ae324..d062cff067 100644
--- a/src/corelib/serialization/qcborstream.cpp
+++ b/src/corelib/serialization/qcborstream.cpp
@@ -404,7 +404,7 @@ QDebug operator<<(QDebug dbg, QCborKnownTags tag)
\value IllegalSimpleType The CBOR stream contains a Simple Type encoded incorrectly (data is
corrupt and the error is not recoverable).
\value InvalidUtf8String The CBOR stream contains a text string that does not decode properly
- as UTF (data is corrupt and the error is not recoverable).
+ as UTF-8 (data is corrupt and the error is not recoverable).
\value DataTooLarge CBOR string, map or array is too big and cannot be parsed by Qt
(internal limitation, but the error is not recoverable).
\value NestingTooDeep Too many levels of arrays or maps encountered while processing the
@@ -413,6 +413,24 @@ QDebug operator<<(QDebug dbg, QCborKnownTags tag)
support (internal limitation, but the error is not recoverable).
*/
+// Convert from CborError to QCborError.
+//
+// Centralized in a function in case we need to make more adjustments in the
+// future.
+static QCborError fromCborError(CborError err)
+{
+ return { QCborError::Code(int(err)) };
+}
+
+// Convert to CborError from QCborError.
+//
+// Centralized in a function in case we need to make more adjustments in the
+// future.
+static CborError toCborError(QCborError c)
+{
+ return CborError(int(c.c));
+}
+
/*!
\variable QCborError::c
\internal
@@ -483,8 +501,8 @@ QString QCborError::toString() const
return QStringLiteral("Internal limitation: unsupported type");
}
- // get the error from TinyCBOR
- CborError err = CborError(int(c));
+ // get the error string from TinyCBOR
+ CborError err = toCborError(*this);
return QString::fromLatin1(cbor_error_string(err));
}
@@ -1823,8 +1841,7 @@ public:
if (err != CborErrorUnexpectedEOF)
corrupt = true;
- // our error codes are the same (for now)
- lastError = { QCborError::Code(err) };
+ lastError = fromCborError(err);
}
void updateBufferAfterString(qsizetype offset, qsizetype size)
@@ -1934,7 +1951,7 @@ inline void QCborStreamReader::preparse()
// for negative integer and we don't have separate types for Boolean,
// Null and Undefined).
if (type_ == CborBooleanType || type_ == CborNullType || type_ == CborUndefinedType) {
- type_ = SimpleType;
+ type_ = CborSimpleType;
value64 = quint8(d->buffer.at(d->bufferStart)) - CborSimpleType;
} else {
// Using internal TinyCBOR API!
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 05bc064005..b023ae9ed2 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -818,6 +818,16 @@ void QThread::quit()
}
+void QThread::exit(int returnCode)
+{
+ Q_D(QThread);
+ d->data->quitNow = true;
+ for (int i = 0; i < d->data->eventLoops.size(); ++i) {
+ QEventLoop *eventLoop = d->data->eventLoops.at(i);
+ eventLoop->exit(returnCode);
+ }
+}
+
bool QThread::wait(unsigned long time)
{
Q_UNUSED(time);
diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp
index 35142bb8b8..10cfdaa264 100644
--- a/src/corelib/tools/qcollator_win.cpp
+++ b/src/corelib/tools/qcollator_win.cpp
@@ -72,6 +72,8 @@ void QCollatorPrivate::init()
if (caseSensitivity == Qt::CaseInsensitive)
collator |= NORM_IGNORECASE;
+ // WINE does not support SORT_DIGITSASNUMBERS :-(
+ // (and its std::sort() crashes on bad comparisons, QTBUG-74209)
if (numericMode)
collator |= SORT_DIGITSASNUMBERS;
@@ -98,16 +100,36 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con
// Returns one of the following values if successful. To maintain the C runtime convention of
// comparing strings, the value 2 can be subtracted from a nonzero return value. Then, the
// meaning of <0, ==0, and >0 is consistent with the C runtime.
+ // [...] The function returns 0 if it does not succeed.
+ // https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-comparestringex#return-value
#ifndef USE_COMPARESTRINGEX
- return CompareString(d->localeID, d->collator,
- reinterpret_cast<const wchar_t*>(s1), len1,
- reinterpret_cast<const wchar_t*>(s2), len2) - 2;
+ const int ret = CompareString(d->localeID, d->collator,
+ reinterpret_cast<const wchar_t*>(s1), len1,
+ reinterpret_cast<const wchar_t*>(s2), len2);
#else
- return CompareStringEx(LPCWSTR(d->localeName.utf16()), d->collator,
- reinterpret_cast<LPCWSTR>(s1), len1,
- reinterpret_cast<LPCWSTR>(s2), len2, NULL, NULL, 0) - 2;
+ const int ret = CompareStringEx(LPCWSTR(d->localeName.utf16()), d->collator,
+ reinterpret_cast<LPCWSTR>(s1), len1,
+ reinterpret_cast<LPCWSTR>(s2), len2,
+ nullptr, nullptr, 0);
#endif
+ if (Q_LIKELY(ret))
+ return ret - 2;
+
+ switch (DWORD error = GetLastError()) {
+ case ERROR_INVALID_FLAGS:
+ qWarning("Unsupported flags (%d) used in QCollator", int(d->collator));
+ break;
+ case ERROR_INVALID_PARAMETER:
+ qWarning("Invalid parameter for QCollator::compare()");
+ break;
+ default:
+ qWarning("Failed (%ld) comparison in QCollator::compare()", long(error));
+ break;
+ }
+ // We have no idea what to return, so pretend we think they're equal.
+ // At least that way we'll be consistent if we get the same values swapped ...
+ return 0;
}
int QCollator::compare(const QString &str1, const QString &str2) const
diff --git a/src/corelib/tools/qscopeguard.qdoc b/src/corelib/tools/qscopeguard.qdoc
index 70e13ab2fd..5a9b7fd210 100644
--- a/src/corelib/tools/qscopeguard.qdoc
+++ b/src/corelib/tools/qscopeguard.qdoc
@@ -33,10 +33,16 @@ QT_BEGIN_NAMESPACE
\class QScopeGuard
\since 5.12
\inmodule QtCore
- \brief Provides a scope guard for calling a function at the of
+ \brief Provides a scope guard for calling a function at the end of
a scope.
*/
+/*! \fn template <typename F> void QScopeGuard<F>::dismiss()
+
+ Disarms the scope guard, so that the function \e F will not be called at
+ the end of the scope.
+*/
+
/*!
\fn template <typename F> const QScopeGuard<F> qScopeGuard(F f)
\inmodule QtCore
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 63d44eb39c..d8bfb69a8b 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1047,6 +1047,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, size_t l)
__m128i nullmask = _mm_setzero_si128();
qptrdiff offset = 0;
+# if !defined(__OPTIMIZE_SIZE__)
// Using the PMOVMSKB instruction, we get two bits for each character
// we compare.
int retval;
@@ -1059,6 +1060,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, size_t l)
retval = uc[offset + idx / 2] - c[offset + idx / 2];
return true;
};
+# endif
// we're going to read uc[offset..offset+15] (32 bytes)
// and c[offset..offset+15] (16 bytes)
diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in
index 07869efd7d..84dbbfebd4 100644
--- a/src/gui/Qt5GuiConfigExtras.cmake.in
+++ b/src/gui/Qt5GuiConfigExtras.cmake.in
@@ -91,16 +91,29 @@ macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs)
endforeach()
!!ENDIF
foreach(_lib ${Libs})
- string(REGEX REPLACE "[^_A-Za-z0-9]" "_" _cmake_lib_name ${_lib})
+ if (IS_ABSOLUTE ${_lib})
+ get_filename_component(_libFile ${_lib} NAME_WE)
+ if (_libFile MATCHES \"^${CMAKE_SHARED_LIBRARY_PREFIX}(.*)\")
+ set(_libFile ${CMAKE_MATCH_1})
+ endif()
+ else()
+ set(_libFile ${_lib})
+ endif()
+
+ string(REGEX REPLACE "[^_A-Za-z0-9]" "_" _cmake_lib_name ${_libFile})
if (NOT TARGET Qt5::Gui_${_cmake_lib_name} AND NOT _Qt5Gui_${_cmake_lib_name}_LIBRARY_DONE)
- find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib}
+ if (IS_ABSOLUTE ${_lib})
+ set(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib})
+ else()
+ find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib}
!!IF !isEmpty(CROSS_COMPILE)
- PATHS \"${LibDir}\"
+ PATHS \"${LibDir}\"
!!IF !mac
- NO_DEFAULT_PATH
+ NO_DEFAULT_PATH
!!ENDIF
!!ENDIF
- )
+ )
+ endif()
!!IF mac
set(Qt5Gui_${_cmake_lib_name}_LIBRARY "${Qt5Gui_${_cmake_lib_name}_LIBRARY}/${_lib}")
if (NOT EXISTS "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
diff --git a/src/gui/configure.json b/src/gui/configure.json
index 44140bc7b6..e4f25ab313 100644
--- a/src/gui/configure.json
+++ b/src/gui/configure.json
@@ -448,7 +448,7 @@
],
"sources": [
{ "type": "pkgConfig", "args": "gl", "condition": "!config.darwin" },
- { "type": "makeSpec", "spec": "OPENGL" }
+ { "type": "openglMakeSpec" }
]
},
"opengl_es2": {
diff --git a/src/gui/configure.pri b/src/gui/configure.pri
index 1b95449a10..0db106597e 100644
--- a/src/gui/configure.pri
+++ b/src/gui/configure.pri
@@ -15,6 +15,17 @@ defineTest(qtConfLibrary_freetype) {
return(true)
}
+defineTest(qtConfLibrary_openglMakeSpec) {
+ darwin:sdk {
+ sysrootified =
+ for(val, QMAKE_INCDIR_OPENGL): sysrootified += $${QMAKE_MAC_SDK_PATH}$$val
+ QMAKE_INCDIR_OPENGL = $$sysrootified
+ }
+ $${1}.spec = OPENGL
+ !qtConfLibrary_makeSpec($$1, $$2): return(false)
+ return(true)
+}
+
# Check for Direct X shader compiler 'fxc'.
# Up to Direct X SDK June 2010 and for MinGW, this is pointed to by the
# DXSDK_DIR variable. Starting with Windows Kit 8, it is included in
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index be04513de6..9a6f879431 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -313,7 +313,7 @@ QOpenGLContext *qt_gl_global_share_context()
\section1 Context Resource Sharing
- Resources, such as framebuffer objects, textures, and vertex buffer objects
+ Resources such as textures and vertex buffer objects
can be shared between contexts. Use setShareContext() before calling
create() to specify that the contexts should share these resources.
QOpenGLContext internally keeps track of a QOpenGLContextGroup object which
diff --git a/src/gui/kernel/qplatformgraphicsbuffer.h b/src/gui/kernel/qplatformgraphicsbuffer.h
index 0aeef946e6..11566e1201 100644
--- a/src/gui/kernel/qplatformgraphicsbuffer.h
+++ b/src/gui/kernel/qplatformgraphicsbuffer.h
@@ -71,12 +71,14 @@ public:
TextureAccess = 0x04,
HWCompositor = 0x08
};
+ Q_ENUM(AccessType);
Q_DECLARE_FLAGS(AccessTypes, AccessType);
enum Origin {
OriginBottomLeft,
OriginTopLeft
};
+ Q_ENUM(Origin);
virtual ~QPlatformGraphicsBuffer();
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 5b32405f5e..7067ece1d8 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -695,13 +695,29 @@ QList<QTouchEvent::TouchPoint>
}
if (states == Qt::TouchPointReleased) {
- g_nextPointId = 1;
- g_pointIdMap->clear();
+ // All points on deviceId have been released.
+ // Remove all points associated with that device from g_pointIdMap.
+ // (On other devices, some touchpoints might still be pressed.
+ // But this function is only called with points from one device at a time.)
+ for (auto it = g_pointIdMap->begin(); it != g_pointIdMap->end();) {
+ if (it.key() >> 32 == quint64(deviceId))
+ it = g_pointIdMap->erase(it);
+ else
+ ++it;
+ }
+ if (g_pointIdMap->isEmpty())
+ g_nextPointId = 1;
}
return touchPoints;
}
+void QWindowSystemInterfacePrivate::clearPointIdMap()
+{
+ g_pointIdMap->clear();
+ g_nextPointId = 1;
+}
+
QList<QWindowSystemInterface::TouchPoint>
QWindowSystemInterfacePrivate::toNativeTouchPoints(const QList<QTouchEvent::TouchPoint>& pointList,
const QWindow *window)
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 9cb4e191cc..cea02fb8b7 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -537,6 +537,7 @@ public:
static QList<QWindowSystemInterface::TouchPoint>
toNativeTouchPoints(const QList<QTouchEvent::TouchPoint>& pointList,
const QWindow *window);
+ static void clearPointIdMap();
static void installWindowSystemEventHandler(QWindowSystemEventHandler *handler);
static void removeWindowSystemEventhandler(QWindowSystemEventHandler *handler);
diff --git a/src/gui/opengl/qopengltextureuploader.cpp b/src/gui/opengl/qopengltextureuploader.cpp
index 42e309b733..03b5cb6eb5 100644
--- a/src/gui/opengl/qopengltextureuploader.cpp
+++ b/src/gui/opengl/qopengltextureuploader.cpp
@@ -114,6 +114,18 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
externalFormat = GL_BGRA;
internalFormat = GL_RGBA;
pixelType = GL_UNSIGNED_INT_8_8_8_8_REV;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ // Without GL_UNSIGNED_INT_8_8_8_8_REV, BGRA only matches ARGB on little endian:
+ } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::BGRATextureFormat) && !sRgbBinding) {
+ // The GL_EXT_texture_format_BGRA8888 extension requires the internal format to match the external.
+ externalFormat = internalFormat = GL_BGRA;
+ pixelType = GL_UNSIGNED_BYTE;
+ } else if (context->isOpenGLES() && context->hasExtension(QByteArrayLiteral("GL_APPLE_texture_format_BGRA8888"))) {
+ // Is only allowed as an external format like OpenGL.
+ externalFormat = GL_BGRA;
+ internalFormat = GL_RGBA;
+ pixelType = GL_UNSIGNED_BYTE;
+#endif
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
GLint swizzle[4] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
@@ -125,25 +137,8 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
externalFormat = internalFormat = GL_RGBA;
pixelType = GL_UNSIGNED_BYTE;
} else {
-#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- // Without GL_UNSIGNED_INT_8_8_8_8_REV, BGRA only matches ARGB on little endian.
- if (funcs->hasOpenGLExtension(QOpenGLExtensions::BGRATextureFormat) && !sRgbBinding) {
- // The GL_EXT_texture_format_BGRA8888 extension requires the internal format to match the external.
- externalFormat = internalFormat = GL_BGRA;
- pixelType = GL_UNSIGNED_BYTE;
- } else if (context->isOpenGLES() && context->hasExtension(QByteArrayLiteral("GL_APPLE_texture_format_BGRA8888"))) {
- // Is only allowed as an external format like OpenGL.
- externalFormat = GL_BGRA;
- internalFormat = GL_RGBA;
- pixelType = GL_UNSIGNED_BYTE;
- } else {
- // No support for direct ARGB32 upload.
- break;
- }
-#else
- // Big endian requires GL_UNSIGNED_INT_8_8_8_8_REV for ARGB to match BGRA
+ // No support for direct ARGB32 upload.
break;
-#endif
}
targetFormat = image.format();
break;
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp
index a3dcb02e07..ddd1d997f2 100644
--- a/src/gui/painting/qbezier.cpp
+++ b/src/gui/painting/qbezier.cpp
@@ -333,7 +333,9 @@ static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qr
*shifted = QBezier::fromPoints(points_shifted[map[0]], points_shifted[map[1]],
points_shifted[map[2]], points_shifted[map[3]]);
- return good_offset(orig, shifted, offset, threshold);
+ if (np > 2)
+ return good_offset(orig, shifted, offset, threshold);
+ return Ok;
}
// This value is used to determine the length of control point vectors
@@ -432,7 +434,6 @@ redo:
} else if (res == Ok) {
++o;
--b;
- continue;
} else if (res == Circle && maxSegments - (o - curveSegments) >= 2) {
// add semi circle
if (addCircle(b, offset, o))
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp
index 52501880e4..b4014272f4 100644
--- a/src/gui/painting/qrasterizer.cpp
+++ b/src/gui/painting/qrasterizer.cpp
@@ -755,11 +755,9 @@ static inline int qSafeFloatToQ16Dot16(qreal x)
void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, bool squareCap)
{
- if (a == b || width == 0 || d->clipRect.isEmpty())
+ if (a == b || !(width > 0.0) || d->clipRect.isEmpty())
return;
- Q_ASSERT(width > 0.0);
-
QPointF pa = a;
QPointF pb = b;
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index 0e07b69868..102a776ed3 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -297,7 +297,7 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block)
QSyntaxHighlighter::QSyntaxHighlighter(QObject *parent)
: QObject(*new QSyntaxHighlighterPrivate, parent)
{
- if (parent->inherits("QTextEdit")) {
+ if (parent && parent->inherits("QTextEdit")) {
QTextDocument *doc = parent->property("document").value<QTextDocument *>();
if (doc)
setDocument(doc);
diff --git a/src/network/access/http2/hpacktable.cpp b/src/network/access/http2/hpacktable.cpp
index a90ee72d52..fddb5feca5 100644
--- a/src/network/access/http2/hpacktable.cpp
+++ b/src/network/access/http2/hpacktable.cpp
@@ -42,6 +42,7 @@
#include <QtCore/qdebug.h>
#include <algorithm>
+#include <cstddef>
#include <cstring>
#include <limits>
@@ -61,7 +62,7 @@ HeaderSize entry_size(const QByteArray &name, const QByteArray &value)
// for counting the number of references to the name and value would have
// 32 octets of overhead."
- const unsigned sum = unsigned(name.size()) + value.size();
+ const unsigned sum = unsigned(name.size() + value.size());
if (std::numeric_limits<unsigned>::max() - 32 < sum)
return HeaderSize();
return HeaderSize(true, quint32(sum + 32));
@@ -75,7 +76,7 @@ int compare(const QByteArray &lhs, const QByteArray &rhs)
if (const int minLen = std::min(lhs.size(), rhs.size())) {
// We use memcmp, since strings in headers are allowed
// to contain '\0'.
- const int cmp = std::memcmp(lhs.constData(), rhs.constData(), minLen);
+ const int cmp = std::memcmp(lhs.constData(), rhs.constData(), std::size_t(minLen));
if (cmp)
return cmp;
}
@@ -138,82 +139,6 @@ bool FieldLookupTable::SearchEntry::operator < (const SearchEntry &rhs)const
return offset > rhs.offset;
}
-// This data is from HPACK's specs and it's quite
-// conveniently sorted == works with binary search as it is.
-// Later this can probably change and instead of simple
-// vector we'll just reuse FieldLookupTable.
-// TODO: it makes sense to generate this table while ...
-// configuring/building Qt (some script downloading/parsing/generating
-// would be quite handy).
-const std::vector<HeaderField> &staticTable()
-{
- static std::vector<HeaderField> table = {
- {":authority", ""},
- {":method", "GET"},
- {":method", "POST"},
- {":path", "/"},
- {":path", "/index.html"},
- {":scheme", "http"},
- {":scheme", "https"},
- {":status", "200"},
- {":status", "204"},
- {":status", "206"},
- {":status", "304"},
- {":status", "400"},
- {":status", "404"},
- {":status", "500"},
- {"accept-charset", ""},
- {"accept-encoding", "gzip, deflate"},
- {"accept-language", ""},
- {"accept-ranges", ""},
- {"accept", ""},
- {"access-control-allow-origin", ""},
- {"age", ""},
- {"allow", ""},
- {"authorization", ""},
- {"cache-control", ""},
- {"content-disposition", ""},
- {"content-encoding", ""},
- {"content-language", ""},
- {"content-length", ""},
- {"content-location", ""},
- {"content-range", ""},
- {"content-type", ""},
- {"cookie", ""},
- {"date", ""},
- {"etag", ""},
- {"expect", ""},
- {"expires", ""},
- {"from", ""},
- {"host", ""},
- {"if-match", ""},
- {"if-modified-since", ""},
- {"if-none-match", ""},
- {"if-range", ""},
- {"if-unmodified-since", ""},
- {"last-modified", ""},
- {"link", ""},
- {"location", ""},
- {"max-forwards", ""},
- {"proxy-authenticate", ""},
- {"proxy-authorization", ""},
- {"range", ""},
- {"referer", ""},
- {"refresh", ""},
- {"retry-after", ""},
- {"server", ""},
- {"set-cookie", ""},
- {"strict-transport-security", ""},
- {"transfer-encoding", ""},
- {"user-agent", ""},
- {"vary", ""},
- {"via", ""},
- {"www-authenticate", ""}
- };
-
- return table;
-}
-
FieldLookupTable::FieldLookupTable(quint32 maxSize, bool use)
: maxTableSize(maxSize),
tableCapacity(maxSize),
@@ -296,12 +221,12 @@ void FieldLookupTable::evictEntry()
quint32 FieldLookupTable::numberOfEntries() const
{
- return quint32(staticTable().size()) + nDynamic;
+ return quint32(staticPart().size()) + nDynamic;
}
quint32 FieldLookupTable::numberOfStaticEntries() const
{
- return quint32(staticTable().size());
+ return quint32(staticPart().size());
}
quint32 FieldLookupTable::numberOfDynamicEntries() const
@@ -326,24 +251,18 @@ void FieldLookupTable::clearDynamicTable()
bool FieldLookupTable::indexIsValid(quint32 index) const
{
- return index && index <= staticTable().size() + nDynamic;
+ return index && index <= staticPart().size() + nDynamic;
}
quint32 FieldLookupTable::indexOf(const QByteArray &name, const QByteArray &value)const
{
// Start from the static part first:
- const auto &table = staticTable();
+ const auto &table = staticPart();
const HeaderField field(name, value);
- const auto staticPos = std::lower_bound(table.begin(), table.end(), field,
- [](const HeaderField &lhs, const HeaderField &rhs) {
- int cmp = compare(lhs.name, rhs.name);
- if (cmp)
- return cmp < 0;
- return compare(lhs.value, rhs.value) < 0;
- });
+ const auto staticPos = findInStaticPart(field, CompareMode::nameAndValue);
if (staticPos != table.end()) {
if (staticPos->name == name && staticPos->value == value)
- return staticPos - table.begin() + 1;
+ return quint32(staticPos - table.begin() + 1);
}
// Now we have to lookup in our dynamic part ...
@@ -366,15 +285,12 @@ quint32 FieldLookupTable::indexOf(const QByteArray &name, const QByteArray &valu
quint32 FieldLookupTable::indexOf(const QByteArray &name) const
{
// Start from the static part first:
- const auto &table = staticTable();
+ const auto &table = staticPart();
const HeaderField field(name, QByteArray());
- const auto staticPos = std::lower_bound(table.begin(), table.end(), field,
- [](const HeaderField &lhs, const HeaderField &rhs) {
- return compare(lhs.name, rhs.name) < 0;
- });
+ const auto staticPos = findInStaticPart(field, CompareMode::nameOnly);
if (staticPos != table.end()) {
if (staticPos->name == name)
- return staticPos - table.begin() + 1;
+ return quint32(staticPos - table.begin() + 1);
}
// Now we have to lookup in our dynamic part ...
@@ -402,7 +318,7 @@ bool FieldLookupTable::field(quint32 index, QByteArray *name, QByteArray *value)
if (!indexIsValid(index))
return false;
- const auto &table = staticTable();
+ const auto &table = staticPart();
if (index - 1 < table.size()) {
*name = table[index - 1].name;
*value = table[index - 1].value;
@@ -477,7 +393,7 @@ quint32 FieldLookupTable::keyToIndex(const SearchEntry &key) const
Q_ASSERT(offset < ChunkSize);
Q_ASSERT(chunkIndex || offset >= begin);
- return quint32(offset + chunkIndex * ChunkSize - begin + 1 + staticTable().size());
+ return quint32(offset + chunkIndex * ChunkSize - begin + 1 + staticPart().size());
}
FieldLookupTable::SearchEntry FieldLookupTable::frontKey() const
@@ -526,6 +442,103 @@ void FieldLookupTable::setMaxDynamicTableSize(quint32 size)
updateDynamicTableSize(size);
}
+// This data is from the HPACK's specs and it's quite conveniently sorted,
+// except ... 'accept' is in the wrong position, see how we handle it below.
+const std::vector<HeaderField> &FieldLookupTable::staticPart()
+{
+ static std::vector<HeaderField> table = {
+ {":authority", ""},
+ {":method", "GET"},
+ {":method", "POST"},
+ {":path", "/"},
+ {":path", "/index.html"},
+ {":scheme", "http"},
+ {":scheme", "https"},
+ {":status", "200"},
+ {":status", "204"},
+ {":status", "206"},
+ {":status", "304"},
+ {":status", "400"},
+ {":status", "404"},
+ {":status", "500"},
+ {"accept-charset", ""},
+ {"accept-encoding", "gzip, deflate"},
+ {"accept-language", ""},
+ {"accept-ranges", ""},
+ {"accept", ""},
+ {"access-control-allow-origin", ""},
+ {"age", ""},
+ {"allow", ""},
+ {"authorization", ""},
+ {"cache-control", ""},
+ {"content-disposition", ""},
+ {"content-encoding", ""},
+ {"content-language", ""},
+ {"content-length", ""},
+ {"content-location", ""},
+ {"content-range", ""},
+ {"content-type", ""},
+ {"cookie", ""},
+ {"date", ""},
+ {"etag", ""},
+ {"expect", ""},
+ {"expires", ""},
+ {"from", ""},
+ {"host", ""},
+ {"if-match", ""},
+ {"if-modified-since", ""},
+ {"if-none-match", ""},
+ {"if-range", ""},
+ {"if-unmodified-since", ""},
+ {"last-modified", ""},
+ {"link", ""},
+ {"location", ""},
+ {"max-forwards", ""},
+ {"proxy-authenticate", ""},
+ {"proxy-authorization", ""},
+ {"range", ""},
+ {"referer", ""},
+ {"refresh", ""},
+ {"retry-after", ""},
+ {"server", ""},
+ {"set-cookie", ""},
+ {"strict-transport-security", ""},
+ {"transfer-encoding", ""},
+ {"user-agent", ""},
+ {"vary", ""},
+ {"via", ""},
+ {"www-authenticate", ""}
+ };
+
+ return table;
+}
+
+std::vector<HeaderField>::const_iterator FieldLookupTable::findInStaticPart(const HeaderField &field, CompareMode mode)
+{
+ const auto &table = staticPart();
+ const auto acceptPos = table.begin() + 18;
+ if (field.name == "accept") {
+ if (mode == CompareMode::nameAndValue && field.value != "")
+ return table.end();
+ return acceptPos;
+ }
+
+ auto predicate = [mode](const HeaderField &lhs, const HeaderField &rhs) {
+ const int cmp = compare(lhs.name, rhs.name);
+ if (cmp)
+ return cmp < 0;
+ else if (mode == CompareMode::nameAndValue)
+ return compare(lhs.value, rhs.value) < 0;
+ return false;
+ };
+
+ const auto staticPos = std::lower_bound(table.begin(), acceptPos, field, predicate);
+ if (staticPos != acceptPos)
+ return staticPos;
+
+ return std::lower_bound(acceptPos + 1, table.end(), field, predicate);
+}
+
}
QT_END_NAMESPACE
diff --git a/src/network/access/http2/hpacktable_p.h b/src/network/access/http2/hpacktable_p.h
index aaea89b986..960e6a3d70 100644
--- a/src/network/access/http2/hpacktable_p.h
+++ b/src/network/access/http2/hpacktable_p.h
@@ -173,6 +173,8 @@ public:
bool updateDynamicTableSize(quint32 size);
void setMaxDynamicTableSize(quint32 size);
+ static const std::vector<HeaderField> &staticPart();
+
private:
// Table's maximum size is controlled
// by SETTINGS_HEADER_TABLE_SIZE (HTTP/2, 6.5.2).
@@ -225,9 +227,16 @@ private:
quint32 indexOfChunk(const Chunk *chunk) const;
quint32 keyToIndex(const SearchEntry &key) const;
+ enum class CompareMode {
+ nameOnly,
+ nameAndValue
+ };
+
+ static std::vector<HeaderField>::const_iterator findInStaticPart(const HeaderField &field, CompareMode mode);
+
mutable QByteArray dummyDst;
- Q_DISABLE_COPY(FieldLookupTable);
+ Q_DISABLE_COPY(FieldLookupTable)
};
}
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 5726925cb0..d5f63af745 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -966,7 +966,10 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
} else if (state != QHttpNetworkConnectionChannel::IdleState && state != QHttpNetworkConnectionChannel::ReadingState) {
// Try to reconnect/resend before sending an error.
// While "Reading" the _q_disconnected() will handle this.
- if (reconnectAttempts-- > 0) {
+ // If we're using ssl then the protocolHandler is not initialized until
+ // "encrypted" has been emitted, since retrying requires the protocolHandler (asserted)
+ // we will not try if encryption is not done.
+ if (!pendingEncrypt && reconnectAttempts-- > 0) {
resendCurrentRequest();
return;
} else {
diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp
index df4e034d97..b1e9853a50 100644
--- a/src/network/access/qnetworkreplywasmimpl.cpp
+++ b/src/network/access/qnetworkreplywasmimpl.cpp
@@ -265,7 +265,7 @@ qint64 QNetworkReplyWasmImpl::readData(char *data, qint64 maxlen)
Q_D(QNetworkReplyWasmImpl);
qint64 howMuch = qMin(maxlen, (d->downloadBuffer.size() - d->downloadBufferReadPosition));
- memcpy(data, d->downloadBuffer.constData(), howMuch);
+ memcpy(data, d->downloadBuffer.constData() + d->downloadBufferReadPosition, howMuch);
d->downloadBufferReadPosition += howMuch;
return howMuch;
diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
index 7fff50b2a1..734bdcaf75 100644
--- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
@@ -179,7 +179,15 @@ static inline bool checkNeedPortalSupport()
return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty() || qEnvironmentVariableIsSet("SNAP");
}
-static inline bool xdgDesktopPortalOpenFile(const QUrl &url)
+static inline bool isPortalReturnPermanent(const QDBusError &error)
+{
+ // A service unknown error isn't permanent, it just indicates that we
+ // should fall back to the regular way. This check includes
+ // QDBusError::NoError.
+ return error.type() != QDBusError::ServiceUnknown;
+}
+
+static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url)
{
// DBus signature:
// OpenFile (IN s parent_window,
@@ -198,23 +206,22 @@ static inline bool xdgDesktopPortalOpenFile(const QUrl &url)
QLatin1String("org.freedesktop.portal.OpenURI"),
QLatin1String("OpenFile"));
- QDBusUnixFileDescriptor descriptor(fd);
- qt_safe_close(fd);
+ QDBusUnixFileDescriptor descriptor;
+ descriptor.giveFileDescriptor(fd);
// FIXME parent_window_id and handle writable option
message << QString() << QVariant::fromValue(descriptor) << QVariantMap();
- QDBusPendingReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(message);
- return !reply.isError();
+ return QDBusConnection::sessionBus().call(message);
}
#else
Q_UNUSED(url)
#endif
- return false;
+ return QDBusMessage::createError(QDBusError::InternalError, qt_error_string());
}
-static inline bool xdgDesktopPortalOpenUrl(const QUrl &url)
+static inline QDBusMessage xdgDesktopPortalOpenUrl(const QUrl &url)
{
// DBus signature:
// OpenURI (IN s parent_window,
@@ -234,11 +241,10 @@ static inline bool xdgDesktopPortalOpenUrl(const QUrl &url)
// FIXME parent_window_id and handle writable option
message << QString() << url.toString() << QVariantMap();
- QDBusPendingReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(message);
- return !reply.isError();
+ return QDBusConnection::sessionBus().call(message);
}
-static inline bool xdgDesktopPortalSendEmail(const QUrl &url)
+static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
{
// DBus signature:
// ComposeEmail (IN s parent_window,
@@ -281,8 +287,7 @@ static inline bool xdgDesktopPortalSendEmail(const QUrl &url)
// FIXME parent_window_id
message << QString() << options;
- QDBusPendingReply<QDBusObjectPath> reply = QDBusConnection::sessionBus().call(message);
- return !reply.isError();
+ return QDBusConnection::sessionBus().call(message);
}
#endif // QT_CONFIG(dbus)
@@ -296,15 +301,23 @@ bool QGenericUnixServices::openUrl(const QUrl &url)
{
if (url.scheme() == QLatin1String("mailto")) {
#if QT_CONFIG(dbus)
- if (checkNeedPortalSupport())
- return xdgDesktopPortalSendEmail(url);
+ if (checkNeedPortalSupport()) {
+ QDBusError error = xdgDesktopPortalSendEmail(url);
+ if (isPortalReturnPermanent(error))
+ return !error.isValid();
+
+ // service not running, fall back
+ }
#endif
return openDocument(url);
}
#if QT_CONFIG(dbus)
- if (checkNeedPortalSupport())
- return xdgDesktopPortalOpenUrl(url);
+ if (checkNeedPortalSupport()) {
+ QDBusError error = xdgDesktopPortalOpenUrl(url);
+ if (isPortalReturnPermanent(error))
+ return !error.isValid();
+ }
#endif
if (m_webBrowser.isEmpty() && !detectWebBrowser(desktopEnvironment(), true, &m_webBrowser)) {
@@ -317,8 +330,11 @@ bool QGenericUnixServices::openUrl(const QUrl &url)
bool QGenericUnixServices::openDocument(const QUrl &url)
{
#if QT_CONFIG(dbus)
- if (checkNeedPortalSupport())
- return xdgDesktopPortalOpenFile(url);
+ if (checkNeedPortalSupport()) {
+ QDBusError error = xdgDesktopPortalOpenFile(url);
+ if (isPortalReturnPermanent(error))
+ return !error.isValid();
+ }
#endif
if (m_documentLauncher.isEmpty() && !detectWebBrowser(desktopEnvironment(), false, &m_documentLauncher)) {
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 13d41bea99..74edfd8356 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -560,10 +560,15 @@ static void quitQtAndroidPlugin(JNIEnv *env, jclass /*clazz*/)
static void terminateQt(JNIEnv *env, jclass /*clazz*/)
{
// QAndroidEventDispatcherStopper is stopped when the user uses the task manager to kill the application
- if (!QAndroidEventDispatcherStopper::instance()->stopped()) {
- sem_wait(&m_terminateSemaphore);
- sem_destroy(&m_terminateSemaphore);
+ if (QAndroidEventDispatcherStopper::instance()->stopped()) {
+ QAndroidEventDispatcherStopper::instance()->startAll();
+ QCoreApplication::quit();
+ QAndroidEventDispatcherStopper::instance()->goingToStop(false);
}
+
+ sem_wait(&m_terminateSemaphore);
+ sem_destroy(&m_terminateSemaphore);
+
env->DeleteGlobalRef(m_applicationClass);
env->DeleteGlobalRef(m_classLoaderObject);
if (m_resourcesObj)
@@ -583,10 +588,7 @@ static void terminateQt(JNIEnv *env, jclass /*clazz*/)
m_androidPlatformIntegration = nullptr;
delete m_androidAssetsFileEngineHandler;
m_androidAssetsFileEngineHandler = nullptr;
-
- if (!QAndroidEventDispatcherStopper::instance()->stopped()) {
- sem_post(&m_exitSemaphore);
- }
+ sem_post(&m_exitSemaphore);
}
static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface, jint w, jint h)
diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
index 3e1cfe305d..3de5d30623 100644
--- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
@@ -47,6 +47,7 @@
#include <QSurfaceFormat>
#include <QtGui/private/qwindow_p.h>
+#include <QtGui/qguiapplication.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformscreen.h>
@@ -121,7 +122,7 @@ void QAndroidPlatformOpenGLWindow::setGeometry(const QRect &rect)
EGLSurface QAndroidPlatformOpenGLWindow::eglSurface(EGLConfig config)
{
- if (QAndroidEventDispatcherStopper::stopped())
+ if (QAndroidEventDispatcherStopper::stopped() || QGuiApplication::applicationState() == Qt::ApplicationSuspended)
return m_eglSurface;
QMutexLocker lock(&m_surfaceMutex);
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index 8d65cf328f..083b7c1655 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -33,6 +33,7 @@ SOURCES += main.mm \
qcocoaintrospection.mm \
qcocoakeymapper.mm \
qcocoamimetypes.mm \
+ qiosurfacegraphicsbuffer.mm \
messages.cpp
HEADERS += qcocoaintegration.h \
@@ -67,6 +68,7 @@ HEADERS += qcocoaintegration.h \
qcocoaintrospection.h \
qcocoakeymapper.h \
messages.h \
+ qiosurfacegraphicsbuffer.h \
qcocoamimetypes.h
qtConfig(opengl.*) {
@@ -81,7 +83,7 @@ qtConfig(vulkan) {
RESOURCES += qcocoaresources.qrc
-LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -lcups
+LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups
QT += \
core-private gui-private \
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index e255719cc1..2cf6672da9 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -115,22 +115,10 @@ QT_USE_NAMESPACE
self = [super init];
if (self) {
inLaunch = true;
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(updateScreens:)
- name:NSApplicationDidChangeScreenParametersNotification
- object:NSApp];
}
return self;
}
-- (void)updateScreens:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- if (QCocoaIntegration *ci = QCocoaIntegration::instance())
- ci->updateScreens();
-}
-
- (void)dealloc
{
[_dockMenu release];
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index b4cd506513..508f24d578 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -44,13 +44,16 @@
#include <private/qcore_mac_p.h>
+#include <QScopedPointer>
+#include "qiosurfacegraphicsbuffer.h"
+
QT_BEGIN_NAMESPACE
-class QCocoaBackingStore : public QRasterBackingStore
+class QNSWindowBackingStore : public QRasterBackingStore
{
public:
- QCocoaBackingStore(QWindow *window);
- ~QCocoaBackingStore();
+ QNSWindowBackingStore(QWindow *window);
+ ~QNSWindowBackingStore();
void flush(QWindow *, const QRegion &, const QPoint &) override;
@@ -60,6 +63,49 @@ private:
void redrawRoundedBottomCorners(CGRect) const;
};
+class QCALayerBackingStore : public QPlatformBackingStore
+{
+public:
+ QCALayerBackingStore(QWindow *window);
+ ~QCALayerBackingStore();
+
+ void resize(const QSize &size, const QRegion &staticContents) override;
+
+ void beginPaint(const QRegion &region) override;
+ QPaintDevice *paintDevice() override;
+ void endPaint() override;
+
+ void flush(QWindow *, const QRegion &, const QPoint &) override;
+ void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
+ QPlatformTextureList *textures, bool translucentBackground) override;
+
+ QPlatformGraphicsBuffer *graphicsBuffer() const override;
+
+private:
+ QSize m_requestedSize;
+ QRegion m_paintedRegion;
+
+ class GraphicsBuffer : public QIOSurfaceGraphicsBuffer
+ {
+ public:
+ GraphicsBuffer(const QSize &size, qreal devicePixelRatio,
+ const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace);
+
+ QRegion dirtyRegion; // In unscaled coordinates
+ QImage *asImage();
+
+ private:
+ qreal m_devicePixelRatio;
+ QImage m_image;
+ };
+
+ void ensureBackBuffer();
+ bool recreateBackBufferIfNeeded();
+ bool prepareForFlush();
+
+ std::list<std::unique_ptr<GraphicsBuffer>> m_buffers;
+};
+
QT_END_NAMESPACE
#endif
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index 81a0a7d040..8e4e928bc5 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -42,24 +42,28 @@
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
+#include <QtCore/qmath.h>
+
+#include <QuartzCore/CATransaction.h>
+
QT_BEGIN_NAMESPACE
-QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
+QNSWindowBackingStore::QNSWindowBackingStore(QWindow *window)
: QRasterBackingStore(window)
{
}
-QCocoaBackingStore::~QCocoaBackingStore()
+QNSWindowBackingStore::~QNSWindowBackingStore()
{
}
-bool QCocoaBackingStore::windowHasUnifiedToolbar() const
+bool QNSWindowBackingStore::windowHasUnifiedToolbar() const
{
Q_ASSERT(window()->handle());
return static_cast<QCocoaWindow *>(window()->handle())->m_drawContentBorderGradient;
}
-QImage::Format QCocoaBackingStore::format() const
+QImage::Format QNSWindowBackingStore::format() const
{
if (windowHasUnifiedToolbar())
return QImage::Format_ARGB32_Premultiplied;
@@ -78,7 +82,7 @@ QImage::Format QCocoaBackingStore::format() const
coordinates, and the \a offset will be the child window's offset in relation
to the backingstore's top level window.
*/
-void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
+void QNSWindowBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
if (m_image.isNull())
return;
@@ -103,131 +107,113 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
qCDebug(lcQpaBackingStore) << "Flushing" << region << "of" << view << qPrintable(targetViewDescription);
}
- // Prevent potentially costly color conversion by assigning the display color space
- // to the backingstore image. This does not copy the underlying image data.
- CGColorSpaceRef displayColorSpace = view.window.screen.colorSpace.CGColorSpace;
- QCFType<CGImageRef> cgImage = CGImageCreateCopyWithColorSpace(
- QCFType<CGImageRef>(m_image.toCGImage()), displayColorSpace);
-
- if (view.layer) {
- // In layer-backed mode, locking focus on a view does not give the right
- // view transformation, and doesn't give us a graphics context to render
- // via when drawing outside of the display cycle. Instead we tell AppKit
- // that we want to update the layer's content, via [NSView wantsUpdateLayer],
- // which result in AppKit not creating a backingstore for each layer, and
- // we then directly set the layer's backingstore (content) to our backingstore,
- // masked to the part of the subview that is relevant.
- // FIXME: Figure out if there's a way to do partial updates
- view.layer.contents = (__bridge id)static_cast<CGImageRef>(cgImage);
- if (view != topLevelView) {
- const CGSize topLevelSize = topLevelView.bounds.size;
- view.layer.contentsRect = CGRectApplyAffineTransform(
- [view convertRect:view.bounds toView:topLevelView],
- // The contentsRect is in unit coordinate system
- CGAffineTransformMakeScale(1.0 / topLevelSize.width, 1.0 / topLevelSize.height));
- }
- } else {
- // Normally a NSView is drawn via drawRect, as part of the display cycle in the
- // main runloop, via setNeedsDisplay and friends. AppKit will lock focus on each
- // individual view, starting with the top level and then traversing any subviews,
- // calling drawRect for each of them. This pull model results in expose events
- // sent to Qt, which result in drawing to the backingstore and flushing it.
- // Qt may also decide to paint and flush the backingstore via e.g. timers,
- // or other events such as mouse events, in which case we're in a push model.
- // If there is no focused view, it means we're in the latter case, and need
- // to manually flush the NSWindow after drawing to its graphic context.
- const bool drawingOutsideOfDisplayCycle = ![NSView focusView];
-
- // We also need to ensure the flushed view has focus, so that the graphics
- // context is set up correctly (coordinate system, clipping, etc). Outside
- // of the normal display cycle there is no focused view, as explained above,
- // so we have to handle it manually. There's also a corner case inside the
- // normal display cycle due to way QWidgetBackingStore composits native child
- // widgets, where we'll get a flush of a native child during the drawRect of
- // its parent/ancestor, and the parent/ancestor being the one locked by AppKit.
- // In this case we also need to lock and unlock focus manually.
- const bool shouldHandleViewLockManually = [NSView focusView] != view;
- if (shouldHandleViewLockManually && ![view lockFocusIfCanDraw]) {
- qWarning() << "failed to lock focus of" << view;
- return;
- }
+ // Normally a NSView is drawn via drawRect, as part of the display cycle in the
+ // main runloop, via setNeedsDisplay and friends. AppKit will lock focus on each
+ // individual view, starting with the top level and then traversing any subviews,
+ // calling drawRect for each of them. This pull model results in expose events
+ // sent to Qt, which result in drawing to the backingstore and flushing it.
+ // Qt may also decide to paint and flush the backingstore via e.g. timers,
+ // or other events such as mouse events, in which case we're in a push model.
+ // If there is no focused view, it means we're in the latter case, and need
+ // to manually flush the NSWindow after drawing to its graphic context.
+ const bool drawingOutsideOfDisplayCycle = ![NSView focusView];
+
+ // We also need to ensure the flushed view has focus, so that the graphics
+ // context is set up correctly (coordinate system, clipping, etc). Outside
+ // of the normal display cycle there is no focused view, as explained above,
+ // so we have to handle it manually. There's also a corner case inside the
+ // normal display cycle due to way QWidgetBackingStore composits native child
+ // widgets, where we'll get a flush of a native child during the drawRect of
+ // its parent/ancestor, and the parent/ancestor being the one locked by AppKit.
+ // In this case we also need to lock and unlock focus manually.
+ const bool shouldHandleViewLockManually = [NSView focusView] != view;
+ if (shouldHandleViewLockManually && ![view lockFocusIfCanDraw]) {
+ qWarning() << "failed to lock focus of" << view;
+ return;
+ }
- const qreal devicePixelRatio = m_image.devicePixelRatio();
+ const qreal devicePixelRatio = m_image.devicePixelRatio();
- // If the flushed window is a content view, and we're filling the drawn area
- // completely, or it doesn't have a window background we need to preserve,
- // we can get away with copying instead of blending the backing store.
- QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
- const NSCompositingOperation compositingOperation = cocoaWindow->isContentView()
- && (cocoaWindow->isOpaque() || view.window.backgroundColor == NSColor.clearColor)
- ? NSCompositingOperationCopy : NSCompositingOperationSourceOver;
+ // If the flushed window is a content view, and we're filling the drawn area
+ // completely, or it doesn't have a window background we need to preserve,
+ // we can get away with copying instead of blending the backing store.
+ QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
+ const NSCompositingOperation compositingOperation = cocoaWindow->isContentView()
+ && (cocoaWindow->isOpaque() || view.window.backgroundColor == NSColor.clearColor)
+ ? NSCompositingOperationCopy : NSCompositingOperationSourceOver;
#ifdef QT_DEBUG
- static bool debugBackingStoreFlush = [[NSUserDefaults standardUserDefaults]
- boolForKey:@"QtCocoaDebugBackingStoreFlush"];
+ static bool debugBackingStoreFlush = [[NSUserDefaults standardUserDefaults]
+ boolForKey:@"QtCocoaDebugBackingStoreFlush"];
#endif
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
- // The current contexts is typically a NSWindowGraphicsContext, but can be
- // NSBitmapGraphicsContext e.g. when debugging the view hierarchy in Xcode.
- // If we need to distinguish things here in the future, we can use e.g.
- // [NSGraphicsContext drawingToScreen], or the attributes of the context.
- NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext];
- Q_ASSERT_X(graphicsContext, "QCocoaBackingStore",
- "Focusing the view should give us a current graphics context");
+ // The current contexts is typically a NSWindowGraphicsContext, but can be
+ // NSBitmapGraphicsContext e.g. when debugging the view hierarchy in Xcode.
+ // If we need to distinguish things here in the future, we can use e.g.
+ // [NSGraphicsContext drawingToScreen], or the attributes of the context.
+ NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext];
+ Q_ASSERT_X(graphicsContext, "QCocoaBackingStore",
+ "Focusing the view should give us a current graphics context");
- // Create temporary image to use for blitting, without copying image data
- NSImage *backingStoreImage = [[[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize] autorelease];
+ // Prevent potentially costly color conversion by assigning the display color space
+ // to the backingstore image. This does not copy the underlying image data.
+ CGColorSpaceRef displayColorSpace = view.window.screen.colorSpace.CGColorSpace;
+ QCFType<CGImageRef> cgImage = CGImageCreateCopyWithColorSpace(
+ QCFType<CGImageRef>(m_image.toCGImage()), displayColorSpace);
- QRegion clippedRegion = region;
- for (QWindow *w = window; w; w = w->parent()) {
- if (!w->mask().isEmpty()) {
- clippedRegion &= w == window ? w->mask()
- : w->mask().translated(window->mapFromGlobal(w->mapToGlobal(QPoint(0, 0))));
- }
+ // Create temporary image to use for blitting, without copying image data
+ NSImage *backingStoreImage = [[[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize] autorelease];
+
+ QRegion clippedRegion = region;
+ for (QWindow *w = window; w; w = w->parent()) {
+ if (!w->mask().isEmpty()) {
+ clippedRegion &= w == window ? w->mask()
+ : w->mask().translated(window->mapFromGlobal(w->mapToGlobal(QPoint(0, 0))));
}
+ }
- for (const QRect &viewLocalRect : clippedRegion) {
- QPoint backingStoreOffset = viewLocalRect.topLeft() + offset;
- QRect backingStoreRect(backingStoreOffset * devicePixelRatio, viewLocalRect.size() * devicePixelRatio);
- if (graphicsContext.flipped) // Flip backingStoreRect to match graphics context
- backingStoreRect.moveTop(m_image.height() - (backingStoreRect.y() + backingStoreRect.height()));
+ for (const QRect &viewLocalRect : clippedRegion) {
+ QPoint backingStoreOffset = viewLocalRect.topLeft() + offset;
+ QRect backingStoreRect(backingStoreOffset * devicePixelRatio, viewLocalRect.size() * devicePixelRatio);
+ if (graphicsContext.flipped) // Flip backingStoreRect to match graphics context
+ backingStoreRect.moveTop(m_image.height() - (backingStoreRect.y() + backingStoreRect.height()));
- CGRect viewRect = viewLocalRect.toCGRect();
+ CGRect viewRect = viewLocalRect.toCGRect();
- if (windowHasUnifiedToolbar())
- NSDrawWindowBackground(viewRect);
+ if (windowHasUnifiedToolbar())
+ NSDrawWindowBackground(viewRect);
- [backingStoreImage drawInRect:viewRect fromRect:backingStoreRect.toCGRect()
- operation:compositingOperation fraction:1.0 respectFlipped:YES hints:nil];
+ [backingStoreImage drawInRect:viewRect fromRect:backingStoreRect.toCGRect()
+ operation:compositingOperation fraction:1.0 respectFlipped:YES hints:nil];
#ifdef QT_DEBUG
- if (Q_UNLIKELY(debugBackingStoreFlush)) {
- [[NSColor colorWithCalibratedRed:drand48() green:drand48() blue:drand48() alpha:0.3] set];
- [NSBezierPath fillRect:viewRect];
-
- if (drawingOutsideOfDisplayCycle) {
- [[[NSColor magentaColor] colorWithAlphaComponent:0.5] set];
- [NSBezierPath strokeLineFromPoint:viewLocalRect.topLeft().toCGPoint()
- toPoint:viewLocalRect.bottomRight().toCGPoint()];
- }
+ if (Q_UNLIKELY(debugBackingStoreFlush)) {
+ [[NSColor colorWithCalibratedRed:drand48() green:drand48() blue:drand48() alpha:0.3] set];
+ [NSBezierPath fillRect:viewRect];
+
+ if (drawingOutsideOfDisplayCycle) {
+ [[[NSColor magentaColor] colorWithAlphaComponent:0.5] set];
+ [NSBezierPath strokeLineFromPoint:viewLocalRect.topLeft().toCGPoint()
+ toPoint:viewLocalRect.bottomRight().toCGPoint()];
}
-#endif
}
+#endif
+ }
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
- if (shouldHandleViewLockManually)
- [view unlockFocus];
+ if (shouldHandleViewLockManually)
+ [view unlockFocus];
- if (drawingOutsideOfDisplayCycle) {
- redrawRoundedBottomCorners([view convertRect:region.boundingRect().toCGRect() toView:nil]);
- [view.window flushWindow];
- }
+ if (drawingOutsideOfDisplayCycle) {
+ redrawRoundedBottomCorners([view convertRect:region.boundingRect().toCGRect() toView:nil]);
+ [view.window flushWindow];
}
- // Done flushing to either CALayer or NSWindow backingstore
+
+ // Done flushing to NSWindow backingstore
QCocoaWindow *topLevelCocoaWindow = static_cast<QCocoaWindow *>(topLevelWindow->handle());
if (Q_UNLIKELY(topLevelCocoaWindow->m_needsInvalidateShadow)) {
@@ -251,7 +237,7 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
https://trac.webkit.org/changeset/85376/webkit
*/
-void QCocoaBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const
+void QNSWindowBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const
{
#if !defined(QT_APPLE_NO_PRIVATE_APIS)
Q_ASSERT(this->window()->handle());
@@ -285,4 +271,345 @@ void QCocoaBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const
#endif
}
+// ----------------------------------------------------------------------------
+
+// https://stackoverflow.com/a/52722575/2761869
+template<class R>
+struct backwards_t {
+ R r;
+ constexpr auto begin() const { using std::rbegin; return rbegin(r); }
+ constexpr auto begin() { using std::rbegin; return rbegin(r); }
+ constexpr auto end() const { using std::rend; return rend(r); }
+ constexpr auto end() { using std::rend; return rend(r); }
+};
+template<class R>
+constexpr backwards_t<R> backwards(R&& r) { return {std::forward<R>(r)}; }
+
+QCALayerBackingStore::QCALayerBackingStore(QWindow *window)
+ : QPlatformBackingStore(window)
+{
+ qCDebug(lcQpaBackingStore) << "Creating QCALayerBackingStore for" << window;
+ m_buffers.resize(1);
+}
+
+QCALayerBackingStore::~QCALayerBackingStore()
+{
+}
+
+void QCALayerBackingStore::resize(const QSize &size, const QRegion &staticContents)
+{
+ qCDebug(lcQpaBackingStore) << "Resize requested to" << size;
+
+ if (!staticContents.isNull())
+ qCWarning(lcQpaBackingStore) << "QCALayerBackingStore does not support static contents";
+
+ m_requestedSize = size;
+}
+
+void QCALayerBackingStore::beginPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+
+ QMacAutoReleasePool pool;
+
+ qCInfo(lcQpaBackingStore) << "Beginning paint of" << region << "into backingstore of" << m_requestedSize;
+
+ ensureBackBuffer(); // Find an unused back buffer, or reserve space for a new one
+
+ const bool bufferWasRecreated = recreateBackBufferIfNeeded();
+
+ m_buffers.back()->lock(QPlatformGraphicsBuffer::SWWriteAccess);
+
+ // Although undocumented, QBackingStore::beginPaint expects the painted region
+ // to be cleared before use if the window has a surface format with an alpha.
+ // Fresh IOSurfaces are already cleared, so we don't need to clear those.
+ if (!bufferWasRecreated && window()->format().hasAlpha()) {
+ qCDebug(lcQpaBackingStore) << "Clearing" << region << "before use";
+ QPainter painter(m_buffers.back()->asImage());
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ for (const QRect &rect : region)
+ painter.fillRect(rect, Qt::transparent);
+ }
+
+ m_paintedRegion += region;
+}
+
+void QCALayerBackingStore::ensureBackBuffer()
+{
+ if (window()->format().swapBehavior() == QSurfaceFormat::SingleBuffer)
+ return;
+
+ // The current back buffer may have been assigned to a layer in a previous flush,
+ // but we deferred the swap. Do it now if the surface has been picked up by CA.
+ if (m_buffers.back() && m_buffers.back()->isInUse() && m_buffers.back() != m_buffers.front()) {
+ qCInfo(lcQpaBackingStore) << "Back buffer has been picked up by CA, swapping to front";
+ std::swap(m_buffers.back(), m_buffers.front());
+ }
+
+ if (Q_UNLIKELY(lcQpaBackingStore().isDebugEnabled())) {
+ // ┌───────┬───────┬───────┬─────┬──────┐
+ // │ front ┊ spare ┊ spare ┊ ... ┊ back │
+ // └───────┴───────┴───────┴─────┴──────┘
+ for (const auto &buffer : m_buffers) {
+ qCDebug(lcQpaBackingStore).nospace() << " "
+ << (buffer == m_buffers.front() ? "front" :
+ buffer == m_buffers.back() ? " back" :
+ "spare"
+ ) << ": " << buffer.get();
+ }
+ }
+
+ // Ensure our back buffer is ready to draw into. If not, find a buffer that
+ // is not in use, or reserve space for a new buffer if none can be found.
+ for (auto &buffer : backwards(m_buffers)) {
+ if (!buffer || !buffer->isInUse()) {
+ // Buffer is okey to use, swap if necessary
+ if (buffer != m_buffers.back())
+ std::swap(buffer, m_buffers.back());
+ qCDebug(lcQpaBackingStore) << "Using back buffer" << m_buffers.back().get();
+
+ static const int kMaxSwapChainDepth = 3;
+ if (m_buffers.size() > kMaxSwapChainDepth) {
+ qCDebug(lcQpaBackingStore) << "Reducing swap chain depth to" << kMaxSwapChainDepth;
+ m_buffers.erase(std::next(m_buffers.begin(), 1), std::prev(m_buffers.end(), 2));
+ }
+
+ break;
+ } else if (buffer == m_buffers.front()) {
+ // We've exhausted the available buffers, make room for a new one
+ const int swapChainDepth = m_buffers.size() + 1;
+ qCDebug(lcQpaBackingStore) << "Available buffers exhausted, increasing swap chain depth to" << swapChainDepth;
+ m_buffers.resize(swapChainDepth);
+ break;
+ }
+ }
+
+ Q_ASSERT(!m_buffers.back() || !m_buffers.back()->isInUse());
+}
+
+// Disabled until performance issue on 5K iMac Pro has been investigated further,
+// as rounding up during resize will typically result in full screen buffer sizes
+// and low frame rate also for smaller window sizes.
+#define USE_LAZY_BUFFER_ALLOCATION_DURING_LIVE_WINDOW_RESIZE 0
+
+bool QCALayerBackingStore::recreateBackBufferIfNeeded()
+{
+ const qreal devicePixelRatio = window()->devicePixelRatio();
+ QSize requestedBufferSize = m_requestedSize * devicePixelRatio;
+
+ const NSView *backingStoreView = static_cast<QCocoaWindow *>(window()->handle())->view();
+ Q_UNUSED(backingStoreView);
+
+ auto bufferSizeMismatch = [&](const QSize requested, const QSize actual) {
+#if USE_LAZY_BUFFER_ALLOCATION_DURING_LIVE_WINDOW_RESIZE
+ if (backingStoreView.inLiveResize) {
+ // Prevent over-eager buffer allocation during window resize by reusing larger buffers
+ return requested.width() > actual.width() || requested.height() > actual.height();
+ }
+#endif
+ return requested != actual;
+ };
+
+ if (!m_buffers.back() || bufferSizeMismatch(requestedBufferSize, m_buffers.back()->size())) {
+#if USE_LAZY_BUFFER_ALLOCATION_DURING_LIVE_WINDOW_RESIZE
+ if (backingStoreView.inLiveResize) {
+ // Prevent over-eager buffer allocation during window resize by rounding up
+ QSize nativeScreenSize = window()->screen()->geometry().size() * devicePixelRatio;
+ requestedBufferSize = QSize(qNextPowerOfTwo(requestedBufferSize.width()),
+ qNextPowerOfTwo(requestedBufferSize.height())).boundedTo(nativeScreenSize);
+ }
+#endif
+
+ qCInfo(lcQpaBackingStore) << "Creating surface of" << requestedBufferSize
+ << "based on requested" << m_requestedSize << "and dpr =" << devicePixelRatio;
+
+ static auto pixelFormat = QImage::toPixelFormat(QImage::Format_ARGB32_Premultiplied);
+
+ NSView *view = static_cast<QCocoaWindow *>(window()->handle())->view();
+ auto colorSpace = QCFType<CGColorSpaceRef>::constructFromGet(view.window.screen.colorSpace.CGColorSpace);
+
+ m_buffers.back().reset(new GraphicsBuffer(requestedBufferSize, devicePixelRatio, pixelFormat, colorSpace));
+ return true;
+ }
+
+ return false;
+}
+
+QPaintDevice *QCALayerBackingStore::paintDevice()
+{
+ Q_ASSERT(m_buffers.back());
+ return m_buffers.back()->asImage();
+}
+
+void QCALayerBackingStore::endPaint()
+{
+ qCInfo(lcQpaBackingStore) << "Paint ended with painted region" << m_paintedRegion;
+ m_buffers.back()->unlock();
+}
+
+void QCALayerBackingStore::flush(QWindow *flushedWindow, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+
+ if (!prepareForFlush())
+ return;
+
+ QMacAutoReleasePool pool;
+
+ NSView *backingStoreView = static_cast<QCocoaWindow *>(window()->handle())->view();
+ NSView *flushedView = static_cast<QCocoaWindow *>(flushedWindow->handle())->view();
+
+ id backBufferSurface = (__bridge id)m_buffers.back()->surface();
+ if (flushedView.layer.contents == backBufferSurface) {
+ // We've managed to paint to the back buffer again before Core Animation had time
+ // to flush the transaction and persist the layer changes to the window server.
+ // The layer already knows about the back buffer, and we don't need to re-apply
+ // it to pick up the surface changes, so bail out early.
+ qCInfo(lcQpaBackingStore).nospace() << "Skipping flush of " << flushedView
+ << ", layer already reflects back buffer";
+ return;
+ }
+
+ // Trigger a new display cycle if there isn't one. This ensures that our layer updates
+ // are committed as part of a display-cycle instead of on the next runloop pass. This
+ // means CA won't try to throttle us if we flush too fast, and we'll coalesce our flush
+ // with other pending view and layer updates.
+ backingStoreView.window.viewsNeedDisplay = YES;
+
+ if (window()->format().swapBehavior() == QSurfaceFormat::SingleBuffer) {
+ // The private API [CALayer reloadValueForKeyPath:@"contents"] would be preferable,
+ // but barring any side effects or performance issues we opt for the hammer for now.
+ flushedView.layer.contents = nil;
+ }
+
+ qCInfo(lcQpaBackingStore) << "Flushing" << backBufferSurface
+ << "to" << flushedView.layer << "of" << flushedView;
+
+ flushedView.layer.contents = backBufferSurface;
+
+ if (flushedView != backingStoreView) {
+ const CGSize backingStoreSize = backingStoreView.bounds.size;
+ flushedView.layer.contentsRect = CGRectApplyAffineTransform(
+ [flushedView convertRect:flushedView.bounds toView:backingStoreView],
+ // The contentsRect is in unit coordinate system
+ CGAffineTransformMakeScale(1.0 / backingStoreSize.width, 1.0 / backingStoreSize.height));
+ }
+
+ // Since we may receive multiple flushes before a new frame is started, we do not
+ // swap any buffers just yet. Instead we check in the next beginPaint if the layer's
+ // surface is in use, and if so swap to an unused surface as the new back buffer.
+
+ // Note: Ideally CoreAnimation would mark a surface as in use the moment we assign
+ // it to a layer, but as that's not the case we may end up painting to the same back
+ // buffer once more if we are painting faster than CA can ship the surfaces over to
+ // the window server.
+}
+
+void QCALayerBackingStore::composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
+ QPlatformTextureList *textures, bool translucentBackground)
+{
+ if (!prepareForFlush())
+ return;
+
+ QPlatformBackingStore::composeAndFlush(window, region, offset, textures, translucentBackground);
+}
+
+QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const
+{
+ return m_buffers.back().get();
+}
+
+bool QCALayerBackingStore::prepareForFlush()
+{
+ if (!m_buffers.back()) {
+ qCWarning(lcQpaBackingStore) << "Tried to flush backingstore without painting to it first";
+ return false;
+ }
+
+ // Update dirty state of buffers based on what was painted. The back buffer will be
+ // less dirty, since we painted to it, while other buffers will become more dirty.
+ // This allows us to minimize copies between front and back buffers on swap in the
+ // cases where the painted region overlaps with the previous frame (front buffer).
+ for (const auto &buffer : m_buffers) {
+ if (buffer == m_buffers.back())
+ buffer->dirtyRegion -= m_paintedRegion;
+ else
+ buffer->dirtyRegion += m_paintedRegion;
+ }
+
+ // After painting, the back buffer is only guaranteed to have content for the painted
+ // region, and may still have dirty areas that need to be synced up with the front buffer,
+ // if we have one. We know that the front buffer is always up to date.
+ if (!m_buffers.back()->dirtyRegion.isEmpty() && m_buffers.front() != m_buffers.back()) {
+ QRegion preserveRegion = m_buffers.back()->dirtyRegion;
+ qCDebug(lcQpaBackingStore) << "Preserving" << preserveRegion << "from front to back buffer";
+
+ m_buffers.front()->lock(QPlatformGraphicsBuffer::SWReadAccess);
+ const QImage *frontBuffer = m_buffers.front()->asImage();
+
+ const QRect frontSurfaceBounds(QPoint(0, 0), m_buffers.front()->size());
+ const qreal sourceDevicePixelRatio = frontBuffer->devicePixelRatio();
+
+ m_buffers.back()->lock(QPlatformGraphicsBuffer::SWWriteAccess);
+ QPainter painter(m_buffers.back()->asImage());
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+
+ // Let painter operate in device pixels, to make it easier to compare coordinates
+ const qreal targetDevicePixelRatio = painter.device()->devicePixelRatio();
+ painter.scale(1.0 / targetDevicePixelRatio, 1.0 / targetDevicePixelRatio);
+
+ for (const QRect &rect : preserveRegion) {
+ QRect sourceRect(rect.topLeft() * sourceDevicePixelRatio, rect.size() * sourceDevicePixelRatio);
+ QRect targetRect(rect.topLeft() * targetDevicePixelRatio, rect.size() * targetDevicePixelRatio);
+
+#ifdef QT_DEBUG
+ if (Q_UNLIKELY(!frontSurfaceBounds.contains(sourceRect.bottomRight()))) {
+ qCWarning(lcQpaBackingStore) << "Front buffer too small to preserve"
+ << QRegion(sourceRect).subtracted(frontSurfaceBounds);
+ }
+#endif
+ painter.drawImage(targetRect, *frontBuffer, sourceRect);
+ }
+
+ m_buffers.back()->unlock();
+ m_buffers.front()->unlock();
+
+ // The back buffer is now completely in sync, ready to be presented
+ m_buffers.back()->dirtyRegion = QRegion();
+ }
+
+ // Prepare for another round of painting
+ m_paintedRegion = QRegion();
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+
+QCALayerBackingStore::GraphicsBuffer::GraphicsBuffer(const QSize &size, qreal devicePixelRatio,
+ const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace)
+ : QIOSurfaceGraphicsBuffer(size, format, colorSpace)
+ , dirtyRegion(0, 0, size.width() / devicePixelRatio, size.height() / devicePixelRatio)
+ , m_devicePixelRatio(devicePixelRatio)
+{
+}
+
+QImage *QCALayerBackingStore::GraphicsBuffer::asImage()
+{
+ if (m_image.isNull()) {
+ qCDebug(lcQpaBackingStore) << "Setting up paint device for" << this;
+ CFRetain(surface());
+ m_image = QImage(data(), size().width(), size().height(),
+ bytesPerLine(), QImage::toImageFormat(format()),
+ QImageCleanupFunction(CFRelease), surface());
+ m_image.setDevicePixelRatio(m_devicePixelRatio);
+ }
+
+ Q_ASSERT_X(m_image.constBits() == data(), "QCALayerBackingStore",
+ "IOSurfaces should have have a fixed location in memory once created");
+
+ return &m_image;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index d86e935788..9c705616ba 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaWindow, "qt.qpa.window");
Q_LOGGING_CATEGORY(lcQpaDrawing, "qt.qpa.drawing");
-Q_LOGGING_CATEGORY(lcQpaMouse, "qt.qpa.input.mouse");
+Q_LOGGING_CATEGORY(lcQpaMouse, "qt.qpa.input.mouse", QtCriticalMsg);
Q_LOGGING_CATEGORY(lcQpaScreen, "qt.qpa.screen");
//
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index 7de7e073de..04cb4e1226 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -144,6 +144,7 @@ private:
#endif
QScopedPointer<QPlatformTheme> mPlatformTheme;
QList<QCocoaScreen *> mScreens;
+ QMacScopedObserver m_screensObserver;
#ifndef QT_NO_CLIPBOARD
QCocoaClipboard *mCocoaClipboard;
#endif
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index f6a49dd74f..6d6c66e242 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -206,6 +206,9 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
// by explicitly setting the presentation option to the magic 'default value',
// which will resolve to an actual value and result in screen invalidation.
cocoaApplication.presentationOptions = NSApplicationPresentationDefault;
+
+ m_screensObserver = QMacScopedObserver([NSApplication sharedApplication],
+ NSApplicationDidChangeScreenParametersNotification, [&]() { updateScreens(); });
updateScreens();
QMacInternalPasteboardMime::initializeMimeTypes();
@@ -404,7 +407,16 @@ QPlatformOpenGLContext *QCocoaIntegration::createPlatformOpenGLContext(QOpenGLCo
QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *window) const
{
- return new QCocoaBackingStore(window);
+ QCocoaWindow *platformWindow = static_cast<QCocoaWindow*>(window->handle());
+ if (!platformWindow) {
+ qWarning() << window << "must be created before being used with a backingstore";
+ return nullptr;
+ }
+
+ if (platformWindow->view().layer)
+ return new QCALayerBackingStore(window);
+ else
+ return new QNSWindowBackingStore(window);
}
QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const
diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h
new file mode 100644
index 0000000000..872773cb7a
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 QIOSURFACEGRAPHICSBUFFER_H
+#define QIOSURFACEGRAPHICSBUFFER_H
+
+#include <qpa/qplatformgraphicsbuffer.h>
+#include <private/qcore_mac_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QIOSurfaceGraphicsBuffer : public QPlatformGraphicsBuffer
+{
+public:
+ QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace);
+ ~QIOSurfaceGraphicsBuffer();
+
+ const uchar *data() const override;
+ uchar *data() override;
+ int bytesPerLine() const override;
+
+ IOSurfaceRef surface();
+ bool isInUse() const;
+
+protected:
+ bool doLock(AccessTypes access, const QRect &rect) override;
+ void doUnlock() override;
+
+private:
+ QCFType<IOSurfaceRef> m_surface;
+
+ friend QDebug operator<<(QDebug, const QIOSurfaceGraphicsBuffer *);
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug, const QIOSurfaceGraphicsBuffer *);
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QIOSURFACEGRAPHICSBUFFER_H
diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm
new file mode 100644
index 0000000000..a367487e85
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "qiosurfacegraphicsbuffer.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qloggingcategory.h>
+
+#include <CoreGraphics/CoreGraphics.h>
+#include <IOSurface/IOSurface.h>
+
+// CGColorSpaceCopyPropertyList is available on 10.12 and above,
+// but was only added in the 10.14 SDK, so declare it just in case.
+extern "C" CFPropertyListRef CGColorSpaceCopyPropertyList(CGColorSpaceRef space);
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(lcQpaIOSurface, "qt.qpa.backingstore.iosurface");
+
+QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace)
+ : QPlatformGraphicsBuffer(size, format)
+{
+ const size_t width = size.width();
+ const size_t height = size.height();
+
+ Q_ASSERT(width <= IOSurfaceGetPropertyMaximum(kIOSurfaceWidth));
+ Q_ASSERT(height <= IOSurfaceGetPropertyMaximum(kIOSurfaceHeight));
+
+ static const char bytesPerElement = 4;
+
+ const size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerElement);
+ const size_t totalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * bytesPerRow);
+
+ NSDictionary *options = @{
+ (id)kIOSurfaceWidth: @(width),
+ (id)kIOSurfaceHeight: @(height),
+ (id)kIOSurfacePixelFormat: @(unsigned('BGRA')),
+ (id)kIOSurfaceBytesPerElement: @(bytesPerElement),
+ (id)kIOSurfaceBytesPerRow: @(bytesPerRow),
+ (id)kIOSurfaceAllocSize: @(totalBytes),
+ };
+
+ m_surface = IOSurfaceCreate((CFDictionaryRef)options);
+ Q_ASSERT(m_surface);
+
+ Q_ASSERT(size_t(bytesPerLine()) == bytesPerRow);
+ Q_ASSERT(size_t(byteCount()) == totalBytes);
+
+ if (colorSpace) {
+ IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"),
+ QCFType<CFPropertyListRef>(CGColorSpaceCopyPropertyList(colorSpace)));
+ }
+}
+
+QIOSurfaceGraphicsBuffer::~QIOSurfaceGraphicsBuffer()
+{
+}
+
+const uchar *QIOSurfaceGraphicsBuffer::data() const
+{
+ return (const uchar *)IOSurfaceGetBaseAddress(m_surface);
+}
+
+uchar *QIOSurfaceGraphicsBuffer::data()
+{
+ return (uchar *)IOSurfaceGetBaseAddress(m_surface);
+}
+
+int QIOSurfaceGraphicsBuffer::bytesPerLine() const
+{
+ return IOSurfaceGetBytesPerRow(m_surface);
+}
+
+IOSurfaceRef QIOSurfaceGraphicsBuffer::surface()
+{
+ return m_surface;
+}
+
+bool QIOSurfaceGraphicsBuffer::isInUse() const
+{
+ return IOSurfaceIsInUse(m_surface);
+}
+
+IOSurfaceLockOptions lockOptionsForAccess(QPlatformGraphicsBuffer::AccessTypes access)
+{
+ IOSurfaceLockOptions lockOptions = 0;
+ if (!(access & QPlatformGraphicsBuffer::SWWriteAccess))
+ lockOptions |= kIOSurfaceLockReadOnly;
+ return lockOptions;
+}
+
+bool QIOSurfaceGraphicsBuffer::doLock(AccessTypes access, const QRect &rect)
+{
+ Q_UNUSED(rect);
+ Q_ASSERT(!isLocked());
+
+ qCDebug(lcQpaIOSurface) << "Locking" << this << "for" << access;
+
+ // FIXME: Teach QPlatformBackingStore::composeAndFlush about non-2D texture
+ // targets, so that we can use CGLTexImageIOSurface2D to support TextureAccess.
+ if (access & (TextureAccess | HWCompositor))
+ return false;
+
+ auto lockOptions = lockOptionsForAccess(access);
+
+ // Try without read-back first
+ lockOptions |= kIOSurfaceLockAvoidSync;
+ kern_return_t ret = IOSurfaceLock(m_surface, lockOptions, nullptr);
+ if (ret == kIOSurfaceSuccess)
+ return true;
+
+ if (ret == kIOReturnCannotLock) {
+ qCWarning(lcQpaIOSurface) << "Locking of" << this << "requires read-back";
+ lockOptions ^= kIOSurfaceLockAvoidSync;
+ ret = IOSurfaceLock(m_surface, lockOptions, nullptr);
+ }
+
+ if (ret != kIOSurfaceSuccess) {
+ qCWarning(lcQpaIOSurface) << "Failed to lock" << this << ret;
+ return false;
+ }
+
+ return true;
+}
+
+void QIOSurfaceGraphicsBuffer::doUnlock()
+{
+ qCDebug(lcQpaIOSurface) << "Unlocking" << this << "from" << isLocked();
+
+ auto lockOptions = lockOptionsForAccess(isLocked());
+ bool success = IOSurfaceUnlock(m_surface, lockOptions, nullptr) == kIOSurfaceSuccess;
+ Q_ASSERT_X(success, "QIOSurfaceGraphicsBuffer", "Unlocking surface should succeed");
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QIOSurfaceGraphicsBuffer *graphicsBuffer)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QIOSurfaceGraphicsBuffer(" << (const void *)graphicsBuffer;
+ if (graphicsBuffer) {
+ debug << ", surface=" << graphicsBuffer->m_surface;
+ debug << ", size=" << graphicsBuffer->size();
+ debug << ", isLocked=" << bool(graphicsBuffer->isLocked());
+ debug << ", isInUse=" << graphicsBuffer->isInUse();
+ }
+ debug << ')';
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 17063f6e92..5309449dce 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -137,22 +137,13 @@
{
if ((self = [super initWithFrame:NSZeroRect])) {
m_platformWindow = platformWindow;
- m_buttons = Qt::NoButton;
- m_acceptedMouseDowns = Qt::NoButton;
- m_frameStrutButtons = Qt::NoButton;
m_sendKeyEvent = false;
- m_sendUpAsRightButton = false;
m_inputSource = nil;
- m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self];
m_resendKeyEvent = false;
- m_scrolling = false;
m_updatingDrag = false;
m_currentlyInterpretedKeyEvent = nil;
- m_dontOverrideCtrlLMB = qt_mac_resolveOption(false, platformWindow->window(),
- "_q_platform_MacDontOverrideCtrlLMB", "QT_MAC_DONT_OVERRIDE_CTRL_LMB");
self.focusRingType = NSFocusRingTypeNone;
- self.cursor = nil;
self.previousSuperview = nil;
self.previousWindow = nil;
diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm
index 1c38c5326c..002cb3279e 100644
--- a/src/plugins/platforms/cocoa/qnsview_dragging.mm
+++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm
@@ -57,9 +57,9 @@
NSFilesPromisePboardType, NSInkTextPboardType,
NSMultipleTextSelectionPboardType, mimeTypeGeneric]];
- // Add custom types supported by the application.
+ // Add custom types supported by the application
for (const QString &customType : qt_mac_enabledDraggedTypes())
- [supportedTypes addObject:customType.toNSString()];
+ [supportedTypes addObject:customType.toNSString()];
[self registerForDraggedTypes:supportedTypes];
}
@@ -79,11 +79,11 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
return target->mapFromGlobal(source->mapToGlobal(point));
}
-- (NSDragOperation)draggingSession:(NSDraggingSession *)session
- sourceOperationMaskForDraggingContext:(NSDraggingContext)context
+- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
{
Q_UNUSED(session);
Q_UNUSED(context);
+
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
return qt_mac_mapDropActions(nativeDrag->currentDrag()->supportedActions());
}
@@ -134,30 +134,29 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
if (pixmapCursor.isNull()) {
switch (response.acceptedAction()) {
- case Qt::CopyAction:
- nativeCursor = [NSCursor dragCopyCursor];
- break;
- case Qt::LinkAction:
- nativeCursor = [NSCursor dragLinkCursor];
- break;
- case Qt::IgnoreAction:
- // Uncomment the next lines if forbiden cursor wanted on non droppable targets.
- /*nativeCursor = [NSCursor operationNotAllowedCursor];
- break;*/
- case Qt::MoveAction:
- default:
- nativeCursor = [NSCursor arrowCursor];
- break;
+ case Qt::CopyAction:
+ nativeCursor = [NSCursor dragCopyCursor];
+ break;
+ case Qt::LinkAction:
+ nativeCursor = [NSCursor dragLinkCursor];
+ break;
+ case Qt::IgnoreAction:
+ // Uncomment the next lines if forbidden cursor is wanted on undroppable targets.
+ /*nativeCursor = [NSCursor operationNotAllowedCursor];
+ break;*/
+ case Qt::MoveAction:
+ default:
+ nativeCursor = [NSCursor arrowCursor];
+ break;
}
- }
- else {
+ } else {
NSImage *nsimage = qt_mac_create_nsimage(pixmapCursor);
nsimage.size = NSSizeFromCGSize((pixmapCursor.size() / pixmapCursor.devicePixelRatioF()).toCGSize());
nativeCursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSZeroPoint];
[nsimage release];
}
- // change the cursor
+ // Change the cursor
[nativeCursor set];
// Make sure the cursor is updated correctly if the mouse does not move and window is under cursor
@@ -169,39 +168,33 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
if (m_updatingDrag)
return;
- const QPoint mousePos(QCursor::pos());
- CGEventRef moveEvent(CGEventCreateMouseEvent(
- NULL, kCGEventMouseMoved,
- CGPointMake(mousePos.x(), mousePos.y()),
+ QCFType<CGEventRef> moveEvent = CGEventCreateMouseEvent(
+ nullptr, kCGEventMouseMoved, QCursor::pos().toCGPoint(),
kCGMouseButtonLeft // ignored
- ));
+ );
CGEventPost(kCGHIDEventTap, moveEvent);
- CFRelease(moveEvent);
}
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
{
- return [self handleDrag : sender];
+ return [self handleDrag:(QEvent::DragEnter) sender:sender];
}
-- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
+- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender
{
- m_updatingDrag = true;
- const NSDragOperation ret([self handleDrag : sender]);
- m_updatingDrag = false;
-
- return ret;
+ QScopedValueRollback<bool> rollback(m_updatingDrag, true);
+ return [self handleDrag:(QEvent::DragMove) sender:sender];
}
// Sends drag update to Qt, return the action
-- (NSDragOperation)handleDrag:(id <NSDraggingInfo>)sender
+- (NSDragOperation)handleDrag:(QEvent::Type)dragType sender:(id<NSDraggingInfo>)sender
{
if (!m_platformWindow)
return NSDragOperationNone;
- NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil];
- QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
- Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]);
+ QPoint windowPoint = QPointF::fromCGPoint([self convertPoint:sender.draggingLocation fromView:nil]).toPoint();
+
+ Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(sender.draggingSourceOperationMask);
QWindow *target = findEventTargetWindow(m_platformWindow->window());
if (!target)
@@ -209,7 +202,12 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
const auto modifiers = [QNSView convertKeyModifiers:NSApp.currentEvent.modifierFlags];
const auto buttons = currentlyPressedMouseButtons();
- const auto point = mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint);
+ const auto point = mapWindowCoordinates(m_platformWindow->window(), target, windowPoint);
+
+ if (dragType == QEvent::DragEnter)
+ qCDebug(lcQpaMouse) << dragType << self << "at" << windowPoint;
+ else
+ qCDebug(lcQpaMouse) << dragType << "at" << windowPoint << "with" << buttons;
QPlatformDragQtResponse response(false, Qt::IgnoreAction, QRect());
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
@@ -219,7 +217,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
point, qtAllowed, buttons, modifiers);
[self updateCursorFromDragResponse:response drag:nativeDrag];
} else {
- QCocoaDropData mimeData([sender draggingPasteboard]);
+ QCocoaDropData mimeData(sender.draggingPasteboard);
response = QWindowSystemInterface::handleDrag(target, &mimeData,
point, qtAllowed, buttons, modifiers);
}
@@ -227,7 +225,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
return qt_mac_mapDropAction(response.acceptedAction());
}
-- (void)draggingExited:(id <NSDraggingInfo>)sender
+- (void)draggingExited:(id<NSDraggingInfo>)sender
{
if (!m_platformWindow)
return;
@@ -236,17 +234,18 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
if (!target)
return;
- NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil];
- QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
+ QPoint windowPoint = QPointF::fromCGPoint([self convertPoint:sender.draggingLocation fromView:nil]).toPoint();
+
+ qCDebug(lcQpaMouse) << QEvent::DragLeave << self << "at" << windowPoint;
// Send 0 mime data to indicate drag exit
QWindowSystemInterface::handleDrag(target, nullptr,
- mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint),
+ mapWindowCoordinates(m_platformWindow->window(), target, windowPoint),
Qt::IgnoreAction, Qt::NoButton, Qt::NoModifier);
}
-// called on drop, send the drop to Qt and return if it was accepted.
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
+// Called on drop, send the drop to Qt and return if it was accepted
+- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender
{
if (!m_platformWindow)
return false;
@@ -255,31 +254,31 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
if (!target)
return false;
- NSPoint windowPoint = [self convertPoint: [sender draggingLocation] fromView: nil];
- QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
- Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]);
+ QPoint windowPoint = QPointF::fromCGPoint([self convertPoint:sender.draggingLocation fromView:nil]).toPoint();
+
+ Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(sender.draggingSourceOperationMask);
QPlatformDropQtResponse response(false, Qt::IgnoreAction);
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
const auto modifiers = [QNSView convertKeyModifiers:NSApp.currentEvent.modifierFlags];
const auto buttons = currentlyPressedMouseButtons();
- const auto point = mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint);
+ const auto point = mapWindowCoordinates(m_platformWindow->window(), target, windowPoint);
+
+ qCDebug(lcQpaMouse) << QEvent::Drop << "at" << windowPoint << "with" << buttons;
if (nativeDrag->currentDrag()) {
// The drag was started from within the application
response = QWindowSystemInterface::handleDrop(target, nativeDrag->dragMimeData(),
point, qtAllowed, buttons, modifiers);
} else {
- QCocoaDropData mimeData([sender draggingPasteboard]);
+ QCocoaDropData mimeData(sender.draggingPasteboard);
response = QWindowSystemInterface::handleDrop(target, &mimeData,
point, qtAllowed, buttons, modifiers);
}
return response.isAccepted();
}
-- (void)draggingSession:(NSDraggingSession *)session
- endedAtPoint:(NSPoint)screenPoint
- operation:(NSDragOperation)operation
+- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation
{
Q_UNUSED(session);
Q_UNUSED(screenPoint);
@@ -295,6 +294,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
nativeDrag->setAcceptedAction(qt_mac_mapNSDragOperation(operation));
m_buttons = currentlyPressedMouseButtons();
+
+ qCDebug(lcQpaMouse) << "Drag session" << session << "ended, with" << m_buttons;
}
@end
diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm
index e9af90a45c..0cebc8d98d 100644
--- a/src/plugins/platforms/cocoa/qnsview_drawing.mm
+++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm
@@ -163,6 +163,13 @@
return NSViewLayerContentsRedrawDuringViewResize;
}
+- (NSViewLayerContentsPlacement)layerContentsPlacement
+{
+ // Always place the layer at top left without any automatic scaling,
+ // so that we can re-use larger layers when resizing a window down.
+ return NSViewLayerContentsPlacementTopLeft;
+}
+
- (void)updateMetalLayerDrawableSize:(CAMetalLayer *)layer
{
CGSize drawableSize = layer.bounds.size;
diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm
index 49c94f18db..6e3cff2b48 100644
--- a/src/plugins/platforms/cocoa/qnsview_mouse.mm
+++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm
@@ -93,6 +93,7 @@
- (void)resetMouseButtons
{
+ qCDebug(lcQpaMouse) << "Reseting mouse buttons";
m_buttons = Qt::NoButton;
m_frameStrutButtons = Qt::NoButton;
}
@@ -145,6 +146,9 @@
QPoint qtScreenPoint = QCocoaScreen::mapFromNative(screenPoint).toPoint();
ulong timestamp = [theEvent timestamp] * 1000;
+
+ auto eventType = cocoaEvent2QtMouseEvent(theEvent);
+ qCInfo(lcQpaMouse) << "Frame-strut" << eventType << "at" << qtWindowPoint << "with" << m_frameStrutButtons << "in" << self.window;
QWindowSystemInterface::handleFrameStrutMouseEvent(m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons);
}
@end
@@ -153,6 +157,19 @@
- (void)initMouse
{
+ m_buttons = Qt::NoButton;
+ m_acceptedMouseDowns = Qt::NoButton;
+ m_frameStrutButtons = Qt::NoButton;
+
+ m_scrolling = false;
+ self.cursor = nil;
+
+ m_sendUpAsRightButton = false;
+ m_dontOverrideCtrlLMB = qt_mac_resolveOption(false, m_platformWindow->window(),
+ "_q_platform_MacDontOverrideCtrlLMB", "QT_MAC_DONT_OVERRIDE_CTRL_LMB");
+
+ m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self];
+
NSUInteger trackingOptions = NSTrackingActiveInActiveApp
| NSTrackingMouseEnteredAndExited | NSTrackingCursorUpdate;
@@ -241,6 +258,11 @@
button = Qt::RightButton;
const auto eventType = cocoaEvent2QtMouseEvent(theEvent);
+ if (eventType == QEvent::MouseMove)
+ qCDebug(lcQpaMouse) << eventType << "at" << qtWindowPoint << "with" << buttons;
+ else
+ qCInfo(lcQpaMouse) << eventType << "of" << button << "at" << qtWindowPoint << "with" << buttons;
+
QWindowSystemInterface::handleMouseEvent(targetView->m_platformWindow->window(),
timestamp, qtWindowPoint, qtScreenPoint,
buttons, button, eventType, modifiers);
@@ -446,16 +468,16 @@
- (void)cursorUpdate:(NSEvent *)theEvent
{
- qCDebug(lcQpaMouse) << "Updating cursor for" << self << "to" << self.cursor;
-
// Note: We do not get this callback when moving from a subview that
// uses the legacy cursorRect API, so the cursor is reset to the arrow
// cursor. See rdar://34183708
- if (self.cursor)
+ if (self.cursor && self.cursor != NSCursor.currentCursor) {
+ qCInfo(lcQpaMouse) << "Updating cursor for" << self << "to" << self.cursor;
[self.cursor set];
- else
+ } else {
[super cursorUpdate:theEvent];
+ }
}
- (void)mouseMovedImpl:(NSEvent *)theEvent
@@ -510,6 +532,8 @@
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
m_platformWindow->m_enterLeaveTargetWindow = m_platformWindow->childWindowAt(windowPoint.toPoint());
+
+ qCInfo(lcQpaMouse) << QEvent::Enter << self << "at" << windowPoint << "with" << currentlyPressedMouseButtons();
QWindowSystemInterface::handleEnterEvent(m_platformWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
}
@@ -528,6 +552,7 @@
if (!m_platformWindow->isContentView())
return;
+ qCInfo(lcQpaMouse) << QEvent::Leave << self;
QWindowSystemInterface::handleLeaveEvent(m_platformWindow->m_enterLeaveTargetWindow);
m_platformWindow->m_enterLeaveTargetWindow = 0;
}
@@ -626,8 +651,10 @@
// "isInverted": natural OS X scrolling, inverted from the Qt/other platform/Jens perspective.
bool isInverted = [theEvent isDirectionInvertedFromDevice];
- qCDebug(lcQpaMouse) << "scroll wheel @ window pos" << qt_windowPoint << "delta px" << pixelDelta
- << "angle" << angleDelta << "phase" << phase << (isInverted ? "inverted" : "");
+ qCInfo(lcQpaMouse).nospace() << phase << " at " << qt_windowPoint
+ << " pixelDelta=" << pixelDelta << " angleDelta=" << angleDelta
+ << (isInverted ? " inverted=true" : "");
+
QWindowSystemInterface::handleWheelEvent(m_platformWindow->window(), qt_timestamp, qt_windowPoint,
qt_screenPoint, pixelDelta, angleDelta, m_currentWheelModifiers, phase, source, isInverted);
}
diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
index 285dbd93d3..11b68c0589 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
@@ -62,9 +62,6 @@ QEglFSScreen::QEglFSScreen(EGLDisplay dpy)
QEglFSScreen::~QEglFSScreen()
{
delete m_cursor;
-#ifndef QT_NO_OPENGL
- QOpenGLCompositor::destroy();
-#endif
}
QRect QEglFSScreen::geometry() const
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
index 29cfd4ea79..98e9ee4728 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
@@ -62,6 +62,7 @@ QEglFSWindow::QEglFSWindow(QWindow *w)
: QPlatformWindow(w),
#ifndef QT_NO_OPENGL
m_backingStore(0),
+ m_rasterCompositingContext(0),
#endif
m_raster(false),
m_winId(0),
@@ -144,18 +145,18 @@ void QEglFSWindow::create()
#ifndef QT_NO_OPENGL
if (isRaster()) {
- QOpenGLContext *context = new QOpenGLContext(QGuiApplication::instance());
- context->setShareContext(qt_gl_global_share_context());
- context->setFormat(m_format);
- context->setScreen(window()->screen());
- if (Q_UNLIKELY(!context->create()))
+ m_rasterCompositingContext = new QOpenGLContext;
+ m_rasterCompositingContext->setShareContext(qt_gl_global_share_context());
+ m_rasterCompositingContext->setFormat(m_format);
+ m_rasterCompositingContext->setScreen(window()->screen());
+ if (Q_UNLIKELY(!m_rasterCompositingContext->create()))
qFatal("EGLFS: Failed to create compositing context");
- compositor->setTarget(context, window(), screen->rawGeometry());
+ compositor->setTarget(m_rasterCompositingContext, window(), screen->rawGeometry());
compositor->setRotation(qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION"));
// If there is a "root" window into which raster and QOpenGLWidget content is
// composited, all other contexts must share with its context.
if (!qt_gl_global_share_context()) {
- qt_gl_set_global_share_context(context);
+ qt_gl_set_global_share_context(m_rasterCompositingContext);
// What we set up here is in effect equivalent to the application setting
// AA_ShareOpenGLContexts. Set the attribute to be fully consistent.
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
@@ -166,6 +167,10 @@ void QEglFSWindow::create()
void QEglFSWindow::destroy()
{
+#ifndef QT_NO_OPENGL
+ QOpenGLCompositor::instance()->removeWindow(this);
+#endif
+
QEglFSScreen *screen = this->screen();
if (m_flags.testFlag(HasNativeWindow)) {
#ifndef QT_NO_OPENGL
@@ -177,12 +182,14 @@ void QEglFSWindow::destroy()
screen->setPrimarySurface(EGL_NO_SURFACE);
invalidateSurface();
- }
- m_flags = 0;
#ifndef QT_NO_OPENGL
- QOpenGLCompositor::instance()->removeWindow(this);
+ QOpenGLCompositor::destroy();
+ delete m_rasterCompositingContext;
#endif
+ }
+
+ m_flags = 0;
}
void QEglFSWindow::invalidateSurface()
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
index c61f04f569..b0091e2a62 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
@@ -116,6 +116,7 @@ public:
protected:
#ifndef QT_NO_OPENGL
QOpenGLCompositorBackingStore *m_backingStore;
+ QOpenGLContext *m_rasterCompositingContext;
#endif
bool m_raster;
WId m_winId;
diff --git a/src/plugins/platforms/haiku/haiku.pro b/src/plugins/platforms/haiku/haiku.pro
index fd1f47b963..e7702361ee 100644
--- a/src/plugins/platforms/haiku/haiku.pro
+++ b/src/plugins/platforms/haiku/haiku.pro
@@ -1,6 +1,6 @@
TARGET = qhaiku
-QT += core-private gui-private eventdistpatcher_support-private
+QT += core-private gui-private eventdispatcher_support-private
SOURCES = \
main.cpp \
diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm
index fff66049ff..535e7d7aa6 100644
--- a/src/plugins/platforms/ios/qioscontext.mm
+++ b/src/plugins/platforms/ios/qioscontext.mm
@@ -306,7 +306,7 @@ bool QIOSContext::verifyGraphicsHardwareAvailability()
Q_UNUSED(oldState);
if (applicationBackgrounded && newState != Qt::ApplicationSuspended) {
qCDebug(lcQpaGLContext) << "app no longer backgrounded, rendering enabled";
- applicationBackgrounded = true;
+ applicationBackgrounded = false;
}
}
);
@@ -317,6 +317,7 @@ bool QIOSContext::verifyGraphicsHardwareAvailability()
return;
qCDebug(lcQpaGLContext) << "app backgrounded, rendering disabled";
+ applicationBackgrounded = true;
// By the time we receive this signal the application has moved into
// Qt::ApplactionStateSuspended, and all windows have been obscured,
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index db79780407..a996e765c4 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -72,6 +72,9 @@
# endif
#endif
+#include <qpa/qplatforminputcontextfactory_p.h>
+#include <qpa/qplatforminputcontext.h>
+
#include "private/qgenericunixfontdatabase_p.h"
#include "private/qgenericunixeventdispatcher_p.h"
@@ -152,6 +155,7 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
, m_inputContext(0)
, m_buttonsNotifier(new QQnxButtonEventNotifier())
#endif
+ , m_qpaInputContext(0)
, m_services(0)
, m_fontDatabase(new QGenericUnixFontDatabase())
, m_eventDispatcher(createUnixEventDispatcher())
@@ -194,13 +198,17 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
m_screenEventHandler->setScreenEventThread(m_screenEventThread);
m_screenEventThread->start();
+ m_qpaInputContext = QPlatformInputContextFactory::create();
+
#if QT_CONFIG(qqnx_pps)
- // Create/start the keyboard class.
- m_virtualKeyboard = new QQnxVirtualKeyboardPps();
+ if (!m_qpaInputContext) {
+ // Create/start the keyboard class.
+ m_virtualKeyboard = new QQnxVirtualKeyboardPps();
- // delay invocation of start() to the time the event loop is up and running
- // needed to have the QThread internals of the main thread properly initialized
- QMetaObject::invokeMethod(m_virtualKeyboard, "start", Qt::QueuedConnection);
+ // delay invocation of start() to the time the event loop is up and running
+ // needed to have the QThread internals of the main thread properly initialized
+ QMetaObject::invokeMethod(m_virtualKeyboard, "start", Qt::QueuedConnection);
+ }
#endif
#if QT_CONFIG(qqnx_pps)
@@ -281,6 +289,7 @@ QQnxIntegration::~QQnxIntegration()
// Destroy input context
delete m_inputContext;
#endif
+ delete m_qpaInputContext;
// Destroy the keyboard class.
delete m_virtualKeyboard;
@@ -397,13 +406,13 @@ QPlatformOpenGLContext *QQnxIntegration::createPlatformOpenGLContext(QOpenGLCont
}
#endif
-#if QT_CONFIG(qqnx_pps)
QPlatformInputContext *QQnxIntegration::inputContext() const
{
qIntegrationDebug();
+ if (m_qpaInputContext)
+ return m_qpaInputContext;
return m_inputContext;
}
-#endif
void QQnxIntegration::moveToScreen(QWindow *window, int screen)
{
diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h
index 4a6f15fc08..366556dc4b 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.h
+++ b/src/plugins/platforms/qnx/qqnxintegration.h
@@ -153,6 +153,7 @@ private:
QQnxInputContext *m_inputContext;
QQnxButtonEventNotifier *m_buttonsNotifier;
#endif
+ QPlatformInputContext *m_qpaInputContext;
QQnxServices *m_services;
QPlatformFontDatabase *m_fontDatabase;
mutable QAbstractEventDispatcher *m_eventDispatcher;
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 41655dbd57..80517ffe69 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -1099,6 +1099,12 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return false;
case QtWindows::ClipboardEvent:
return false;
+ case QtWindows::CursorEvent: // Sent to windows that do not have capture (see QTBUG-58590).
+ if (QWindowsCursor::hasOverrideCursor()) {
+ QWindowsCursor::enforceOverrideCursor();
+ return true;
+ }
+ break;
case QtWindows::UnknownEvent:
return false;
case QtWindows::AccessibleObjectFromWindowRequest:
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index 95d1fc8b7d..322865b0f3 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -49,6 +49,7 @@
#include "qwindowswindow.h"
#include "qwindowsmousehandler.h"
#include "qwindowscursor.h"
+#include "qwindowskeymapper.h"
#include <QtGui/qevent.h>
#include <QtGui/qpixmap.h>
@@ -205,6 +206,9 @@ static inline Qt::MouseButtons toQtMouseButtons(DWORD keyState)
return buttons;
}
+static Qt::KeyboardModifiers lastModifiers = Qt::NoModifier;
+static Qt::MouseButtons lastButtons = Qt::NoButton;
+
/*!
\class QWindowsOleDropSource
\brief Implementation of IDropSource
@@ -403,7 +407,7 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
case DRAGDROP_S_DROP:
case DRAGDROP_S_CANCEL:
if (!m_windowUnderMouse.isNull() && m_mode != TouchDrag && fEscapePressed == FALSE
- && buttons != QGuiApplicationPrivate::mouse_buttons) {
+ && buttons != lastButtons) {
// QTBUG 66447: Synthesize a mouse release to the window under mouse at
// start of the DnD operation as Windows does not send any.
const QPoint globalPos = QWindowsCursor::mousePosition();
@@ -503,13 +507,14 @@ void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState,
QWindowsDrag *windowsDrag = QWindowsDrag::instance();
const Qt::DropActions actions = translateToQDragDropActions(*pdwEffect);
- const Qt::KeyboardModifiers keyboardModifiers = toQtKeyboardModifiers(grfKeyState);
- const Qt::MouseButtons mouseButtons = toQtMouseButtons(grfKeyState);
+
+ lastModifiers = toQtKeyboardModifiers(grfKeyState);
+ lastButtons = toQtMouseButtons(grfKeyState);
const QPlatformDragQtResponse response =
QWindowSystemInterface::handleDrag(window, windowsDrag->dropData(),
m_lastPoint, actions,
- mouseButtons, keyboardModifiers);
+ lastButtons, lastModifiers);
m_answerRect = response.answerRect();
const Qt::DropAction action = response.acceptedAction();
@@ -521,7 +526,7 @@ void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState,
*pdwEffect = m_chosenEffect;
qCDebug(lcQpaMime) << __FUNCTION__ << m_window
<< windowsDrag->dropData() << " supported actions=" << actions
- << " mods=" << keyboardModifiers << " mouse=" << mouseButtons
+ << " mods=" << lastModifiers << " mouse=" << lastButtons
<< " accepted: " << response.isAccepted() << action
<< m_answerRect << " effect" << *pdwEffect;
}
@@ -572,6 +577,9 @@ QWindowsOleDropTarget::DragLeave()
qCDebug(lcQpaMime) << __FUNCTION__ << ' ' << m_window;
+ lastModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
+ lastButtons = QWindowsMouseHandler::queryMouseButtons();
+
QWindowSystemInterface::handleDrag(m_window, nullptr, QPoint(), Qt::IgnoreAction,
Qt::NoButton, Qt::NoModifier);
@@ -598,12 +606,15 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState,
QWindowsDrag *windowsDrag = QWindowsDrag::instance();
+ lastModifiers = toQtKeyboardModifiers(grfKeyState);
+ lastButtons = toQtMouseButtons(grfKeyState);
+
const QPlatformDropQtResponse response =
QWindowSystemInterface::handleDrop(m_window, windowsDrag->dropData(),
m_lastPoint,
translateToQDragDropActions(*pdwEffect),
- toQtMouseButtons(grfKeyState),
- toQtKeyboardModifiers(grfKeyState));
+ lastButtons,
+ lastModifiers);
m_lastKeyState = grfKeyState;
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index 32eec322e8..ed945ec4b1 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -289,4 +289,13 @@ QVariant QWindowsNativeInterface::gpu() const
return GpuDescription::detect().toVariant();
}
+QVariant QWindowsNativeInterface::gpuList() const
+{
+ QVariantList result;
+ const auto gpus = GpuDescription::detectAll();
+ for (const auto &gpu : gpus)
+ result.append(gpu.toVariant());
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index d085a4afb3..e6f8aae8fb 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -66,6 +66,7 @@ class QWindowsNativeInterface : public QPlatformNativeInterface
Q_OBJECT
Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose)
Q_PROPERTY(QVariant gpu READ gpu STORED false)
+ Q_PROPERTY(QVariant gpuList READ gpuList STORED false)
public:
void *nativeResourceForIntegration(const QByteArray &resource) override;
@@ -91,6 +92,7 @@ public:
void setAsyncExpose(bool value);
QVariant gpu() const;
+ QVariant gpuList() const;
QVariantMap windowProperties(QPlatformWindow *window) const override;
QVariant windowProperty(QPlatformWindow *window, const QString &name) const override;
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
index 2046135725..840a3a11c4 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -62,19 +62,70 @@ QT_BEGIN_NAMESPACE
static const DWORD VENDOR_ID_AMD = 0x1002;
-GpuDescription GpuDescription::detect()
+static GpuDescription adapterIdentifierToGpuDescription(const D3DADAPTER_IDENTIFIER9 &adapterIdentifier)
+{
+ GpuDescription result;
+ result.vendorId = adapterIdentifier.VendorId;
+ result.deviceId = adapterIdentifier.DeviceId;
+ result.revision = adapterIdentifier.Revision;
+ result.subSysId = adapterIdentifier.SubSysId;
+ QVector<int> version(4, 0);
+ version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product
+ version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version
+ version[2] = HIWORD(adapterIdentifier.DriverVersion.LowPart); // Sub version
+ version[3] = LOWORD(adapterIdentifier.DriverVersion.LowPart); // build
+ result.driverVersion = QVersionNumber(version);
+ result.driverName = adapterIdentifier.Driver;
+ result.description = adapterIdentifier.Description;
+ return result;
+}
+
+class QDirect3D9Handle
+{
+public:
+ Q_DISABLE_COPY(QDirect3D9Handle)
+
+ QDirect3D9Handle();
+ ~QDirect3D9Handle();
+
+ bool isValid() const { return m_direct3D9 != nullptr; }
+
+ UINT adapterCount() const { return m_direct3D9 ? m_direct3D9->GetAdapterCount() : 0u; }
+ bool retrieveAdapterIdentifier(UINT n, D3DADAPTER_IDENTIFIER9 *adapterIdentifier) const;
+
+private:
+ QSystemLibrary m_d3d9lib;
+ IDirect3D9 *m_direct3D9 = nullptr;
+};
+
+QDirect3D9Handle::QDirect3D9Handle() :
+ m_d3d9lib(QStringLiteral("d3d9"))
{
- typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT);
+ using PtrDirect3DCreate9 = IDirect3D9 *(WINAPI *)(UINT);
+ if (m_d3d9lib.load()) {
+ if (auto direct3DCreate9 = (PtrDirect3DCreate9)m_d3d9lib.resolve("Direct3DCreate9"))
+ m_direct3D9 = direct3DCreate9(D3D_SDK_VERSION);
+ }
+}
+
+QDirect3D9Handle::~QDirect3D9Handle()
+{
+ if (m_direct3D9)
+ m_direct3D9->Release();
+}
+
+bool QDirect3D9Handle::retrieveAdapterIdentifier(UINT n, D3DADAPTER_IDENTIFIER9 *adapterIdentifier) const
+{
+ return m_direct3D9
+ && SUCCEEDED(m_direct3D9->GetAdapterIdentifier(n, 0, adapterIdentifier));
+}
+
+GpuDescription GpuDescription::detect()
+{
GpuDescription result;
- QSystemLibrary d3d9lib(QStringLiteral("d3d9"));
- if (!d3d9lib.load())
- return result;
- PtrDirect3DCreate9 direct3DCreate9 = (PtrDirect3DCreate9)d3d9lib.resolve("Direct3DCreate9");
- if (!direct3DCreate9)
- return result;
- IDirect3D9 *direct3D9 = direct3DCreate9(D3D_SDK_VERSION);
- if (!direct3D9)
+ QDirect3D9Handle direct3D9;
+ if (!direct3D9.isValid())
return result;
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
@@ -85,20 +136,8 @@ GpuDescription GpuDescription::detect()
// and D3D uses by default. Therefore querying any additional adapters is
// futile and not useful for our purposes in general, except for
// identifying a few special cases later on.
- HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier);
- if (SUCCEEDED(hr)) {
- result.vendorId = adapterIdentifier.VendorId;
- result.deviceId = adapterIdentifier.DeviceId;
- result.revision = adapterIdentifier.Revision;
- result.subSysId = adapterIdentifier.SubSysId;
- QVector<int> version(4, 0);
- version[0] = HIWORD(adapterIdentifier.DriverVersion.HighPart); // Product
- version[1] = LOWORD(adapterIdentifier.DriverVersion.HighPart); // Version
- version[2] = HIWORD(adapterIdentifier.DriverVersion.LowPart); // Sub version
- version[3] = LOWORD(adapterIdentifier.DriverVersion.LowPart); // build
- result.driverVersion = QVersionNumber(version);
- result.driverName = adapterIdentifier.Driver;
- result.description = adapterIdentifier.Description;
+ if (direct3D9.retrieveAdapterIdentifier(0, &adapterIdentifier)) {
+ result = adapterIdentifierToGpuDescription(adapterIdentifier);
isAMD = result.vendorId == VENDOR_ID_AMD;
}
@@ -106,30 +145,41 @@ GpuDescription GpuDescription::detect()
// when starting apps on a screen connected to the Intel card) by looking
// for a default AMD adapter and an additional non-AMD one.
if (isAMD) {
- const UINT adapterCount = direct3D9->GetAdapterCount();
+ const UINT adapterCount = direct3D9.adapterCount();
for (UINT adp = 1; adp < adapterCount; ++adp) {
- hr = direct3D9->GetAdapterIdentifier(adp, 0, &adapterIdentifier);
- if (SUCCEEDED(hr)) {
- if (adapterIdentifier.VendorId != VENDOR_ID_AMD) {
- // Bingo. Now figure out the display for the AMD card.
- DISPLAY_DEVICE dd;
- memset(&dd, 0, sizeof(dd));
- dd.cb = sizeof(dd);
- for (int dev = 0; EnumDisplayDevices(nullptr, dev, &dd, 0); ++dev) {
- if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
- // DeviceName is something like \\.\DISPLAY1 which can be used to
- // match with the MONITORINFOEX::szDevice queried by QWindowsScreen.
- result.gpuSuitableScreen = QString::fromWCharArray(dd.DeviceName);
- break;
- }
+ if (direct3D9.retrieveAdapterIdentifier(adp, &adapterIdentifier)
+ && adapterIdentifier.VendorId != VENDOR_ID_AMD) {
+ // Bingo. Now figure out the display for the AMD card.
+ DISPLAY_DEVICE dd;
+ memset(&dd, 0, sizeof(dd));
+ dd.cb = sizeof(dd);
+ for (int dev = 0; EnumDisplayDevices(nullptr, dev, &dd, 0); ++dev) {
+ if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
+ // DeviceName is something like \\.\DISPLAY1 which can be used to
+ // match with the MONITORINFOEX::szDevice queried by QWindowsScreen.
+ result.gpuSuitableScreen = QString::fromWCharArray(dd.DeviceName);
+ break;
}
- break;
}
+ break;
}
}
}
- direct3D9->Release();
+ return result;
+}
+
+QVector<GpuDescription> GpuDescription::detectAll()
+{
+ QVector<GpuDescription> result;
+ QDirect3D9Handle direct3D9;
+ if (const UINT adapterCount = direct3D9.adapterCount()) {
+ for (UINT adp = 0; adp < adapterCount; ++adp) {
+ D3DADAPTER_IDENTIFIER9 adapterIdentifier;
+ if (direct3D9.retrieveAdapterIdentifier(adp, &adapterIdentifier))
+ result.append(adapterIdentifierToGpuDescription(adapterIdentifier));
+ }
+ }
return result;
}
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h
index 08628c2586..9576dfbae0 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.h
+++ b/src/plugins/platforms/windows/qwindowsopengltester.h
@@ -42,6 +42,7 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qflags.h>
+#include <QtCore/qvector.h>
#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -52,6 +53,7 @@ class QVariant;
struct GpuDescription
{
static GpuDescription detect();
+ static QVector<GpuDescription> detectAll();
QString toString() const;
QVariant toVariant() const;
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index c5d57be2ad..2c0ffc9b26 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -746,7 +746,8 @@ QWindowsWindowData
const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle));
QWindowsContext::instance()->setWindowCreationContext(context);
- QMargins invMargins = topLevel && !(result.flags & Qt::FramelessWindowHint) && QWindowsGeometryHint::positionIncludesFrame(w)
+ const bool hasFrame = (style & (WS_DLGFRAME | WS_THICKFRAME));
+ QMargins invMargins = topLevel && hasFrame && QWindowsGeometryHint::positionIncludesFrame(w)
? invisibleMargins(QPoint(context->frameX, context->frameY)) : QMargins();
qCDebug(lcQpaWindows).nospace()
@@ -777,6 +778,7 @@ QWindowsWindowData
result.geometry = context->obtainedGeometry;
result.fullFrameMargins = context->margins;
result.embedded = embedded;
+ result.hasFrame = hasFrame;
result.customMargins = context->customMargins;
return result;
@@ -2232,7 +2234,7 @@ void QWindowsWindow::setFullFrameMargins(const QMargins &newMargins)
QMargins QWindowsWindow::frameMargins() const
{
QMargins result = fullFrameMargins();
- if (isTopLevel() && !(m_data.flags & Qt::FramelessWindowHint))
+ if (isTopLevel() && m_data.hasFrame)
result -= invisibleMargins(geometry().topLeft());
return result;
}
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index b9b398b67b..2675990cf1 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -112,6 +112,7 @@ struct QWindowsWindowData
QMargins customMargins; // User-defined, additional frame for NCCALCSIZE
HWND hwnd = 0;
bool embedded = false;
+ bool hasFrame = false;
static QWindowsWindowData create(const QWindow *w,
const QWindowsWindowData &parameters,
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 47036ca257..15537fede4 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -187,10 +187,10 @@ public:
void addPeekFunc(PeekFunc f);
inline xcb_timestamp_t time() const { return m_time; }
- inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; }
+ inline void setTime(xcb_timestamp_t t) { if (timeGreaterThan(t, m_time)) m_time = t; }
inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; }
- inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; }
+ inline void setNetWmUserTime(xcb_timestamp_t t) { if (timeGreaterThan(t, m_netWmUserTime)) m_netWmUserTime = t; }
xcb_timestamp_t getTimestamp();
xcb_window_t getSelectionOwner(xcb_atom_t atom) const;
@@ -264,6 +264,8 @@ private:
void destroyScreen(QXcbScreen *screen);
void initializeScreens();
bool compressEvent(xcb_generic_event_t *event) const;
+ inline bool timeGreaterThan(xcb_timestamp_t a, xcb_timestamp_t b) const
+ { return static_cast<int32_t>(a - b) > 0 || b == XCB_CURRENT_TIME; }
#if QT_CONFIG(xcb_xinput)
void xi2SetupDevice(void *info, bool removeExisting = true);
diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.h b/src/plugins/platforms/xcb/qxcbconnection_basic.h
index ca91f7fa45..6e407a5f80 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_basic.h
+++ b/src/plugins/platforms/xcb/qxcbconnection_basic.h
@@ -40,6 +40,7 @@
#define QXCBBASICCONNECTION_H
#include "qxcbatom.h"
+#include "qxcbexport.h"
#include <QtCore/QPair>
#include <QtCore/QObject>
@@ -55,7 +56,7 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcQpaXcb)
-class QXcbBasicConnection : public QObject
+class Q_XCB_EXPORT QXcbBasicConnection : public QObject
{
Q_OBJECT
public:
diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
index 5e94d1558e..dcf52921aa 100644
--- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
@@ -48,6 +48,7 @@
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
+#include <QFile>
#include <QMetaType>
#include <QMimeType>
#include <QMimeDatabase>
@@ -181,10 +182,10 @@ void QXdgDesktopPortalFileDialog::openPortal()
if (d->saveFile) {
if (!d->directory.isEmpty())
- options.insert(QLatin1String("current_folder"), d->directory.toLatin1().append('\0'));
+ options.insert(QLatin1String("current_folder"), QFile::encodeName(d->directory).append('\0'));
if (!d->selectedFiles.isEmpty())
- options.insert(QLatin1String("current_file"), d->selectedFiles.first().toLatin1().append('\0'));
+ options.insert(QLatin1String("current_file"), QFile::encodeName(d->selectedFiles.first()).append('\0'));
}
// Insert filters
diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
index f07ca3f098..fb65f6d909 100644
--- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
@@ -185,11 +185,13 @@ QIconEngine * QXdgDesktopPortalTheme::createIconEngine(const QString &iconName)
return d->baseTheme->createIconEngine(iconName);
}
+#if QT_CONFIG(shortcut)
QList<QKeySequence> QXdgDesktopPortalTheme::keyBindings(QKeySequence::StandardKey key) const
{
Q_D(const QXdgDesktopPortalTheme);
return d->baseTheme->keyBindings(key);
}
+#endif
QString QXdgDesktopPortalTheme::standardButtonText(int button) const
{
diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h
index b72e676419..4c5f474595 100644
--- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h
+++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h
@@ -76,7 +76,9 @@ public:
QIconEngine *createIconEngine(const QString &iconName) const override;
+#if QT_CONFIG(shortcut)
QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const override;
+#endif
QString standardButtonText(int button) const override;
diff --git a/src/testlib/qappletestlogger.cpp b/src/testlib/qappletestlogger.cpp
index 8e75da88f8..959ff6cf64 100644
--- a/src/testlib/qappletestlogger.cpp
+++ b/src/testlib/qappletestlogger.cpp
@@ -55,9 +55,8 @@ bool QAppleTestLogger::debugLoggingEnabled()
return os_log_type_enabled(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG);
}
-QAppleTestLogger::QAppleTestLogger(QAbstractTestLogger *logger)
+QAppleTestLogger::QAppleTestLogger()
: QAbstractTestLogger(nullptr)
- , m_logger(logger)
{
}
@@ -65,6 +64,8 @@ static QAppleLogActivity testFunctionActivity;
void QAppleTestLogger::enterTestFunction(const char *function)
{
+ Q_UNUSED(function);
+
// Re-create activity each time
testFunctionActivity = QT_APPLE_LOG_ACTIVITY("Running test function").enter();
@@ -73,15 +74,12 @@ void QAppleTestLogger::enterTestFunction(const char *function)
QString identifier = QString::fromLatin1(testIdentifier.data());
QMessageLogContext context(nullptr, 0, nullptr, "qt.test.enter");
QString message = identifier;
- if (AppleUnifiedLogger::messageHandler(QtDebugMsg, context, message, identifier))
- return; // AUL already printed to stderr
- m_logger->enterTestFunction(function);
+ AppleUnifiedLogger::messageHandler(QtDebugMsg, context, message, identifier);
}
void QAppleTestLogger::leaveTestFunction()
{
- m_logger->leaveTestFunction();
testFunctionActivity.leave();
}
@@ -134,18 +132,12 @@ void QAppleTestLogger::addIncident(IncidentTypes type, const char *description,
if (qstrlen(description))
message += QLatin1Char('\n') % QString::fromLatin1(description);
- if (AppleUnifiedLogger::messageHandler(incidentClassification.first, context, message, subsystem))
- return; // AUL already printed to stderr
-
- m_logger->addIncident(type, description, file, line);
+ AppleUnifiedLogger::messageHandler(incidentClassification.first, context, message, subsystem);
}
void QAppleTestLogger::addMessage(QtMsgType type, const QMessageLogContext &context, const QString &message)
{
- if (AppleUnifiedLogger::messageHandler(type, context, message))
- return; // AUL already printed to stderr
-
- m_logger->addMessage(type, context, message);
+ AppleUnifiedLogger::messageHandler(type, context, message);
}
#endif // QT_USE_APPLE_UNIFIED_LOGGING
diff --git a/src/testlib/qappletestlogger_p.h b/src/testlib/qappletestlogger_p.h
index 5a45fad7a0..4217f4e6a2 100644
--- a/src/testlib/qappletestlogger_p.h
+++ b/src/testlib/qappletestlogger_p.h
@@ -63,12 +63,7 @@ class QAppleTestLogger : public QAbstractTestLogger
public:
static bool debugLoggingEnabled();
- QAppleTestLogger(QAbstractTestLogger *logger);
-
- void startLogging() override
- { m_logger->startLogging(); }
- void stopLogging() override
- { m_logger->stopLogging(); }
+ QAppleTestLogger();
void enterTestFunction(const char *function) override;
void leaveTestFunction() override;
@@ -77,16 +72,12 @@ public:
const char *file = 0, int line = 0) override;
void addMessage(QtMsgType, const QMessageLogContext &,
const QString &) override;
-
- void addBenchmarkResult(const QBenchmarkResult &result) override
- { m_logger->addBenchmarkResult(result); }
-
void addMessage(MessageTypes type, const QString &message,
const char *file = 0, int line = 0) override
- { m_logger->addMessage(type, message, file, line); }
+ { Q_UNUSED(type); Q_UNUSED(message); Q_UNUSED(file); Q_UNUSED(line); Q_UNREACHABLE(); }
-private:
- QScopedPointer<QAbstractTestLogger> m_logger;
+ void addBenchmarkResult(const QBenchmarkResult &result) override
+ { Q_UNUSED(result); }
};
#endif
diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp
index f430294142..ae2913da9a 100644
--- a/src/testlib/qtestblacklist.cpp
+++ b/src/testlib/qtestblacklist.cpp
@@ -104,6 +104,7 @@ static QSet<QByteArray> keywords()
#endif
#ifdef Q_OS_OSX
<< "osx"
+ << "macos"
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
<< "windows"
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 22e8ac49bc..0c935a1f1c 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -77,6 +77,10 @@
#include <QtTest/private/qtestutil_macos_p.h>
#endif
+#if defined(Q_OS_DARWIN)
+#include <QtTest/private/qappletestlogger_p.h>
+#endif
+
#include <cmath>
#include <numeric>
#include <algorithm>
@@ -509,7 +513,7 @@ static int qToInt(char *str)
Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
{
- QTestLog::LogMode logFormat = QTestLog::Plain;
+ int logFormat = -1; // Not set
const char *logFilename = 0;
QTest::testFunctions.clear();
@@ -677,7 +681,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
fprintf(stderr, "only one logger can log to stdout\n");
exit(1);
}
- QTestLog::addLogger(logFormat, filename);
+ QTestLog::addLogger(QTestLog::LogMode(logFormat), filename);
}
delete [] filename;
delete [] format;
@@ -839,10 +843,25 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
QTestLog::setInstalledTestCoverage(installedTestCoverage);
// If no loggers were created by the long version of the -o command-line
- // option, create a logger using whatever filename and format were
- // set using the old-style command-line options.
- if (QTestLog::loggerCount() == 0)
- QTestLog::addLogger(logFormat, logFilename);
+ // option, but a logger was requested via the old-style option, add it.
+ const bool explicitLoggerRequested = logFormat != -1;
+ if (QTestLog::loggerCount() == 0 && explicitLoggerRequested)
+ QTestLog::addLogger(QTestLog::LogMode(logFormat), logFilename);
+
+ bool addFallbackLogger = !explicitLoggerRequested;
+
+#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
+ // Any explicitly requested loggers will be added by now, so we can check if they use stdout
+ const bool safeToAddAppleLogger = !AppleUnifiedLogger::willMirrorToStderr() || !QTestLog::loggerUsingStdout();
+ if (safeToAddAppleLogger && QAppleTestLogger::debugLoggingEnabled()) {
+ QTestLog::addLogger(QTestLog::Apple, nullptr);
+ if (AppleUnifiedLogger::willMirrorToStderr() && !logFilename)
+ addFallbackLogger = false; // Prevent plain test logger fallback below
+ }
+#endif
+
+ if (addFallbackLogger)
+ QTestLog::addLogger(QTestLog::Plain, logFilename);
}
QBenchmarkResult qMedian(const QVector<QBenchmarkResult> &container)
diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h
index 63501ffb1e..e8a7e0d5f5 100644
--- a/src/testlib/qtestkeyboard.h
+++ b/src/testlib/qtestkeyboard.h
@@ -166,6 +166,7 @@ namespace QTest
Q_DECL_UNUSED inline static void keyPress(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
{ keyEvent(Press, window, key, modifier, delay); }
+#if QT_CONFIG(shortcut)
Q_DECL_UNUSED inline static void keySequence(QWindow *window, const QKeySequence &keySequence)
{
for (int i = 0; i < keySequence.count(); ++i) {
@@ -174,6 +175,7 @@ namespace QTest
keyClick(window, key, modifiers);
}
}
+#endif
#ifdef QT_WIDGETS_LIB
static void simulateEvent(QWidget *widget, bool press, int code,
@@ -305,6 +307,7 @@ namespace QTest
inline static void keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
{ keyEvent(Click, widget, key, modifier, delay); }
+#if QT_CONFIG(shortcut)
inline static void keySequence(QWidget *widget, const QKeySequence &keySequence)
{
for (int i = 0; i < keySequence.count(); ++i) {
@@ -313,6 +316,7 @@ namespace QTest
keyClick(widget, key, modifiers);
}
}
+#endif
#endif // QT_WIDGETS_LIB
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
index 3285a6d8a7..57bb7d95a7 100644
--- a/src/testlib/qtestlog.cpp
+++ b/src/testlib/qtestlog.cpp
@@ -60,6 +60,7 @@
#include <QtCore/qbytearray.h>
#include <QtCore/QElapsedTimer>
#include <QtCore/QVariant>
+#include <QtCore/qvector.h>
#if QT_CONFIG(regularexpression)
#include <QtCore/QRegularExpression>
#endif
@@ -93,6 +94,8 @@ static void saveCoverageTool(const char * appname, bool testfailed, bool install
static QElapsedTimer elapsedFunctionTime;
static QElapsedTimer elapsedTotalTime;
+#define FOREACH_TEST_LOGGER for (QAbstractTestLogger *logger : QTest::loggers)
+
namespace QTest {
int fails = 0;
@@ -160,109 +163,7 @@ namespace QTest {
static IgnoreResultList *ignoreResultList = 0;
- struct LoggerList
- {
- QAbstractTestLogger *logger;
- LoggerList *next;
- };
-
- class TestLoggers
- {
- public:
- static void addLogger(QAbstractTestLogger *logger)
- {
- LoggerList *l = new LoggerList;
- l->logger = logger;
- l->next = loggers;
- loggers = l;
- }
-
- static void destroyLoggers()
- {
- while (loggers) {
- LoggerList *l = loggers;
- loggers = loggers->next;
- delete l->logger;
- delete l;
- }
- }
-
-#define FOREACH_LOGGER(operation) \
- LoggerList *l = loggers; \
- while (l) { \
- QAbstractTestLogger *logger = l->logger; \
- Q_UNUSED(logger); \
- operation; \
- l = l->next; \
- }
-
- static void startLogging()
- {
- FOREACH_LOGGER(logger->startLogging());
- }
-
- static void stopLogging()
- {
- FOREACH_LOGGER(logger->stopLogging());
- }
-
- static void enterTestFunction(const char *function)
- {
- FOREACH_LOGGER(logger->enterTestFunction(function));
- }
-
- static void leaveTestFunction()
- {
- FOREACH_LOGGER(logger->leaveTestFunction());
- }
-
- static void enterTestData(QTestData *data)
- {
- FOREACH_LOGGER(logger->enterTestData(data));
- }
-
- static void addIncident(QAbstractTestLogger::IncidentTypes type, const char *description,
- const char *file = 0, int line = 0)
- {
- FOREACH_LOGGER(logger->addIncident(type, description, file, line));
- }
-
- static void addBenchmarkResult(const QBenchmarkResult &result)
- {
- FOREACH_LOGGER(logger->addBenchmarkResult(result));
- }
-
- static void addMessage(QtMsgType type, const QMessageLogContext &context,
- const QString &message)
- {
- FOREACH_LOGGER(logger->addMessage(type, context, message));
- }
-
- static void addMessage(QAbstractTestLogger::MessageTypes type, const QString &message,
- const char *file = 0, int line = 0)
- {
- FOREACH_LOGGER(logger->addMessage(type, message, file, line));
- }
-
- static void outputString(const char *msg)
- {
- FOREACH_LOGGER(logger->outputString(msg));
- }
-
- static int loggerCount()
- {
- int count = 0;
- FOREACH_LOGGER(++count);
- return count;
- }
-
- private:
- static LoggerList *loggers;
- };
-
-#undef FOREACH_LOGGER
-
- LoggerList *TestLoggers::loggers = 0;
+ static QVector<QAbstractTestLogger*> loggers;
static bool loggerUsingStdout = false;
static int verbosity = 0;
@@ -301,10 +202,10 @@ namespace QTest {
{
static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(QTest::maxWarnings);
- if (QTest::TestLoggers::loggerCount() == 0) {
+ if (QTestLog::loggerCount() == 0) {
// if this goes wrong, something is seriously broken.
qInstallMessageHandler(oldMessageHandler);
- QTEST_ASSERT(QTest::TestLoggers::loggerCount() != 0);
+ QTEST_ASSERT(QTestLog::loggerCount() != 0);
}
if (handleIgnoredMessage(type, message)) {
@@ -317,13 +218,16 @@ namespace QTest {
return;
if (!counter.deref()) {
- QTest::TestLoggers::addMessage(QAbstractTestLogger::QSystem,
+ FOREACH_TEST_LOGGER {
+ logger->addMessage(QAbstractTestLogger::QSystem,
QStringLiteral("Maximum amount of warnings exceeded. Use -maxwarnings to override."));
+ }
return;
}
}
- QTest::TestLoggers::addMessage(type, context, message);
+ FOREACH_TEST_LOGGER
+ logger->addMessage(type, context, message);
if (type == QtFatalMsg) {
/* Right now, we're inside the custom message handler and we're
@@ -346,13 +250,16 @@ void QTestLog::enterTestFunction(const char* function)
QTEST_ASSERT(function);
- QTest::TestLoggers::enterTestFunction(function);
+ FOREACH_TEST_LOGGER
+ logger->enterTestFunction(function);
}
void QTestLog::enterTestData(QTestData *data)
{
QTEST_ASSERT(data);
- QTest::TestLoggers::enterTestData(data);
+
+ FOREACH_TEST_LOGGER
+ logger->enterTestData(data);
}
int QTestLog::unhandledIgnoreMessages()
@@ -371,7 +278,8 @@ void QTestLog::leaveTestFunction()
if (printAvailableTags)
return;
- QTest::TestLoggers::leaveTestFunction();
+ FOREACH_TEST_LOGGER
+ logger->leaveTestFunction();
}
void QTestLog::printUnhandledIgnoreMessages()
@@ -386,7 +294,8 @@ void QTestLog::printUnhandledIgnoreMessages()
message = QStringLiteral("Did not receive any message matching: \"") + list->pattern.toRegularExpression().pattern() + QLatin1Char('"');
#endif
}
- QTest::TestLoggers::addMessage(QAbstractTestLogger::Info, message);
+ FOREACH_TEST_LOGGER
+ logger->addMessage(QAbstractTestLogger::Info, message);
list = list->next;
}
@@ -406,7 +315,8 @@ void QTestLog::addPass(const char *msg)
++QTest::passes;
- QTest::TestLoggers::addIncident(QAbstractTestLogger::Pass, msg);
+ FOREACH_TEST_LOGGER
+ logger->addIncident(QAbstractTestLogger::Pass, msg);
}
void QTestLog::addFail(const char *msg, const char *file, int line)
@@ -415,7 +325,8 @@ void QTestLog::addFail(const char *msg, const char *file, int line)
++QTest::fails;
- QTest::TestLoggers::addIncident(QAbstractTestLogger::Fail, msg, file, line);
+ FOREACH_TEST_LOGGER
+ logger->addIncident(QAbstractTestLogger::Fail, msg, file, line);
}
void QTestLog::addXFail(const char *msg, const char *file, int line)
@@ -423,7 +334,8 @@ void QTestLog::addXFail(const char *msg, const char *file, int line)
QTEST_ASSERT(msg);
QTEST_ASSERT(file);
- QTest::TestLoggers::addIncident(QAbstractTestLogger::XFail, msg, file, line);
+ FOREACH_TEST_LOGGER
+ logger->addIncident(QAbstractTestLogger::XFail, msg, file, line);
}
void QTestLog::addXPass(const char *msg, const char *file, int line)
@@ -433,7 +345,8 @@ void QTestLog::addXPass(const char *msg, const char *file, int line)
++QTest::fails;
- QTest::TestLoggers::addIncident(QAbstractTestLogger::XPass, msg, file, line);
+ FOREACH_TEST_LOGGER
+ logger->addIncident(QAbstractTestLogger::XPass, msg, file, line);
}
void QTestLog::addBPass(const char *msg)
@@ -442,7 +355,8 @@ void QTestLog::addBPass(const char *msg)
++QTest::blacklists;
- QTest::TestLoggers::addIncident(QAbstractTestLogger::BlacklistedPass, msg);
+ FOREACH_TEST_LOGGER
+ logger->addIncident(QAbstractTestLogger::BlacklistedPass, msg);
}
void QTestLog::addBFail(const char *msg, const char *file, int line)
@@ -452,7 +366,8 @@ void QTestLog::addBFail(const char *msg, const char *file, int line)
++QTest::blacklists;
- QTest::TestLoggers::addIncident(QAbstractTestLogger::BlacklistedFail, msg, file, line);
+ FOREACH_TEST_LOGGER
+ logger->addIncident(QAbstractTestLogger::BlacklistedFail, msg, file, line);
}
void QTestLog::addBXPass(const char *msg, const char *file, int line)
@@ -462,7 +377,8 @@ void QTestLog::addBXPass(const char *msg, const char *file, int line)
++QTest::blacklists;
- QTest::TestLoggers::addIncident(QAbstractTestLogger::BlacklistedXPass, msg, file, line);
+ FOREACH_TEST_LOGGER
+ logger->addIncident(QAbstractTestLogger::BlacklistedXPass, msg, file, line);
}
void QTestLog::addBXFail(const char *msg, const char *file, int line)
@@ -470,7 +386,10 @@ void QTestLog::addBXFail(const char *msg, const char *file, int line)
QTEST_ASSERT(msg);
QTEST_ASSERT(file);
- QTest::TestLoggers::addIncident(QAbstractTestLogger::BlacklistedXFail, msg, file, line);
+ ++QTest::blacklists;
+
+ FOREACH_TEST_LOGGER
+ logger->addIncident(QAbstractTestLogger::BlacklistedXFail, msg, file, line);
}
void QTestLog::addSkip(const char *msg, const char *file, int line)
@@ -480,27 +399,33 @@ void QTestLog::addSkip(const char *msg, const char *file, int line)
++QTest::skips;
- QTest::TestLoggers::addMessage(QAbstractTestLogger::Skip, QString::fromUtf8(msg), file, line);
+ FOREACH_TEST_LOGGER
+ logger->addMessage(QAbstractTestLogger::Skip, QString::fromUtf8(msg), file, line);
}
void QTestLog::addBenchmarkResult(const QBenchmarkResult &result)
{
- QTest::TestLoggers::addBenchmarkResult(result);
+ FOREACH_TEST_LOGGER
+ logger->addBenchmarkResult(result);
}
void QTestLog::startLogging()
{
elapsedTotalTime.start();
elapsedFunctionTime.start();
- QTest::TestLoggers::startLogging();
+ FOREACH_TEST_LOGGER
+ logger->startLogging();
QTest::oldMessageHandler = qInstallMessageHandler(QTest::messageHandler);
}
void QTestLog::stopLogging()
{
qInstallMessageHandler(QTest::oldMessageHandler);
- QTest::TestLoggers::stopLogging();
- QTest::TestLoggers::destroyLoggers();
+ FOREACH_TEST_LOGGER {
+ logger->stopLogging();
+ delete logger;
+ }
+ QTest::loggers.clear();
QTest::loggerUsingStdout = false;
saveCoverageTool(QTestResult::currentAppName(), failCount() != 0, QTestLog::installedTestCoverage());
}
@@ -535,6 +460,11 @@ void QTestLog::addLogger(LogMode mode, const char *filename)
case QTestLog::TAP:
logger = new QTapTestLogger(filename);
break;
+#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
+ case QTestLog::Apple:
+ logger = new QAppleTestLogger;
+ break;
+#endif
#if defined(HAVE_XCTEST)
case QTestLog::XCTest:
logger = new QXcodeTestLogger;
@@ -542,21 +472,13 @@ void QTestLog::addLogger(LogMode mode, const char *filename)
#endif
}
-#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
- // Logger that also feeds messages to AUL. It needs to wrap the existing
- // logger, as it needs to be able to short circuit the existing logger
- // in case AUL prints to stderr.
- if (QAppleTestLogger::debugLoggingEnabled())
- logger = new QAppleTestLogger(logger);
-#endif
-
QTEST_ASSERT(logger);
- QTest::TestLoggers::addLogger(logger);
+ QTest::loggers.append(logger);
}
int QTestLog::loggerCount()
{
- return QTest::TestLoggers::loggerCount();
+ return QTest::loggers.size();
}
bool QTestLog::loggerUsingStdout()
@@ -568,15 +490,16 @@ void QTestLog::warn(const char *msg, const char *file, int line)
{
QTEST_ASSERT(msg);
- if (QTest::TestLoggers::loggerCount() > 0)
- QTest::TestLoggers::addMessage(QAbstractTestLogger::Warn, QString::fromUtf8(msg), file, line);
+ FOREACH_TEST_LOGGER
+ logger->addMessage(QAbstractTestLogger::Warn, QString::fromUtf8(msg), file, line);
}
void QTestLog::info(const char *msg, const char *file, int line)
{
QTEST_ASSERT(msg);
- QTest::TestLoggers::addMessage(QAbstractTestLogger::Info, QString::fromUtf8(msg), file, line);
+ FOREACH_TEST_LOGGER
+ logger->addMessage(QAbstractTestLogger::Info, QString::fromUtf8(msg), file, line);
}
void QTestLog::setVerboseLevel(int level)
diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h
index 0bdd6290e1..e63e89a78e 100644
--- a/src/testlib/qtestlog_p.h
+++ b/src/testlib/qtestlog_p.h
@@ -53,6 +53,10 @@
#include <QtTest/qttestglobal.h>
+#if defined(Q_OS_DARWIN)
+#include <QtCore/private/qcore_mac_p.h>
+#endif
+
QT_BEGIN_NAMESPACE
class QBenchmarkResult;
@@ -63,9 +67,12 @@ class Q_TESTLIB_EXPORT QTestLog
{
public:
enum LogMode {
- Plain = 0, XML, LightXML, XunitXML, CSV, TeamCity, TAP,
+ Plain = 0, XML, LightXML, XunitXML, CSV, TeamCity, TAP
+#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
+ , Apple
+#endif
#if defined(HAVE_XCTEST)
- XCTest
+ , XCTest
#endif
};
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp
index cf85c244cd..20b1befc38 100644
--- a/src/tools/androiddeployqt/main.cpp
+++ b/src/tools/androiddeployqt/main.cpp
@@ -1261,7 +1261,7 @@ bool updateStringsXml(const Options &options)
fprintf(stderr, "Can't open %s for writing.\n", qPrintable(fileName));
return false;
}
- file.write(QByteArray("<?xml version='1.0' encoding='utf-8'?><resources><string name=\"app_name\">")
+ file.write(QByteArray("<?xml version='1.0' encoding='utf-8'?><resources><string name=\"app_name\" translatable=\"false\">")
.append(QFileInfo(options.applicationBinary).baseName().mid(sizeof("lib") - 1).toLatin1())
.append("</string></resources>\n"));
return true;
@@ -1722,7 +1722,7 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies)
QStringList importPaths;
importPaths += shellQuote(options->qtInstallDirectory + QLatin1String("/qml"));
- importPaths += rootPath;
+ importPaths += shellQuote(rootPath);
for (const QString &qmlImportPath : qAsConst(options->qmlImportPaths))
importPaths += shellQuote(qmlImportPath);
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 7ab6c31cb2..0adc91ddb9 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -767,9 +767,9 @@ void WriteInitialization::acceptWidget(DomWidget *node)
static const QLatin1String realPropertyNames[] = {
QLatin1String("visible"),
QLatin1String("cascadingSectionResizes"),
+ QLatin1String("minimumSectionSize"), // before defaultSectionSize
QLatin1String("defaultSectionSize"),
QLatin1String("highlightSections"),
- QLatin1String("minimumSectionSize"),
QLatin1String("showSortIndicator"),
QLatin1String("stretchLastSection"),
};
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index c9093095a7..1c10e3e786 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -246,6 +246,13 @@ void QDialogPrivate::deletePlatformHelper()
window-system properties for the widget (in particular it will
reset the Qt::Dialog flag).
+ \note The parent relationship of the dialog does \e{not} imply
+ that the dialog will always be stacked on top of the parent
+ window. To ensure that the dialog is always on top, make the
+ dialog modal. This also applies for child windows of the dialog
+ itself. To ensure that child windows of the dialog stay on top
+ of the dialog, make the child windows modal as well.
+
\section1 Modal Dialogs
A \b{modal} dialog is a dialog that blocks input to other
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 02eae33a12..e1e45143b4 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1912,7 +1912,7 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event)
bool click = (index == d->pressedIndex && index.isValid());
bool selectedClicked = click && (event->button() == Qt::LeftButton) && d->pressedAlreadySelected;
EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers);
- bool edited = edit(index, trigger, event);
+ const bool edited = click ? edit(index, trigger, event) : false;
d->ctrlDragSelectionFlag = QItemSelectionModel::NoUpdate;
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index 0986da9707..1465ee71a7 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -244,6 +244,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
case QVariant::Bool: {
QBooleanComboBox *cb = new QBooleanComboBox(parent);
cb->setFrame(false);
+ cb->setSizePolicy(QSizePolicy::Ignored, cb->sizePolicy().verticalPolicy());
return cb; }
#endif
#if QT_CONFIG(spinbox)
@@ -252,12 +253,14 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
sb->setFrame(false);
sb->setMinimum(0);
sb->setMaximum(INT_MAX);
+ sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
case QVariant::Int: {
QSpinBox *sb = new QSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(INT_MIN);
sb->setMaximum(INT_MAX);
+ sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
#endif
#if QT_CONFIG(datetimeedit)
@@ -284,6 +287,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
sb->setFrame(false);
sb->setMinimum(-DBL_MAX);
sb->setMaximum(DBL_MAX);
+ sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
#endif
#if QT_CONFIG(lineedit)
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 6b5857f1ca..e07514f297 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -1315,8 +1315,8 @@ void QListView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFl
if (tl.isValid() && br.isValid()
&& d->isIndexEnabled(tl)
&& d->isIndexEnabled(br)) {
- QRect first = rectForIndex(tl);
- QRect last = rectForIndex(br);
+ QRect first = d->cellRectForIndex(tl);
+ QRect last = d->cellRectForIndex(br);
QRect middle;
if (d->flow == LeftToRight) {
QRect &top = first;
diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h
index 181386d4d0..c94357afe9 100644
--- a/src/widgets/itemviews/qlistview_p.h
+++ b/src/widgets/itemviews/qlistview_p.h
@@ -333,14 +333,31 @@ public:
inline QModelIndex listViewItemToIndex(const QListViewItem &item) const
{ return model->index(commonListView->itemIndex(item), column, root); }
+ inline bool hasRectForIndex(const QModelIndex &index) const
+ {
+ return isIndexValid(index) && index.parent() == root && index.column() == column && !isHidden(index.row());
+ }
+
QRect rectForIndex(const QModelIndex &index) const
{
- if (!isIndexValid(index) || index.parent() != root || index.column() != column || isHidden(index.row()))
+ if (!hasRectForIndex(index))
return QRect();
executePostedLayout();
return viewItemRect(indexToListViewItem(index));
}
+ QRect cellRectForIndex(const QModelIndex &index)
+ {
+ if (!hasRectForIndex(index))
+ return QRect();
+ executePostedLayout();
+ auto oldItemAlignment = itemAlignment;
+ itemAlignment = Qt::Alignment();
+ const QRect rect = rectForIndex(index);
+ itemAlignment = oldItemAlignment;
+ return rect;
+ }
+
void viewUpdateGeometries() { q_func()->updateGeometries(); }
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 79e338a6e7..c739ddc6e2 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -843,11 +843,14 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut
}
#endif // QT_CONFIG(toolbutton)
-static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth)
+static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth, int maxHeight = -1, int *lastVisibleLine = nullptr)
{
+ if (lastVisibleLine)
+ *lastVisibleLine = -1;
qreal height = 0;
qreal widthUsed = 0;
textLayout.beginLayout();
+ int i = 0;
while (true) {
QTextLine line = textLayout.createLine();
if (!line.isValid())
@@ -856,6 +859,13 @@ static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth)
line.setPosition(QPointF(0, height));
height += line.height();
widthUsed = qMax(widthUsed, line.naturalTextWidth());
+ // we assume that the height of the next line is the same as the current one
+ if (maxHeight > 0 && lastVisibleLine && height + line.height() > maxHeight) {
+ const QTextLine nextLine = textLayout.createLine();
+ *lastVisibleLine = nextLine.isValid() ? i : -1;
+ break;
+ }
+ ++i;
}
textLayout.endLayout();
return QSizeF(widthUsed, height);
@@ -869,7 +879,13 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex
QTextLayout textLayout(text, font);
textLayout.setTextOption(textOption);
- viewItemTextLayout(textLayout, textRect.width());
+ // In AlignVCenter mode when more than one line is displayed and the height only allows
+ // some of the lines it makes no sense to display those. From a users perspective it makes
+ // more sense to see the start of the text instead something inbetween.
+ const bool vAlignmentOptimization = paintStartPosition && valign.testFlag(Qt::AlignVCenter);
+
+ int lastVisibleLine = -1;
+ viewItemTextLayout(textLayout, textRect.width(), vAlignmentOptimization ? textRect.height() : -1, &lastVisibleLine);
const QRectF boundingRect = textLayout.boundingRect();
// don't care about LTR/RTL here, only need the height
@@ -896,7 +912,7 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex
const int start = line.textStart();
const int length = line.textLength();
const bool drawElided = line.naturalTextWidth() > textRect.width();
- bool elideLastVisibleLine = false;
+ bool elideLastVisibleLine = lastVisibleLine == i;
if (!drawElided && i + 1 < lineCount && lastVisibleLineShouldBeElided) {
const QTextLine nextLine = textLayout.lineAt(i + 1);
const int nextHeight = height + nextLine.height() / 2;
@@ -927,7 +943,8 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex
}
// below visible text, can stop
- if (height + layoutRect.top() >= textRect.bottom())
+ if ((height + layoutRect.top() >= textRect.bottom()) ||
+ (lastVisibleLine >= 0 && lastVisibleLine == i))
break;
}
return ret;
diff --git a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp
index 17c51eaaf4..569c610e24 100644
--- a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp
+++ b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp
@@ -53,6 +53,7 @@ void tst_QNoDebug::noDebugOutput() const
// should do nothing
qDebug() << "foo";
qCDebug(cat) << "foo";
+ qCDebug(cat, "foo");
// qWarning still works, though
QTest::ignoreMessage(QtWarningMsg, "bar");
diff --git a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
index 541e73636c..3745782dfc 100644
--- a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
@@ -9,7 +9,7 @@ SUBDIRS = lib \
tst.depends += almostplugin
SUBDIRS += almostplugin
}
-macos:qtConfig(private_tests) {
+macos:qtConfig(private_tests):qtHaveModule(gui) {
tst.depends += machtest
SUBDIRS += machtest
}
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
index db5e83e2c7..13dc924f93 100644
--- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
@@ -204,6 +204,7 @@ private slots:
void basicRawEventTranslationOfIds();
void multiPointRawEventTranslationOnTouchScreen();
void multiPointRawEventTranslationOnTouchPad();
+ void touchOnMultipleTouchscreens();
void deleteInEventHandler();
void deleteInRawEventTranslation();
void crashInQGraphicsSceneAfterNotHandlingTouchBegin();
@@ -213,11 +214,13 @@ private slots:
private:
QTouchDevice *touchScreenDevice;
+ QTouchDevice *secondaryTouchScreenDevice;
QTouchDevice *touchPadDevice;
};
tst_QTouchEvent::tst_QTouchEvent()
: touchScreenDevice(QTest::createTouchDevice())
+ , secondaryTouchScreenDevice(QTest::createTouchDevice())
, touchPadDevice(QTest::createTouchDevice(QTouchDevice::TouchPad))
{
}
@@ -225,6 +228,7 @@ tst_QTouchEvent::tst_QTouchEvent()
void tst_QTouchEvent::cleanup()
{
QVERIFY(QGuiApplication::topLevelWindows().isEmpty());
+ QWindowSystemInterfacePrivate::clearPointIdMap();
}
void tst_QTouchEvent::qPointerUniqueId()
@@ -951,6 +955,157 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
}
}
+void tst_QTouchEvent::touchOnMultipleTouchscreens()
+{
+ tst_QTouchEventWidget touchWidget;
+ touchWidget.setWindowTitle(QTest::currentTestFunction());
+ touchWidget.setAttribute(Qt::WA_AcceptTouchEvents);
+ touchWidget.setGeometry(100, 100, 400, 300);
+ touchWidget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&touchWidget));
+ QWindow *window = touchWidget.windowHandle();
+
+ QPointF pos = touchWidget.rect().center();
+ QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint());
+ QPointF delta(10, 10);
+ QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget);
+
+ QVector<QTouchEvent::TouchPoint> rawTouchPoints(3);
+ rawTouchPoints[0].setId(0);
+ rawTouchPoints[1].setId(10);
+ rawTouchPoints[2].setId(11);
+
+ // this should be translated to a TouchBegin
+ rawTouchPoints[0].setState(Qt::TouchPointPressed);
+ rawTouchPoints[0].setScreenPos(screenPos);
+ rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry));
+ rawTouchPoints[0].setRawScreenPositions({{12, 34}, {56, 78}});
+ ulong timestamp = 1234;
+ QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window);
+ QWindowSystemInterface::handleTouchEvent(window, timestamp, touchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(!touchWidget.seenTouchUpdate);
+ QVERIFY(!touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.timestamp, timestamp);
+ QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.first();
+ const int touchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1;
+ const int secTouchPointId = (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2;
+ QCOMPARE(touchBeginPoint.id(), touchPointId);
+ QCOMPARE(touchBeginPoint.state(), rawTouchPoints[0].state());
+ QCOMPARE(touchBeginPoint.pos(), pos);
+
+ // press a point on secondaryTouchScreenDevice
+ touchWidget.seenTouchBegin = false;
+ rawTouchPoints[1].setState(Qt::TouchPointPressed);
+ rawTouchPoints[1].setScreenPos(screenPos);
+ rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry));
+ rawTouchPoints[1].setRawScreenPositions({{90, 100}, {110, 120}});
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[1], window);
+ QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(!touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.timestamp, timestamp);
+ touchBeginPoint = touchWidget.touchBeginPoints[0];
+ QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2);
+ QCOMPARE(touchBeginPoint.state(), rawTouchPoints[1].state());
+ QCOMPARE(touchBeginPoint.pos(), pos);
+
+ // press another point on secondaryTouchScreenDevice
+ touchWidget.seenTouchBegin = false;
+ rawTouchPoints[2].setState(Qt::TouchPointPressed);
+ rawTouchPoints[2].setScreenPos(screenPos);
+ rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry));
+ rawTouchPoints[2].setRawScreenPositions({{130, 140}, {150, 160}});
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[2], window);
+ QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(!touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.timestamp, timestamp);
+ touchBeginPoint = touchWidget.touchBeginPoints[0];
+ QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 3);
+ QCOMPARE(touchBeginPoint.state(), rawTouchPoints[2].state());
+ QCOMPARE(touchBeginPoint.pos(), pos);
+
+ // moving the first point should translate to TouchUpdate
+ rawTouchPoints[0].setState(Qt::TouchPointMoved);
+ rawTouchPoints[0].setScreenPos(screenPos + delta);
+ rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window);
+ QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(touchWidget.seenTouchUpdate);
+ QVERIFY(!touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchUpdatePoints.count(), 1);
+ QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
+ QCOMPARE(touchUpdatePoint.id(), touchPointId);
+ QCOMPARE(touchUpdatePoint.state(), rawTouchPoints[0].state());
+ QCOMPARE(touchUpdatePoint.pos(), pos + delta);
+
+ // releasing the first point translates to TouchEnd
+ rawTouchPoints[0].setState(Qt::TouchPointReleased);
+ rawTouchPoints[0].setScreenPos(screenPos + delta + delta);
+ rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry));
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[0], window);
+ QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(touchWidget.seenTouchUpdate);
+ QVERIFY(touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first();
+ QCOMPARE(touchEndPoint.id(), touchPointId);
+ QCOMPARE(touchEndPoint.state(), rawTouchPoints[0].state());
+ QCOMPARE(touchEndPoint.pos(), pos + delta + delta);
+
+ // Widgets don't normally handle this case: if a TouchEnd was seen before, then
+ // WA_WState_AcceptedTouchBeginEvent will be false, and
+ // QApplicationPrivate::translateRawTouchEvent will ignore touch events that aren't TouchBegin.
+ // So we have to set it true. It _did_ in fact accept the touch begin from the secondary device,
+ // but it also got a TouchEnd from the primary device in the meantime.
+ touchWidget.setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, true);
+
+ // Releasing one point on the secondary touchscreen does not yet generate TouchEnd.
+ touchWidget.seenTouchEnd = false;
+ touchWidget.touchEndPoints.clear();
+ rawTouchPoints[1].setState(Qt::TouchPointReleased);
+ rawTouchPoints[2].setState(Qt::TouchPointStationary);
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[1] << rawTouchPoints[2], window);
+ QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(touchWidget.seenTouchUpdate);
+ QVERIFY(!touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints[0].id(), secTouchPointId);
+ QCOMPARE(touchWidget.touchUpdatePoints[1].id(), secTouchPointId + 1);
+
+ // releasing the last point on the secondary touchscreen translates to TouchEnd
+ touchWidget.seenTouchEnd = false;
+ rawTouchPoints[2].setState(Qt::TouchPointReleased);
+ nativeTouchPoints =
+ QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoints[2], window);
+ QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
+ QCoreApplication::processEvents();
+ QVERIFY(touchWidget.seenTouchBegin);
+ QVERIFY(touchWidget.seenTouchUpdate);
+ QVERIFY(touchWidget.seenTouchEnd);
+ QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ touchEndPoint = touchWidget.touchEndPoints.first();
+ QCOMPARE(touchEndPoint.id(), secTouchPointId + 1);
+ QCOMPARE(touchEndPoint.state(), rawTouchPoints[2].state());
+}
+
void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
{
tst_QTouchEventWidget touchWidget;
diff --git a/tests/auto/network/access/hpack/tst_hpack.cpp b/tests/auto/network/access/hpack/tst_hpack.cpp
index 810745a065..d5e359db57 100644
--- a/tests/auto/network/access/hpack/tst_hpack.cpp
+++ b/tests/auto/network/access/hpack/tst_hpack.cpp
@@ -57,7 +57,6 @@ private Q_SLOTS:
void lookupTableConstructor();
- void lookupTableStatic_data();
void lookupTableStatic();
void lookupTableDynamic();
@@ -126,7 +125,7 @@ void tst_Hpack::bitstreamConstruction()
// 'Read' some data back:
for (int i = 0; i < size; ++i) {
uchar bitPattern = 0;
- const auto bitsRead = in.peekBits(i * 8, 8, &bitPattern);
+ const auto bitsRead = in.peekBits(quint64(i * 8), 8, &bitPattern);
QVERIFY(bitsRead == 8);
QVERIFY(bitPattern == bytes[i]);
}
@@ -282,7 +281,7 @@ void tst_Hpack::bitstreamCompression()
const auto start = QRandomGenerator::global()->bounded(uint(bytes.length()) / 2);
auto end = start * 2;
if (!end)
- end = bytes.length() / 2;
+ end = unsigned(bytes.length() / 2);
strings.push_back(bytes.substr(start, end - start));
const auto &s = strings.back();
totalStringBytes += s.size();
@@ -384,43 +383,21 @@ void tst_Hpack::lookupTableConstructor()
}
}
-void tst_Hpack::lookupTableStatic_data()
-{
- QTest::addColumn<QByteArray>("expectedName");
- QTest::addColumn<QByteArray>("expectedValue");
-
- // Some predefined fields to find
- // (they are always defined/required by HPACK).
- QTest::newRow(":authority|") << QByteArray(":authority") << QByteArray("");
- QTest::newRow(":method|GET") << QByteArray(":method") << QByteArray("GET");
- QTest::newRow(":method|POST") << QByteArray(":method") << QByteArray("POST");
- QTest::newRow(":path|/") << QByteArray(":path") << QByteArray("/");
- QTest::newRow(":path|/index.html") << QByteArray(":path") << QByteArray("/index.html");
- QTest::newRow(":scheme|http") << QByteArray(":scheme") << QByteArray("http");
- QTest::newRow(":scheme|https") << QByteArray(":scheme") << QByteArray("https");
- QTest::newRow(":status|200") << QByteArray(":status") << QByteArray("200");
- QTest::newRow(":status|204") << QByteArray(":status") << QByteArray("204");
- QTest::newRow(":status|206") << QByteArray(":status") << QByteArray("206");
- QTest::newRow(":status|304") << QByteArray(":status") << QByteArray("304");
- QTest::newRow(":status|400") << QByteArray(":status") << QByteArray("400");
- QTest::newRow(":status|404") << QByteArray(":status") << QByteArray("404");
- QTest::newRow(":status|500") << QByteArray(":status") << QByteArray("500");
-}
-
void tst_Hpack::lookupTableStatic()
{
const FieldLookupTable table(0, false /*all static, no need in 'search index'*/);
-
- QFETCH(QByteArray, expectedName);
- QFETCH(QByteArray, expectedValue);
-
- const quint32 index = table.indexOf(expectedName, expectedValue);
- QVERIFY(index != 0);
-
+ const auto &staticTable = FieldLookupTable::staticPart();
QByteArray name, value;
- QVERIFY(table.field(index, &name, &value));
- QCOMPARE(name, expectedName);
- QCOMPARE(value, expectedValue);
+ quint32 currentIndex = 1; // HPACK is indexing starting from 1.
+ for (const HeaderField &field : staticTable) {
+ const quint32 index = table.indexOf(field.name, field.value);
+ QVERIFY(index != 0);
+ QCOMPARE(index, currentIndex);
+ QVERIFY(table.field(index, &name, &value));
+ QCOMPARE(name, field.name);
+ QCOMPARE(value, field.value);
+ ++currentIndex;
+ }
}
void tst_Hpack::lookupTableDynamic()
diff --git a/tests/auto/network/access/http2/http2srv.cpp b/tests/auto/network/access/http2/http2srv.cpp
index 1f9ffb8985..6e2220fa67 100644
--- a/tests/auto/network/access/http2/http2srv.cpp
+++ b/tests/auto/network/access/http2/http2srv.cpp
@@ -431,6 +431,13 @@ void Http2Server::readReady()
if (connectionError)
return;
+ if (redirectSent) {
+ // We are a "single shot" server, working in 'h2' mode,
+ // responding with a redirect code. Don't bother to handle
+ // anything else now.
+ return;
+ }
+
if (upgradeProtocol) {
handleProtocolUpgrade();
} else if (waitingClientPreface) {
@@ -800,6 +807,13 @@ void Http2Server::sendResponse(quint32 streamID, bool emptyBody)
HttpHeader header;
if (redirectWhileReading) {
+ if (redirectSent) {
+ // This is a "single-shot" server responding with a redirect code.
+ return;
+ }
+
+ redirectSent = true;
+
qDebug("server received HEADERS frame (followed by DATA frames), redirecting ...");
Q_ASSERT(targetPort);
header.push_back({":status", "308"});
diff --git a/tests/auto/network/access/http2/http2srv.h b/tests/auto/network/access/http2/http2srv.h
index 87a17ced8b..ae3f084fdc 100644
--- a/tests/auto/network/access/http2/http2srv.h
+++ b/tests/auto/network/access/http2/http2srv.h
@@ -193,6 +193,7 @@ private:
// Redirect, with status code 308, as soon as we've seen headers, while client
// may still be sending DATA frames. See tst_Http2::earlyResponse().
bool redirectWhileReading = false;
+ bool redirectSent = false;
quint16 targetPort = 0;
QAtomicInt interrupted;
protected slots:
diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp
index 235b78c34a..52e98c1fc1 100644
--- a/tests/auto/network/access/http2/tst_http2.cpp
+++ b/tests/auto/network/access/http2/tst_http2.cpp
@@ -473,7 +473,7 @@ void tst_Http2::earlyResponse()
runEventLoop();
QVERIFY(serverPort);
- sendRequest(1, QNetworkRequest::NormalPriority, {10000000, Qt::Uninitialized});
+ sendRequest(1, QNetworkRequest::NormalPriority, {1000000, Qt::Uninitialized});
runEventLoop();
diff --git a/tests/auto/network/ssl/qsslkey/BLACKLIST b/tests/auto/network/ssl/qsslkey/BLACKLIST
index c0dfe5eb86..f9bc0af6de 100644
--- a/tests/auto/network/ssl/qsslkey/BLACKLIST
+++ b/tests/auto/network/ssl/qsslkey/BLACKLIST
@@ -1,2 +1,2 @@
-redhatenterpriselinuxworkstation-6.6
-rhel-7.4
+redhatenterpriselinuxworkstation
+rhel
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index a720860288..25ab62a1c3 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -56,7 +56,7 @@ winrt|!qtHaveModule(gui)|!qtConfig(accessibility): SUBDIRS -= qaccessibility
!qtConfig(process): SUBDIRS -= qprocess_and_guieventloop
-!mac: SUBDIRS -= \
+!macos|!qtHaveModule(gui): SUBDIRS -= \
macgui \
macnativeevents \
macplist \
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST b/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST
new file mode 100644
index 0000000000..01679eb6ee
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST
@@ -0,0 +1,11 @@
+winrt
+[sort:QFileDialog usage]
+ubuntu
+b2qt
+[specialFiles]
+ubuntu
+b2qt
+[dirsBeforeFiles]
+ubuntu
+b2qt
+windows
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro
index bc4671f60c..db8cf7de3f 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro
@@ -1,3 +1,6 @@
+INCLUDEPATH += ../../../../shared
+HEADERS += ../../../../shared/emulationdetector.h
+
CONFIG += testcase
# This testcase can be slow on Windows and OS X, and may interfere with other file system tests.
win32:testcase.timeout = 900
@@ -8,5 +11,3 @@ QT += core-private testlib
SOURCES += tst_qfilesystemmodel.cpp
TARGET = tst_qfilesystemmodel
-
-CONFIG += insignificant_test # QTBUG-29403
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 9ee5292fcb..665a116a3a 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
+#include <emulationdetector.h>
#include <QtTest/QtTest>
#ifdef QT_BUILD_INTERNAL
#include <private/qfilesystemmodel_p.h>
@@ -788,6 +789,9 @@ void tst_QFileSystemModel::sort()
MyFriendFileSystemModel *myModel = new MyFriendFileSystemModel();
QTreeView *tree = new QTreeView();
+ if (fileDialogMode && EmulationDetector::isRunningArmOnX86())
+ QSKIP("Crashes in QEMU. QTBUG-70572");
+
#ifdef QT_BUILD_INTERNAL
if (fileDialogMode)
myModel->d_func()->disableRecursiveSort = true;
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 9175c0bff4..9511654110 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -121,6 +121,7 @@ private slots:
void task254449_draggingItemToNegativeCoordinates();
void keyboardSearch();
void shiftSelectionWithNonUniformItemSizes();
+ void shiftSelectionWithItemAlignment();
void clickOnViewportClearsSelection();
void task262152_setModelColumnNavigate();
void taskQTBUG_2233_scrollHiddenItems_data();
@@ -1798,6 +1799,51 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
}
}
+void tst_QListView::shiftSelectionWithItemAlignment()
+{
+ QStringList items;
+ for (int c = 0; c < 2; c++) {
+ for (int i = 10; i > 0; i--)
+ items << QString(i, QLatin1Char('*'));
+
+ for (int i = 1; i < 11; i++)
+ items << QString(i, QLatin1Char('*'));
+ }
+
+ QListView view;
+ view.setFlow(QListView::TopToBottom);
+ view.setWrapping(true);
+ view.setItemAlignment(Qt::AlignLeft);
+ view.setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ QStringListModel model(items);
+ view.setModel(&model);
+
+ QFont font = view.font();
+ font.setPixelSize(10);
+ view.setFont(font);
+ view.resize(300, view.sizeHintForRow(0) * items.size() / 2 + view.horizontalScrollBar()->height());
+
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+ QCOMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
+
+ QModelIndex index1 = view.model()->index(items.size() / 4, 0);
+ QPoint p = view.visualRect(index1).center();
+ QVERIFY(view.viewport()->rect().contains(p));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p);
+ QCOMPARE(view.currentIndex(), index1);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), 1);
+
+ QModelIndex index2 = view.model()->index(items.size() / 4 * 3, 0);
+ p = view.visualRect(index2).center();
+ QVERIFY(view.viewport()->rect().contains(p));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p);
+ QCOMPARE(view.currentIndex(), index2);
+ QCOMPARE(view.selectionModel()->selectedIndexes().size(), index2.row() - index1.row() + 1);
+}
+
void tst_QListView::clickOnViewportClearsSelection()
{
QStringList items;
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 8f9afeea4d..a9858ae420 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -199,6 +199,7 @@ private slots:
void taskQTBUG_45697_crash();
void taskQTBUG_7232_AllowUserToControlSingleStep();
void taskQTBUG_8376();
+ void taskQTBUG_61476();
void testInitialFocus();
};
@@ -4726,5 +4727,58 @@ void tst_QTreeView::taskQTBUG_8376()
QCOMPARE(rowHeightLvl1Visible, rowHeightLvl1Visible2);
}
+void tst_QTreeView::taskQTBUG_61476()
+{
+ // This checks that if a user clicks on an item to collapse it that it
+ // does not edit (in this case change the check state) the item that is
+ // now over the mouse just because it got a release event
+ QTreeView tv;
+ QStandardItemModel model;
+ QStandardItem *lastTopLevel = nullptr;
+ {
+ for (int i = 0; i < 4; ++i) {
+ QStandardItem *item = new QStandardItem(QLatin1String("Row Item"));
+ item->setCheckable(true);
+ item->setCheckState(Qt::Checked);
+ model.appendRow(item);
+ lastTopLevel = item;
+ for (int j = 0; j < 2; ++j) {
+ QStandardItem *childItem = new QStandardItem(QLatin1String("Child row Item"));
+ childItem->setCheckable(true);
+ childItem->setCheckState(Qt::Checked);
+ item->appendRow(childItem);
+ QStandardItem *grandChild = new QStandardItem(QLatin1String("Grand child row Item"));
+ grandChild->setCheckable(true);
+ grandChild->setCheckState(Qt::Checked);
+ childItem->appendRow(grandChild);
+ }
+ }
+ }
+ tv.setModel(&model);
+ tv.expandAll();
+ // We need it to be this size so that the effect of the collapsing will
+ // cause the parent item to move to be under the cursor
+ tv.resize(200, 200);
+ tv.show();
+ QVERIFY(QTest::qWaitForWindowActive(&tv));
+ tv.verticalScrollBar()->setValue(tv.verticalScrollBar()->maximum());
+
+ // We want to press specifically right around where a checkbox for the
+ // parent item could be when collapsing
+ QTreeViewPrivate *priv = static_cast<QTreeViewPrivate*>(qt_widget_private(&tv));
+ const QModelIndex mi = lastTopLevel->child(0)->index();
+ const QRect rect = priv->itemDecorationRect(mi);
+ const QPoint pos = rect.center();
+
+ QTest::mousePress(tv.viewport(), Qt::LeftButton, 0, pos);
+ if (tv.style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, &tv) ==
+ QEvent::MouseButtonPress)
+ QTRY_VERIFY(!tv.isExpanded(mi));
+
+ QTest::mouseRelease(tv.viewport(), Qt::LeftButton, 0, pos);
+ QTRY_VERIFY(!tv.isExpanded(mi));
+ QCOMPARE(lastTopLevel->checkState(), Qt::Checked);
+}
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp
index 80e269ee2a..c9f9cd9bd2 100644
--- a/tests/baselineserver/shared/baselineprotocol.cpp
+++ b/tests/baselineserver/shared/baselineprotocol.cpp
@@ -366,7 +366,7 @@ bool BaselineProtocol::connect(const QString &testCase, bool *dryrun, const Plat
if (!socket.waitForConnected(Timeout)) {
sysSleep(3000); // Wait a bit and try again, the server might just be restarting
if (!socket.waitForConnected(Timeout)) {
- errMsg += QLS("TCP connectToHost failed. Host:") + serverName + QLS(" port:") + QString::number(ServerPort);
+ errMsg += QLS("TCP connectToHost failed. Host:") + QLS(serverName) + QLS(" port:") + QString::number(ServerPort);
return false;
}
}
diff --git a/tests/manual/gestures/graphicsview/gestures.cpp b/tests/manual/gestures/graphicsview/gestures.cpp
index cc0ff3e1aa..6e5b07bf18 100644
--- a/tests/manual/gestures/graphicsview/gestures.cpp
+++ b/tests/manual/gestures/graphicsview/gestures.cpp
@@ -44,11 +44,13 @@ QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::recognize(QGesture
switch (event->type()) {
case QEvent::TouchBegin:
result = QGestureRecognizer::MayBeGesture;
+ break;
case QEvent::TouchEnd:
if (d->gestureFired)
result = QGestureRecognizer::FinishGesture;
else
result = QGestureRecognizer::CancelGesture;
+ break;
case QEvent::TouchUpdate:
if (d->state() != Qt::NoGesture) {
QTouchEvent *ev = static_cast<QTouchEvent*>(event);
diff --git a/tests/manual/qgraphicsitemgroup/widget.cpp b/tests/manual/qgraphicsitemgroup/widget.cpp
index b0e7a47cf8..ba9ed815fa 100644
--- a/tests/manual/qgraphicsitemgroup/widget.cpp
+++ b/tests/manual/qgraphicsitemgroup/widget.cpp
@@ -224,7 +224,7 @@ void Widget::updateUngroupButton()
CustomItem * Widget::checkedItem() const
{
- CustomItem *item;
+ CustomItem *item = nullptr;
if (ui->blue->isChecked())
item = rectBlue;
diff --git a/tests/manual/qsysinfo/main.cpp b/tests/manual/qsysinfo/main.cpp
index 62d0c51416..1d39514236 100644
--- a/tests/manual/qsysinfo/main.cpp
+++ b/tests/manual/qsysinfo/main.cpp
@@ -57,6 +57,11 @@ QByteArray windowsVersionToString(QSysInfo::WinVersion v)
CASE_VERSION(WV_WINDOWS8_1);
CASE_VERSION(WV_WINDOWS10);
case QSysInfo::WV_NT_based: // shouldn't happen
+ case QSysInfo::WV_CE:
+ case QSysInfo::WV_CENET:
+ case QSysInfo::WV_CE_5:
+ case QSysInfo::WV_CE_6:
+ case QSysInfo::WV_CE_based:
break;
}
@@ -82,6 +87,7 @@ QByteArray macVersionToString(QSysInfo::MacVersion v)
CASE_VERSION(MV_10_9);
CASE_VERSION(MV_10_10);
CASE_VERSION(MV_10_11);
+ CASE_VERSION(MV_10_12);
CASE_VERSION(MV_IOS_4_3);
CASE_VERSION(MV_IOS_5_0);
@@ -96,8 +102,24 @@ QByteArray macVersionToString(QSysInfo::MacVersion v)
CASE_VERSION(MV_IOS_8_3);
CASE_VERSION(MV_IOS_8_4);
CASE_VERSION(MV_IOS_9_0);
+ CASE_VERSION(MV_IOS_9_1);
+ CASE_VERSION(MV_IOS_9_2);
+ CASE_VERSION(MV_IOS_9_3);
+ CASE_VERSION(MV_IOS_10_0);
case QSysInfo::MV_IOS: // shouldn't happen:
+ case QSysInfo::MV_TVOS:
+ case QSysInfo::MV_WATCHOS:
break;
+
+ CASE_VERSION(MV_TVOS_9_0);
+ CASE_VERSION(MV_TVOS_9_1);
+ CASE_VERSION(MV_TVOS_9_2);
+ CASE_VERSION(MV_TVOS_10_0);
+
+ CASE_VERSION(MV_WATCHOS_2_0);
+ CASE_VERSION(MV_WATCHOS_2_1);
+ CASE_VERSION(MV_WATCHOS_2_2);
+ CASE_VERSION(MV_WATCHOS_3_0);
}
if (v & QSysInfo::MV_IOS) {
diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp
index c0366dea63..4816e2f3b9 100644
--- a/tests/manual/qtabletevent/regular_widgets/main.cpp
+++ b/tests/manual/qtabletevent/regular_widgets/main.cpp
@@ -284,7 +284,7 @@ int main(int argc, char *argv[])
mainWindow.setWindowTitle(QString::fromLatin1("Tablet Test %1").arg(QT_VERSION_STR));
EventReportWidget *widget = new EventReportWidget;
QObject::connect(proximityEventFilter, &ProximityEventFilter::proximityChanged,
- widget, QOverload<void>::of(&QWidget::update));
+ widget, QOverload<>::of(&QWidget::update));
widget->setMinimumSize(640, 480);
QMenu *fileMenu = mainWindow.menuBar()->addMenu("File");
fileMenu->addAction("Clear", widget, &EventReportWidget::clearPoints);
diff --git a/tests/manual/widgets/widgets/widgets.pro b/tests/manual/widgets/widgets/widgets.pro
new file mode 100644
index 0000000000..1fccb09d79
--- /dev/null
+++ b/tests/manual/widgets/widgets/widgets.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+SUBDIRS = bigmenucreator \
+ defaultUpMenuBar \
+ multiscreen-menus \
+ qtoolbutton/menuOnMultiScreens