summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/syncqt.pl5
-rw-r--r--config_help.txt1
-rw-r--r--configure.json4
-rw-r--r--examples/vulkan/hellovulkancubes/renderer.cpp2
-rw-r--r--examples/vulkan/hellovulkantexture/hellovulkantexture.cpp2
-rw-r--r--examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp2
-rw-r--r--examples/vulkan/shared/trianglerenderer.cpp2
-rw-r--r--examples/widgets/doc/src/dirview.qdoc21
-rw-r--r--examples/widgets/doc/src/lineedits.qdoc2
-rw-r--r--examples/widgets/graphicsview/elasticnodes/graphwidget.cpp2
-rw-r--r--examples/widgets/graphicsview/elasticnodes/node.cpp2
-rw-r--r--examples/widgets/graphicsview/elasticnodes/node.h2
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.cpp12
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.h2
-rw-r--r--examples/widgets/painting/gradients/gradients.cpp78
-rw-r--r--examples/widgets/richtext/orderform/detailsdialog.cpp4
-rw-r--r--examples/widgets/richtext/orderform/mainwindow.cpp4
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.cpp8
-rw-r--r--examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp4
-rw-r--r--examples/widgets/widgets/digitalclock/digitalclock.cpp2
-rw-r--r--mkspecs/features/create_cmake.prf10
-rw-r--r--mkspecs/features/mac/default_post.prf7
-rw-r--r--mkspecs/features/mac/default_pre.prf7
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp12
-rw-r--r--qmake/generators/makefile.cpp16
-rw-r--r--qmake/generators/unix/unixmake.cpp18
-rw-r--r--src/3rdparty/freetype/LICENSE.txt2
-rw-r--r--src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java63
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp16
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp13
-rw-r--r--src/corelib/doc/snippets/qstringlist/main.cpp11
-rw-r--r--src/corelib/global/qglobal.cpp70
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/global/qlogging.cpp3
-rw-r--r--src/corelib/io/qloggingcategory.cpp27
-rw-r--r--src/corelib/io/qprocess_win.cpp7
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp69
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h1
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp4
-rw-r--r--src/corelib/serialization/qjson.cpp45
-rw-r--r--src/corelib/serialization/qjson_p.h2
-rw-r--r--src/corelib/serialization/qjsondocument.cpp3
-rw-r--r--src/corelib/tools/qarraydataops.h10
-rw-r--r--src/corelib/tools/qbytearray.cpp67
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp2
-rw-r--r--src/corelib/tools/qlist.cpp13
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h11
-rw-r--r--src/corelib/tools/qsimd_p.h5
-rw-r--r--src/corelib/tools/qstring.cpp80
-rw-r--r--src/corelib/tools/qstringlist.cpp15
-rw-r--r--src/dbus/qdbusmisc.cpp7
-rw-r--r--src/gui/kernel/qinputdevicemanager.cpp23
-rw-r--r--src/gui/kernel/qinputdevicemanager_p.h2
-rw-r--r--src/gui/kernel/qshortcutmap.cpp13
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp5
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h1
-rw-r--r--src/gui/painting/qdrawhelper_p.h5
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp10
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp4
-rw-r--r--src/network/access/qnetworkcookiejar.cpp16
-rw-r--r--src/network/access/qnetworkrequest.cpp3
-rw-r--r--src/network/kernel/qnetworkinterface_linux.cpp4
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp4
-rw-r--r--src/network/ssl/qsslsocket_winrt.cpp4
-rw-r--r--src/platformheaders/eglfsfunctions/qeglfsfunctions.qdoc15
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm11
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp3
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp5
-rw-r--r--src/platformsupport/input/libinput/qlibinputkeyboard.cpp24
-rw-r--r--src/platformsupport/input/libinput/qlibinputkeyboard_p.h1
-rw-r--r--src/platformsupport/input/libinput/qlibinputpointer.cpp2
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm1
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm6
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm2
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm14
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp26
-rw-r--r--src/plugins/platforms/qnx/qqnxkeytranslator.h245
-rw-r--r--src/plugins/platforms/qnx/qqnxnativeinterface.cpp3
-rw-r--r--src/plugins/platforms/qnx/qqnxrasterwindow.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp101
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.h1
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp74
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp34
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsmenu.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp20
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp7
-rw-r--r--src/plugins/platformthemes/flatpak/qflatpakfiledialog.cpp2
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine.cpp5
-rw-r--r--src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp8
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm1
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac_p_p.h2
-rw-r--r--src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h2
-rw-r--r--src/plugins/styles/windowsvista/qwindowsxpstyle.cpp6
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog.cpp17
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog_p.h7
-rw-r--r--src/printsupport/dialogs/qprintdialog_unix.cpp4
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp5
-rw-r--r--src/testlib/qabstractitemmodeltester.cpp21
-rw-r--r--src/testlib/qabstractitemmodeltester.h21
-rw-r--r--src/testlib/qtestsystem.h18
-rw-r--r--src/testlib/qtesttable.cpp2
-rw-r--r--src/tools/qlalr/compress.cpp6
-rw-r--r--src/tools/qlalr/cppgenerator.cpp12
-rw-r--r--src/tools/qlalr/lalr.cpp56
-rw-r--r--src/tools/qlalr/lalr.g14
-rw-r--r--src/tools/qlalr/lalr.h5
-rw-r--r--src/tools/qlalr/main.cpp12
-rw-r--r--src/tools/qlalr/recognizer.cpp14
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp16
-rw-r--r--src/widgets/kernel/qformlayout.cpp2
-rw-r--r--src/widgets/kernel/qlayout.cpp2
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp2
-rw-r--r--src/widgets/kernel/qmacgesturerecognizer.cpp15
-rw-r--r--src/widgets/kernel/qmacgesturerecognizer_p.h4
-rw-r--r--src/widgets/kernel/qwidget.cpp3
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp1
-rw-r--r--src/widgets/kernel/qwindowcontainer.cpp1
-rw-r--r--src/widgets/statemachine/qguistatemachine.cpp4
-rw-r--r--src/widgets/styles/qcommonstyle.cpp22
-rw-r--r--src/widgets/styles/qfusionstyle.cpp2
-rw-r--r--src/widgets/styles/qstyleoption.cpp2
-rw-r--r--src/widgets/styles/qstyleoption.h4
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp32
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp8
-rw-r--r--src/widgets/widgets/qcombobox.cpp2
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp2
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp1
-rw-r--r--src/widgets/widgets/qmainwindow.cpp18
-rw-r--r--src/widgets/widgets/qmainwindow.h6
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp77
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h32
-rw-r--r--src/widgets/widgets/qmenu_p.h27
-rw-r--r--src/widgets/widgets/qmenubar.cpp2
-rw-r--r--src/widgets/widgets/qpushbutton.cpp4
-rw-r--r--src/widgets/widgets/qtabwidget.cpp12
-rw-r--r--src/widgets/widgets/qtoolbar.cpp4
-rw-r--r--src/widgets/widgets/qtoolbar.h7
-rw-r--r--src/widgets/widgets/qtoolbar_p.h6
-rw-r--r--src/widgets/widgets/qtoolbararealayout.cpp4
-rw-r--r--src/widgets/widgets/qtoolbararealayout_p.h35
-rw-r--r--src/widgets/widgets/qtoolbarlayout.cpp4
-rw-r--r--src/widgets/widgets/qtoolbarlayout_p.h6
-rw-r--r--src/widgets/widgets/qtoolbarseparator.cpp4
-rw-r--r--src/widgets/widgets/qtoolbarseparator_p.h6
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp12
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp7
-rw-r--r--src/widgets/widgets/widgets.pri28
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp4
-rw-r--r--tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp6
-rw-r--r--tests/auto/corelib/io/qprocess/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp3
-rw-r--r--tests/auto/corelib/io/qresourceengine/qresourceengine.pro2
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp18
-rw-r--r--tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp96
-rw-r--r--tests/auto/corelib/serialization/json/invalidBinaryData/38.bjson0
-rw-r--r--tests/auto/corelib/serialization/json/invalidBinaryData/39.bjsonbin0 -> 24 bytes
-rw-r--r--tests/auto/corelib/serialization/json/invalidBinaryData/40.bjsonbin0 -> 60 bytes
-rw-r--r--tests/auto/corelib/serialization/json/invalidBinaryData/41.bjsonbin0 -> 32 bytes
-rw-r--r--tests/auto/corelib/serialization/json/tst_qtjson.cpp1
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp2
-rw-r--r--tests/auto/corelib/tools/qline/tst_qline.cpp3
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp8
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp8
-rw-r--r--tests/auto/gui/kernel/qwindow/BLACKLIST2
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp3
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp4
-rw-r--r--tests/auto/network/access/qftp/tst_qftp.cpp2
-rw-r--r--tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp33
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp11
-rw-r--r--tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp3
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp12
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp6
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp6
-rw-r--r--tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.1.142
-rw-r--r--tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp7
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp33
-rw-r--r--tests/auto/other/gestures/tst_gestures.cpp84
-rw-r--r--tests/auto/other/qfocusevent/tst_qfocusevent.cpp1
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp45
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp12
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp13
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp79
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp31
-rw-r--r--tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp3
-rw-r--r--tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp3
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp202
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp5
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp41
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp10
-rw-r--r--tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp48
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp43
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp53
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp40
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp41
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp19
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp37
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp2
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp8
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp3
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp1
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp2
-rw-r--r--tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp17
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp28
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp10
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp13
-rw-r--r--tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp15
-rw-r--r--tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp3
-rw-r--r--tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp3
-rw-r--r--tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp3
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp7
-rw-r--r--tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp47
-rw-r--r--tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp3
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp11
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp10
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp1
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp28
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp6
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp10
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp14
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp7
-rw-r--r--tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp3
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp23
-rw-r--r--tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp6
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp3
-rw-r--r--tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp13
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp3
-rw-r--r--tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp12
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp3
-rw-r--r--tests/manual/dialogs/main.cpp43
-rw-r--r--tests/manual/touch/main.cpp126
-rw-r--r--tests/shared/emulationdetector.h4
245 files changed, 2158 insertions, 1658 deletions
diff --git a/bin/syncqt.pl b/bin/syncqt.pl
index f202599fe0..78fe0663b5 100755
--- a/bin/syncqt.pl
+++ b/bin/syncqt.pl
@@ -882,7 +882,6 @@ die "The -version argument is mandatory" if (!$module_version);
$build_basedir = $out_basedir if (!defined($build_basedir));
our @ignore_headers = ();
-our @ignore_for_master_contents = ();
our @ignore_for_include_check = ();
our @ignore_for_qt_begin_namespace_check = ();
our @ignore_for_qt_module_check = ();
@@ -1024,10 +1023,6 @@ foreach my $lib (@modules_to_sync) {
$qpa_header = 1;
} elsif ($allheadersprivate || $thisprivate || $public_header =~ /_p(ch)?\.h$/) {
$public_header = 0;
- } else {
- foreach (@ignore_for_master_contents) {
- $public_header = 0 if($header eq $_);
- }
}
my $clean_header;
diff --git a/config_help.txt b/config_help.txt
index d15e113b9a..f90d4439cd 100644
--- a/config_help.txt
+++ b/config_help.txt
@@ -292,6 +292,7 @@ Gui, printing, widget options:
(-qt-xcb still uses system version of libxcb itself)
Input backends:
+ -libudev............ Enable udev support [auto]
-evdev ............. Enable evdev support [auto]
-imf ............... Enable IMF support [auto] (QNX only)
-libinput .......... Enable libinput support [auto]
diff --git a/configure.json b/configure.json
index ae2aa22070..b4a87f5505 100644
--- a/configure.json
+++ b/configure.json
@@ -521,11 +521,11 @@
"output": [ "prepareSpec", "prepareOptions", "preparePaths", "reloadSpec" ]
},
"machineTuple": {
- "condition": "!config.linux || config.android || tests.machineTuple",
+ "condition": "config.linux && !config.android && tests.machineTuple",
"output": [ "machineTuple" ]
},
"commit": {
- "condition": "features.machineTuple",
+ "condition": "features.machineTuple || true",
"output": [ "commitOptions" ]
},
"android-style-assets": {
diff --git a/examples/vulkan/hellovulkancubes/renderer.cpp b/examples/vulkan/hellovulkancubes/renderer.cpp
index 523511337d..2e913bcae8 100644
--- a/examples/vulkan/hellovulkancubes/renderer.cpp
+++ b/examples/vulkan/hellovulkancubes/renderer.cpp
@@ -893,7 +893,7 @@ void Renderer::buildFrame()
VkCommandBuffer cb = m_window->currentCommandBuffer();
const QSize sz = m_window->swapChainImageSize();
- VkClearColorValue clearColor = { 0.67f, 0.84f, 0.9f, 1.0f };
+ VkClearColorValue clearColor = {{ 0.67f, 0.84f, 0.9f, 1.0f }};
VkClearDepthStencilValue clearDS = { 1, 0 };
VkClearValue clearValues[3];
memset(clearValues, 0, sizeof(clearValues));
diff --git a/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp b/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp
index 543eb7884a..ffe1a31442 100644
--- a/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp
+++ b/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp
@@ -768,7 +768,7 @@ void VulkanRenderer::startNextFrame()
// Add the necessary barriers and do the host-linear -> device-optimal copy, if not yet done.
ensureTexture();
- VkClearColorValue clearColor = { 0, 0, 0, 1 };
+ VkClearColorValue clearColor = {{ 0, 0, 0, 1 }};
VkClearDepthStencilValue clearDS = { 1, 0 };
VkClearValue clearValues[2];
memset(clearValues, 0, sizeof(clearValues));
diff --git a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp b/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp
index 0a7d1d4174..31d32307a9 100644
--- a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp
+++ b/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp
@@ -94,7 +94,7 @@ void VulkanRenderer::startNextFrame()
if (m_green > 1.0f)
m_green = 0.0f;
- VkClearColorValue clearColor = { 0.0f, m_green, 0.0f, 1.0f };
+ VkClearColorValue clearColor = {{ 0.0f, m_green, 0.0f, 1.0f }};
VkClearDepthStencilValue clearDS = { 1.0f, 0 };
VkClearValue clearValues[2];
memset(clearValues, 0, sizeof(clearValues));
diff --git a/examples/vulkan/shared/trianglerenderer.cpp b/examples/vulkan/shared/trianglerenderer.cpp
index f346f90c89..6ed7e65ff9 100644
--- a/examples/vulkan/shared/trianglerenderer.cpp
+++ b/examples/vulkan/shared/trianglerenderer.cpp
@@ -452,7 +452,7 @@ void TriangleRenderer::startNextFrame()
VkCommandBuffer cb = m_window->currentCommandBuffer();
const QSize sz = m_window->swapChainImageSize();
- VkClearColorValue clearColor = { 0, 0, 0, 1 };
+ VkClearColorValue clearColor = {{ 0, 0, 0, 1 }};
VkClearDepthStencilValue clearDS = { 1, 0 };
VkClearValue clearValues[3];
memset(clearValues, 0, sizeof(clearValues));
diff --git a/examples/widgets/doc/src/dirview.qdoc b/examples/widgets/doc/src/dirview.qdoc
index d9a16fa58d..6db339eced 100644
--- a/examples/widgets/doc/src/dirview.qdoc
+++ b/examples/widgets/doc/src/dirview.qdoc
@@ -37,6 +37,10 @@
\borderedimage dirview-example.png
+ \quotefromfile itemviews/dirview/main.cpp
+ \skipto QCommandLineParser parser
+ \printuntil parser.positionalArguments
+
The example supports a number of command line options.
These options include:
\list
@@ -47,22 +51,17 @@
use custom directory options
\endlist
- \quotefromfile itemviews/dirview/main.cpp
- \skipto QCommandLineParser parser
- \printuntil parser.positionalArguments
-
- Declares a QFileSystemModel as data model for viewing
- the local file system. QFileSystem works with a cache, that is,
- it is updated continually with QFileSystemWatcher on that folder.
-
\skipto QFileSystemModel
\printuntil tree.setModel
- Creates a model/view implementation called \c tree
- for viewing the filesystem.
+ Declares \c model as data model for reading the local filesystem.
+ \c model.setRootPath("") sets the current folder as the folder from
+ which \c model will start reading.
+ QTreeView object \c tree visualizes the filesystem in a tree structure.
\skipto tree.setAnimated(false)
\printuntil tree.setWindowTitle
- Sets some formatting options for \c tree.
+ Sets layout options for animation, indentation, sorting, and sizing of the
+ filesystem tree.
*/
diff --git a/examples/widgets/doc/src/lineedits.qdoc b/examples/widgets/doc/src/lineedits.qdoc
index 5cf321bbb1..08de3c08dd 100644
--- a/examples/widgets/doc/src/lineedits.qdoc
+++ b/examples/widgets/doc/src/lineedits.qdoc
@@ -148,7 +148,7 @@
\snippet widgets/lineedits/window.cpp 12
Each entry in the relevant combobox is associated with an input mask. We set
- a new mask by calling the QLineEdit::setMask() function with a suitable string;
+ a new mask by calling the QLineEdit::setInputMask() function with a suitable string;
the mask is disabled if an empty string is used.
The \c accessChanged() slot handles changes to the combobox in the
diff --git a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
index 4259aab803..81928a4ee1 100644
--- a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
@@ -174,7 +174,7 @@ void GraphWidget::timerEvent(QTimerEvent *event)
bool itemsMoved = false;
foreach (Node *node, nodes) {
- if (node->advance())
+ if (node->advancePosition())
itemsMoved = true;
}
diff --git a/examples/widgets/graphicsview/elasticnodes/node.cpp b/examples/widgets/graphicsview/elasticnodes/node.cpp
index 94df45524a..71737c984b 100644
--- a/examples/widgets/graphicsview/elasticnodes/node.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/node.cpp
@@ -138,7 +138,7 @@ void Node::calculateForces()
//! [6]
//! [7]
-bool Node::advance()
+bool Node::advancePosition()
{
if (newPos == pos())
return false;
diff --git a/examples/widgets/graphicsview/elasticnodes/node.h b/examples/widgets/graphicsview/elasticnodes/node.h
index 487ae0d68e..43ea1fb24b 100644
--- a/examples/widgets/graphicsview/elasticnodes/node.h
+++ b/examples/widgets/graphicsview/elasticnodes/node.h
@@ -73,7 +73,7 @@ public:
int type() const override { return Type; }
void calculateForces();
- bool advance();
+ bool advancePosition();
QRectF boundingRect() const override;
QPainterPath shape() const override;
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
index b2c5ccc473..fe31207326 100644
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
+++ b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
@@ -187,6 +187,13 @@ void MainWindow::setupMenuBar()
#endif
dockWidgetMenu = menuBar()->addMenu(tr("&Dock Widgets"));
+
+ QMenu *aboutMenu = menuBar()->addMenu(tr("About"));
+ QAction *aboutAct = aboutMenu->addAction(tr("&About"), this, &MainWindow::about);
+ aboutAct->setStatusTip(tr("Show the application's About box"));
+
+ QAction *aboutQtAct = aboutMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
+ aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
}
void MainWindow::setDockOptions()
@@ -476,3 +483,8 @@ void MainWindow::destroyDockWidget(QAction *action)
if (destroyDockWidgetMenu->isEmpty())
destroyDockWidgetMenu->setEnabled(false);
}
+
+void MainWindow::about()
+{
+ QMessageBox::about(this, tr("About MainWindows"), message);
+}
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.h b/examples/widgets/mainwindows/mainwindow/mainwindow.h
index 9b1af6df80..a2c9d30ded 100644
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.h
+++ b/examples/widgets/mainwindows/mainwindow/mainwindow.h
@@ -77,6 +77,8 @@ public slots:
void createDockWidget();
void destroyDockWidget(QAction *action);
+ void about();
+
private:
void setupToolBar();
void setupMenuBar();
diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp
index 5433b28025..78c174a8bf 100644
--- a/examples/widgets/painting/gradients/gradients.cpp
+++ b/examples/widgets/painting/gradients/gradients.cpp
@@ -88,7 +88,8 @@ ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent)
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
- connect(m_hoverPoints, SIGNAL(pointsChanged(QPolygonF)), this, SIGNAL(colorsChanged()));
+ connect(m_hoverPoints, &HoverPoints::pointsChanged,
+ this, &ShadeWidget::colorsChanged);
}
QPolygonF ShadeWidget::points() const
@@ -191,10 +192,14 @@ GradientEditor::GradientEditor(QWidget *parent)
vbox->addWidget(m_blue_shade);
vbox->addWidget(m_alpha_shade);
- connect(m_red_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated()));
- connect(m_green_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated()));
- connect(m_blue_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated()));
- connect(m_alpha_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated()));
+ connect(m_red_shade, &ShadeWidget::colorsChanged,
+ this, &GradientEditor::pointsUpdated);
+ connect(m_green_shade, &ShadeWidget::colorsChanged,
+ this, &GradientEditor::pointsUpdated);
+ connect(m_blue_shade, &ShadeWidget::colorsChanged,
+ this, &GradientEditor::pointsUpdated);
+ connect(m_alpha_shade, &ShadeWidget::colorsChanged,
+ this, &GradientEditor::pointsUpdated);
}
inline static bool x_less_than(const QPointF &p1, const QPointF &p2)
@@ -354,33 +359,46 @@ GradientWidget::GradientWidget(QWidget *parent)
defaultsGroupLayout->addWidget(default3Button);
editorGroupLayout->addWidget(default4Button);
- connect(m_editor, SIGNAL(gradientStopsChanged(QGradientStops)),
- m_renderer, SLOT(setGradientStops(QGradientStops)));
-
- connect(m_linearButton, SIGNAL(clicked()), m_renderer, SLOT(setLinearGradient()));
- connect(m_radialButton, SIGNAL(clicked()), m_renderer, SLOT(setRadialGradient()));
- connect(m_conicalButton, SIGNAL(clicked()), m_renderer, SLOT(setConicalGradient()));
-
- connect(m_padSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setPadSpread()));
- connect(m_reflectSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setReflectSpread()));
- connect(m_repeatSpreadButton, SIGNAL(clicked()), m_renderer, SLOT(setRepeatSpread()));
-
- connect(default1Button, SIGNAL(clicked()), this, SLOT(setDefault1()));
- connect(default2Button, SIGNAL(clicked()), this, SLOT(setDefault2()));
- connect(default3Button, SIGNAL(clicked()), this, SLOT(setDefault3()));
- connect(default4Button, SIGNAL(clicked()), this, SLOT(setDefault4()));
-
- connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource()));
+ connect(m_editor, &GradientEditor::gradientStopsChanged,
+ m_renderer, &GradientRenderer::setGradientStops);
+ connect(m_linearButton, &QRadioButton::clicked,
+ m_renderer, &GradientRenderer::setLinearGradient);
+ connect(m_radialButton, &QRadioButton::clicked,
+ m_renderer, &GradientRenderer::setRadialGradient);
+ connect(m_conicalButton,&QRadioButton::clicked,
+ m_renderer, &GradientRenderer::setConicalGradient);
+
+ connect(m_padSpreadButton, &QRadioButton::clicked,
+ m_renderer, &GradientRenderer::setPadSpread);
+ connect(m_reflectSpreadButton, &QRadioButton::clicked,
+ m_renderer, &GradientRenderer::setReflectSpread);
+ connect(m_repeatSpreadButton, &QRadioButton::clicked,
+ m_renderer, &GradientRenderer::setRepeatSpread);
+
+ connect(default1Button, &QPushButton::clicked,
+ this, &GradientWidget::setDefault1);
+ connect(default2Button, &QPushButton::clicked,
+ this, &GradientWidget::setDefault2);
+ connect(default3Button, &QPushButton::clicked,
+ this, &GradientWidget::setDefault3);
+ connect(default4Button, &QPushButton::clicked,
+ this, &GradientWidget::setDefault4);
+
+ connect(showSourceButton, &QPushButton::clicked,
+ m_renderer, &GradientRenderer::showSource);
#ifdef QT_OPENGL_SUPPORT
- connect(enableOpenGLButton, SIGNAL(clicked(bool)), m_renderer, SLOT(enableOpenGL(bool)));
+ connect(enableOpenGLButton, QOverload<bool>::of(&QPushButton::clicked),
+ m_renderer, &ArthurFrame::enableOpenGL);
#endif
- connect(whatsThisButton, SIGNAL(clicked(bool)), m_renderer, SLOT(setDescriptionEnabled(bool)));
- connect(whatsThisButton, SIGNAL(clicked(bool)),
- m_renderer->hoverPoints(), SLOT(setDisabled(bool)));
- connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)),
- whatsThisButton, SLOT(setChecked(bool)));
- connect(m_renderer, SIGNAL(descriptionEnabledChanged(bool)),
- m_renderer->hoverPoints(), SLOT(setDisabled(bool)));
+
+ connect(whatsThisButton, QOverload<bool>::of(&QPushButton::clicked),
+ m_renderer, &ArthurFrame::setDescriptionEnabled);
+ connect(whatsThisButton, QOverload<bool>::of(&QPushButton::clicked),
+ m_renderer->hoverPoints(), &HoverPoints::setDisabled);
+ connect(m_renderer, QOverload<bool>::of(&ArthurFrame::descriptionEnabledChanged),
+ whatsThisButton, &QPushButton::setChecked);
+ connect(m_renderer, QOverload<bool>::of(&ArthurFrame::descriptionEnabledChanged),
+ m_renderer->hoverPoints(), &HoverPoints::setDisabled);
m_renderer->loadSourceFile(":res/gradients/gradients.cpp");
m_renderer->loadDescription(":res/gradients/gradients.html");
diff --git a/examples/widgets/richtext/orderform/detailsdialog.cpp b/examples/widgets/richtext/orderform/detailsdialog.cpp
index 3ec13c4c70..9ef9eff73d 100644
--- a/examples/widgets/richtext/orderform/detailsdialog.cpp
+++ b/examples/widgets/richtext/orderform/detailsdialog.cpp
@@ -71,8 +71,8 @@ DetailsDialog::DetailsDialog(const QString &title, QWidget *parent)
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(verify()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &DetailsDialog::verify);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &DetailsDialog::reject);
//! [0]
//! [1]
diff --git a/examples/widgets/richtext/orderform/mainwindow.cpp b/examples/widgets/richtext/orderform/mainwindow.cpp
index 030072978e..b207ee4dbc 100644
--- a/examples/widgets/richtext/orderform/mainwindow.cpp
+++ b/examples/widgets/richtext/orderform/mainwindow.cpp
@@ -75,8 +75,8 @@ MainWindow::MainWindow()
letters = new QTabWidget;
- connect(newAction, SIGNAL(triggered()), this, SLOT(openDialog()));
- connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(newAction, &QAction::triggered, this, &MainWindow::openDialog);
+ connect(quitAction, &QAction::triggered, this, &MainWindow::close);
setCentralWidget(letters);
setWindowTitle(tr("Order Form"));
diff --git a/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp b/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp
index 1efc7b9355..64b59d506e 100644
--- a/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp
+++ b/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp
@@ -83,10 +83,10 @@ void EchoWindow::createGUI()
label->setFrameStyle(QFrame::Box | QFrame::Plain);
button = new QPushButton(tr("Send Message"));
- connect(lineEdit, SIGNAL(editingFinished()),
- this, SLOT(sendEcho()));
- connect(button, SIGNAL(clicked()),
- this, SLOT(sendEcho()));
+ connect(lineEdit, &QLineEdit::editingFinished,
+ this, &EchoWindow::sendEcho);
+ connect(button, &QPushButton::clicked,
+ this, &EchoWindow::sendEcho);
layout = new QGridLayout;
layout->addWidget(new QLabel(tr("Message:")), 0, 0);
diff --git a/examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp b/examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp
index f33155375c..1016afba07 100644
--- a/examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp
+++ b/examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp
@@ -55,10 +55,6 @@
#include <QStandardItem>
#include "mainwindow.h"
-
-const int ROWS = 2;
-const int COLUMNS = 3;
-
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
diff --git a/examples/widgets/widgets/digitalclock/digitalclock.cpp b/examples/widgets/widgets/digitalclock/digitalclock.cpp
index 6787c975c5..dec7e64fc3 100644
--- a/examples/widgets/widgets/digitalclock/digitalclock.cpp
+++ b/examples/widgets/widgets/digitalclock/digitalclock.cpp
@@ -59,7 +59,7 @@ DigitalClock::DigitalClock(QWidget *parent)
setSegmentStyle(Filled);
QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
+ connect(timer, &QTimer::timeout, this, &DigitalClock::showTime);
timer->start(1000);
showTime();
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 66acedef55..2ed708e085 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -28,9 +28,13 @@ CMAKE_OUT_DIR = $$MODULE_BASE_OUTDIR/lib/cmake
CMAKE_MODULE_NAME = $$cmakeModuleName($${MODULE})
+!generated_privates {
+ isEmpty(SYNCQT.INJECTED_PRIVATE_HEADER_FILES):isEmpty(SYNCQT.PRIVATE_HEADER_FILES): \
+ CMAKE_NO_PRIVATE_INCLUDES = true
+}
+
split_incpath {
CMAKE_ADD_SOURCE_INCLUDE_DIRS = true
- CMAKE_NO_PRIVATE_INCLUDES = true # Don't add private includes in the build dir which don't exist
CMAKE_SOURCE_INCLUDES = \
$$cmakeTargetPaths($$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/Qt$${CMAKE_MODULE_NAME})
CMAKE_SOURCE_PRIVATE_INCLUDES = \
@@ -53,10 +57,6 @@ contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*") {
CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
}
-isEmpty(QT.$${MODULE}_private.includes)| \
- !exists($$first(QT.$${MODULE}_private.includes)): \
- CMAKE_NO_PRIVATE_INCLUDES = true
-
CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])
contains(CMAKE_LIB_DIR,"^\\.\\./.*") {
CMAKE_LIB_DIR = $$[QT_INSTALL_LIBS]/
diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf
index 50a1ec6764..21d487f1f9 100644
--- a/mkspecs/features/mac/default_post.prf
+++ b/mkspecs/features/mac/default_post.prf
@@ -210,3 +210,10 @@ cache(QMAKE_XCODE_DEVELOPER_PATH, stash)
cache(QMAKE_XCODE_VERSION, stash)
QMAKE_XCODE_LIBRARY_SUFFIX = $$qtPlatformTargetSuffix()
+
+xcode_product_bundle_identifier_setting.name = PRODUCT_BUNDLE_IDENTIFIER
+xcode_product_bundle_identifier_setting.value = $$QMAKE_TARGET_BUNDLE_PREFIX
+isEmpty(xcode_product_bundle_identifier_setting.value): \
+ xcode_product_bundle_identifier_setting.value = "com.yourcompany"
+xcode_product_bundle_identifier_setting.value = "$${xcode_product_bundle_identifier_setting.value}.${PRODUCT_NAME:rfc1034identifier}"
+QMAKE_MAC_XCODE_SETTINGS += xcode_product_bundle_identifier_setting
diff --git a/mkspecs/features/mac/default_pre.prf b/mkspecs/features/mac/default_pre.prf
index f1a4ca77b2..e3534561a5 100644
--- a/mkspecs/features/mac/default_pre.prf
+++ b/mkspecs/features/mac/default_pre.prf
@@ -58,10 +58,3 @@ QMAKE_XCODE_LIBRARY_SUFFIX_SETTING = QT_LIBRARY_SUFFIX
xcode_copy_phase_strip_setting.name = COPY_PHASE_STRIP
xcode_copy_phase_strip_setting.value = NO
QMAKE_MAC_XCODE_SETTINGS += xcode_copy_phase_strip_setting
-
-xcode_product_bundle_identifier_setting.name = PRODUCT_BUNDLE_IDENTIFIER
-xcode_product_bundle_identifier_setting.value = $$QMAKE_TARGET_BUNDLE_PREFIX
-isEmpty(xcode_product_bundle_identifier_setting.value): \
- xcode_product_bundle_identifier_setting.value = "com.yourcompany"
-xcode_product_bundle_identifier_setting.value = "$${xcode_product_bundle_identifier_setting.value}.${PRODUCT_NAME:rfc1034identifier}"
-QMAKE_MAC_XCODE_SETTINGS += xcode_product_bundle_identifier_setting
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index 3b1f904253..18b62c5135 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -1603,7 +1603,17 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
}
}
- t << "\t\t\t\t" << writeSettings("SYMROOT", Option::output_dir) << ";\n";
+ // The symroot is marked by xcodebuild as excluded from Time Machine
+ // backups, as it's a temporary build dir, so we don't want it to be
+ // the same as the possibe in-source dir, as that would leave out
+ // sources from being backed up.
+ t << "\t\t\t\t" << writeSettings("SYMROOT",
+ Option::output_dir + Option::dir_sep + ".xcode") << ";\n";
+
+ // The configuration build dir however is not treated as excluded,
+ // so we can safely point it to the root output dir.
+ t << "\t\t\t\t" << writeSettings("CONFIGURATION_BUILD_DIR",
+ Option::output_dir + Option::dir_sep + "$(CONFIGURATION)") << ";\n";
if (!project->isEmpty("DESTDIR")) {
ProString dir = project->first("DESTDIR");
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 82573347b6..99aecdd8ce 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -1953,11 +1953,12 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
}
QT_PCLOSE(proc);
if(!indeps.isEmpty()) {
+ QDir outDir(Option::output_dir);
// ### This is basically fubar. Add 'lines' flag to CONFIG?
QStringList dep_cmd_deps = indeps.replace('\n', ' ').simplified().split(' ');
for(int i = 0; i < dep_cmd_deps.count(); ++i) {
QString &file = dep_cmd_deps[i];
- QString absFile = QDir(Option::output_dir).absoluteFilePath(file);
+ QString absFile = outDir.absoluteFilePath(file);
if (exists(absFile)) {
file = absFile;
} else {
@@ -1965,8 +1966,9 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
QList<QMakeLocalFileName> depdirs = QMakeSourceFileInfo::dependencyPaths();
for (QList<QMakeLocalFileName>::Iterator dit = depdirs.begin();
dit != depdirs.end(); ++dit) {
- if (exists((*dit).local() + '/' + file)) {
- localFile = (*dit).local() + '/' + file;
+ QString lf = outDir.absoluteFilePath((*dit).local() + '/' + file);
+ if (exists(lf)) {
+ localFile = lf;
break;
}
}
@@ -2045,11 +2047,12 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
}
QT_PCLOSE(proc);
if(!indeps.isEmpty()) {
+ QDir outDir(Option::output_dir);
// ### This is basically fubar. Add 'lines' flag to CONFIG?
QStringList dep_cmd_deps = indeps.replace('\n', ' ').simplified().split(' ');
for(int i = 0; i < dep_cmd_deps.count(); ++i) {
QString &file = dep_cmd_deps[i];
- QString absFile = QDir(Option::output_dir).absoluteFilePath(file);
+ QString absFile = outDir.absoluteFilePath(file);
if (exists(absFile)) {
file = absFile;
} else {
@@ -2057,8 +2060,9 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
QList<QMakeLocalFileName> depdirs = QMakeSourceFileInfo::dependencyPaths();
for (QList<QMakeLocalFileName>::Iterator dit = depdirs.begin();
dit != depdirs.end(); ++dit) {
- if (exists((*dit).local() + '/' + file)) {
- localFile = (*dit).local() + '/' + file;
+ QString lf = outDir.absoluteFilePath((*dit).local() + '/' + file);
+ if (exists(lf)) {
+ localFile = lf;
break;
}
}
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index 30f99174f8..894020d2bd 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -461,10 +461,24 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
opt = (*++it).toQString();
else
opt = opt.mid(10).trimmed();
+ static const QChar suffixMarker = ',';
+ const int suffixPosition = opt.indexOf(suffixMarker);
+ const bool hasSuffix = suffixPosition >= 0;
+ QString frameworkName = opt;
+ if (hasSuffix) {
+ frameworkName.truncate(suffixPosition);
+ opt.remove(suffixMarker); // Apply suffix by removing marker
+ }
for (const QMakeLocalFileName &dir : qAsConst(frameworkdirs)) {
- QString prl = dir.local() + "/" + opt + ".framework/" + opt + Option::prl_ext;
- if (processPrlFile(prl))
+ QString frameworkDirectory = dir.local() + "/" + frameworkName + + ".framework/";
+ QString suffixedPrl = frameworkDirectory + opt + Option::prl_ext;
+ if (processPrlFile(suffixedPrl))
break;
+ if (hasSuffix) {
+ QString unsuffixedPrl = frameworkDirectory + frameworkName + Option::prl_ext;
+ if (processPrlFile(unsuffixedPrl))
+ break;
+ }
}
} else {
if (opt.length() == 10)
diff --git a/src/3rdparty/freetype/LICENSE.txt b/src/3rdparty/freetype/LICENSE.txt
index 382225f105..1119880c09 100644
--- a/src/3rdparty/freetype/LICENSE.txt
+++ b/src/3rdparty/freetype/LICENSE.txt
@@ -85,7 +85,7 @@ Introduction
encourage you to use the following text:
"""
- Portions of this software are copyright © <year> The FreeType
+ Portions of this software are copyright © <year> The FreeType
Project (www.freetype.org). All rights reserved.
"""
diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java
index 424bf45c53..fc3d7e04ce 100644
--- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java
+++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java
@@ -355,12 +355,21 @@ public abstract class QtLoader {
destinationFile.createNewFile();
AssetManager assetsManager = m_context.getAssets();
- InputStream inputStream = assetsManager.open(source);
- OutputStream outputStream = new FileOutputStream(destinationFile);
- copyFile(inputStream, outputStream);
+ InputStream inputStream = null;
+ OutputStream outputStream = null;
+ try {
+ inputStream = assetsManager.open(source);
+ outputStream = new FileOutputStream(destinationFile);
+ copyFile(inputStream, outputStream);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (inputStream != null)
+ inputStream.close();
- inputStream.close();
- outputStream.close();
+ if (outputStream != null)
+ outputStream.close();
+ }
}
private static void createBundledBinary(String source, String destination)
@@ -377,12 +386,21 @@ public abstract class QtLoader {
destinationFile.createNewFile();
- InputStream inputStream = new FileInputStream(source);
- OutputStream outputStream = new FileOutputStream(destinationFile);
- copyFile(inputStream, outputStream);
+ InputStream inputStream = null;
+ OutputStream outputStream = null;
+ try {
+ inputStream = new FileInputStream(source);
+ outputStream = new FileOutputStream(destinationFile);
+ copyFile(inputStream, outputStream);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (inputStream != null)
+ inputStream.close();
- inputStream.close();
- outputStream.close();
+ if (outputStream != null)
+ outputStream.close();
+ }
}
private boolean cleanCacheIfNecessary(String pluginsPrefix, long packageVersion)
@@ -391,12 +409,20 @@ public abstract class QtLoader {
long cacheVersion = 0;
if (versionFile.exists() && versionFile.canRead()) {
+ DataInputStream inputStream = null;
try {
- DataInputStream inputStream = new DataInputStream(new FileInputStream(versionFile));
+ inputStream = new DataInputStream(new FileInputStream(versionFile));
cacheVersion = inputStream.readLong();
- inputStream.close();
} catch (Exception e) {
e.printStackTrace();
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
}
@@ -431,9 +457,16 @@ public abstract class QtLoader {
versionFile.createNewFile();
- DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(versionFile));
- outputStream.writeLong(packageVersion);
- outputStream.close();
+ DataOutputStream outputStream = null;
+ try {
+ outputStream = new DataOutputStream(new FileOutputStream(versionFile));
+ outputStream.writeLong(packageVersion);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (outputStream != null)
+ outputStream.close();
+ }
}
{
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
index ceb3f8adf3..2d7b9a9ac8 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -387,11 +387,11 @@ CONFIG += no_keywords
//! [34]
QString FriendlyConversation::greeting(int type)
{
-static const char *greeting_strings[] = {
- QT_TR_NOOP("Hello"),
- QT_TR_NOOP("Goodbye")
-};
-return tr(greeting_strings[type]);
+ static const char *greeting_strings[] = {
+ QT_TR_NOOP("Hello"),
+ QT_TR_NOOP("Goodbye")
+ };
+ return tr(greeting_strings[type]);
}
//! [34]
@@ -410,7 +410,7 @@ QString FriendlyConversation::greeting(int type)
QString global_greeting(int type)
{
return qApp->translate("FriendlyConversation",
- greeting_strings[type]);
+ greeting_strings[type]);
}
//! [35]
@@ -434,8 +434,8 @@ QString FriendlyConversation::greeting(int type)
QString global_greeting(int type)
{
return qApp->translate("FriendlyConversation",
- greeting_strings[type].source,
- greeting_strings[type].comment);
+ greeting_strings[type].source,
+ greeting_strings[type].comment);
}
//! [36]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
index ac17de1bee..27565a7878 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
@@ -54,11 +54,14 @@ QList<QDate> dateList;
//! [0]
-//! [1]
-QList<QString> list;
-list << "one" << "two" << "three";
-// list: ["one", "two", "three"]
-//! [1]
+//! [1a]
+QList<QString> list = { "one", "two", "three" };
+//! [1a]
+
+
+//! [1b]
+list << "four" << "five";
+//! [1b]
//! [2]
diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp
index 4d9c015747..55c60650fe 100644
--- a/src/corelib/doc/snippets/qstringlist/main.cpp
+++ b/src/corelib/doc/snippets/qstringlist/main.cpp
@@ -61,10 +61,13 @@ public:
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
-//! [0]
- QStringList fonts;
- fonts << "Arial" << "Helvetica" << "Times" << "Courier";
-//! [0]
+//! [0a]
+ QStringList fonts = { "Arial", "Helvetica", "Times" };
+//! [0a]
+
+//! [0b]
+ fonts << "Courier" << "Verdana";
+//! [0b]
//! [1]
for (int i = 0; i < fonts.size(); ++i)
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index ad015ee048..2ca627e851 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -648,10 +648,10 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
compiler or platform specific code to their application.
The remaining macros are convenience macros for larger operations:
- The QT_TRANSLATE_NOOP() and QT_TR_NOOP() macros provide the
- possibility of marking text for dynamic translation,
- i.e. translation without changing the stored source text. The
- Q_ASSERT() and Q_ASSERT_X() enables warning messages of various
+ The QT_TR_NOOP(), QT_TRANSLATE_NOOP(), and QT_TRANSLATE_NOOP3()
+ macros provide the possibility of marking strings for delayed
+ translation.
+ The Q_ASSERT() and Q_ASSERT_X() enables warning messages of various
level of refinement. The Q_FOREACH() and foreach() macros
implement Qt's foreach loop.
@@ -662,11 +662,11 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
memory, if the pointer is 0. The qPrintable() and qUtf8Printable()
macros represent an easy way of printing text.
- Finally, the QT_POINTER_SIZE macro expands to the size of a
- pointer in bytes, and the QT_VERSION and QT_VERSION_STR macros
- expand to a numeric value or a string, respectively, specifying
- Qt's version number, i.e the version the application is compiled
- against.
+ The QT_POINTER_SIZE macro expands to the size of a pointer in bytes.
+
+ The macros QT_VERSION and QT_VERSION_STR expand to a numeric value
+ or a string, respectively, that specifies the version of Qt that the
+ application is compiled against.
\sa <QtAlgorithms>, QSysInfo
*/
@@ -3268,14 +3268,15 @@ QByteArray qgetenv(const char *varName)
/*!
- QString qEnvironmentVariable(const char *varName, const QString &defaultValue);
+ \fn QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
+ \fn QString qEnvironmentVariable(const char *varName)
\relates <QtGlobal>
\since 5.10
- Returns the value of the environment variable with name \a varName as a
- QString. If no variable by that name is found in the environment, this
- function returns \a defaultValue.
+ These functions return the value of the environment variable, \a varName, as a
+ QString. If no variable \a varName is found in the environment and \a defaultValue
+ is provided, \a defaultValue is returned. Otherwise QString() is returned.
The Qt environment manipulation functions are thread-safe, but this
requires that the C library equivalent functions like getenv and putenv are
@@ -3344,9 +3345,6 @@ QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
#endif
}
-/*!
- \internal
-*/
QString qEnvironmentVariable(const char *varName)
{
return qEnvironmentVariable(varName, QString());
@@ -3678,19 +3676,18 @@ bool qunsetenv(const char *varName)
\macro QT_TR_NOOP(sourceText)
\relates <QtGlobal>
- Marks the string literal \a sourceText for dynamic translation in
- the current context (class), i.e the stored \a sourceText will not
- be altered.
+ Marks the UTF-8 encoded string literal \a sourceText for delayed
+ translation in the current context (class).
- The macro expands to \a sourceText.
+ The macro tells lupdate to collect the string, and expands to
+ \a sourceText itself.
Example:
\snippet code/src_corelib_global_qglobal.cpp 34
- The macro QT_TR_NOOP_UTF8() is identical except that it tells lupdate
- that the source string is encoded in UTF-8. Corresponding variants
- exist in the QT_TRANSLATE_NOOP() family of macros, too.
+ The macro QT_TR_NOOP_UTF8() is identical and obsolete; this applies
+ to all other _UTF8 macros as well.
\sa QT_TRANSLATE_NOOP(), {Internationalization with Qt}
*/
@@ -3699,12 +3696,12 @@ bool qunsetenv(const char *varName)
\macro QT_TRANSLATE_NOOP(context, sourceText)
\relates <QtGlobal>
- Marks the string literal \a sourceText for dynamic translation in
- the given \a context; i.e, the stored \a sourceText will not be
- altered. The \a context is typically a class and also needs to
- be specified as string literal.
+ Marks the UTF-8 encoded string literal \a sourceText for delayed
+ translation in the given \a context. The \a context is typically
+ a class name and also needs to be specified as a string literal.
- The macro expands to \a sourceText.
+ The macro tells lupdate to collect the string, and expands to
+ \a sourceText itself.
Example:
@@ -3714,18 +3711,19 @@ bool qunsetenv(const char *varName)
*/
/*!
- \macro QT_TRANSLATE_NOOP3(context, sourceText, comment)
+ \macro QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)
\relates <QtGlobal>
\since 4.4
- Marks the string literal \a sourceText for dynamic translation in the
- given \a context and with \a comment, i.e the stored \a sourceText will
- not be altered. The \a context is typically a class and also needs to
- be specified as string literal. The string literal \a comment
- will be available for translators using e.g. Qt Linguist.
+ Marks the UTF-8 encoded string literal \a sourceText for delayed
+ translation in the given \a context with the given \a disambiguation.
+ The \a context is typically a class and also needs to be specified
+ as a string literal. The string literal \a disambiguation should be
+ a short semantic tag to tell apart otherwise identical strings.
- The macro expands to anonymous struct of the two string
- literals passed as \a sourceText and \a comment.
+ The macro tells lupdate to collect the string, and expands to an
+ anonymous struct of the two string literals passed as \a sourceText
+ and \a disambiguation.
Example:
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index e31d4d9ad7..3684c6b5de 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1062,7 +1062,7 @@ template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelpe
#define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment}
#define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment}
-#ifndef QT_NO_TRANSLATION // ### This should enclose the NOOPs above
+#ifndef QT_NO_TRANSLATION // ### Qt6: This should enclose the NOOPs above
// Defined in qcoreapplication.cpp
// The better name qTrId() is reserved for an upcoming function which would
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 17002c4231..7444145e82 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -208,6 +208,7 @@ static bool isDefaultCategory(const char *category)
/*!
Returns true if writing to \c stderr is supported.
+ \internal
\sa stderrHasConsoleAttached()
*/
static bool systemHasStderr()
@@ -236,6 +237,7 @@ static bool systemHasStderr()
the output might still end up visible to the user. For this reason, we don't guard
the stderr output in the default message handler with stderrHasConsoleAttached().
+ \internal
\sa systemHasStderr()
*/
bool stderrHasConsoleAttached()
@@ -288,6 +290,7 @@ namespace QtPrivate {
This is normally the case if \c stderr has a console attached, but may be overridden
by the user by setting the QT_FORCE_STDERR_LOGGING environment variable to \c 1.
+ \internal
\sa stderrHasConsoleAttached()
*/
bool shouldLogToStderr()
diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp
index b029274329..a6c27d19c0 100644
--- a/src/corelib/io/qloggingcategory.cpp
+++ b/src/corelib/io/qloggingcategory.cpp
@@ -147,9 +147,15 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
Rules are evaluated in text order, from first to last. That is, if two rules
apply to a category/type, the rule that comes later is applied.
- Rules can be set via \l setFilterRules(). Since Qt 5.3, logging rules can also
- be set in the \c QT_LOGGING_RULES environment variable, and
- are automatically loaded from the \c [Rules] section of a logging
+ Rules can be set via \l setFilterRules():
+
+ \code
+ QLoggingCategory::setFilterRules("*.debug=false\n"
+ "driver.usb.debug=true");
+ \endcode
+
+ Since Qt 5.3, logging rules are also
+ automatically loaded from the \c [Rules] section of a logging
configuration file. Such configuration files are looked up in the QtProject
configuration directory, or explicitly set in a \c QT_LOGGING_CONF
environment variable:
@@ -160,19 +166,18 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
driver.usb.debug=true
\endcode
- Rules set by \l setFilterRules() take precedence over rules specified
- in the QtProject configuration directory, and can, in turn, be
- overwritten by rules from the configuration file specified by
- \c QT_LOGGING_CONF, and rules set by \c QT_LOGGING_RULES.
-
-
- Since Qt 5.6, \c QT_LOGGING_RULES may contain multiple rules separated
- by semicolons:
+ Since Qt 5.3, logging rules can also be specified in a \c QT_LOGGING_RULES
+ environment variable. And since Qt 5.6, multiple rules can also be
+ separated by semicolons:
\code
QT_LOGGING_RULES="*.debug=false;driver.usb.debug=true"
\endcode
+ Rules set by \l setFilterRules() take precedence over rules specified
+ in the QtProject configuration directory, and can, in turn, be
+ overwritten by rules from the configuration file specified by
+ \c QT_LOGGING_CONF, and rules set by \c QT_LOGGING_RULES.
Order of evaluation:
\list
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 3a62a67e3b..b1ec2c560c 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -499,8 +499,13 @@ void QProcessPrivate::startProcess()
if (!openChannel(stdinChannel) ||
!openChannel(stdoutChannel) ||
- !openChannel(stderrChannel))
+ !openChannel(stderrChannel)) {
+ QString errorString = QProcess::tr("Process failed to start: %1").arg(qt_error_string());
+ cleanup();
+ setErrorAndEmit(QProcess::FailedToStart, errorString);
+ q->setProcessState(QProcess::NotRunning);
return;
+ }
const QString args = qt_create_commandline(program, arguments, nativeArguments);
QByteArray envlist;
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index 9af4fd9133..edb9bb9098 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -1502,30 +1502,40 @@ bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent) cons
&& d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid())
return false;
}
+
+ auto isSelectable = [&](int row, int column) {
+ Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
+ return (flags & Qt::ItemIsSelectable);
+ };
+
+ const int colCount = d->model->columnCount(parent);
+ int unselectable = 0;
// add ranges and currentSelection and check through them all
QList<QItemSelectionRange>::const_iterator it;
QList<QItemSelectionRange> joined = d->ranges;
if (d->currentSelection.count())
joined += d->currentSelection;
- int colCount = d->model->columnCount(parent);
for (int column = 0; column < colCount; ++column) {
+ if (!isSelectable(row, column)) {
+ ++unselectable;
+ continue;
+ }
+
for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
if ((*it).contains(row, column, parent)) {
- bool selectable = false;
- for (int i = column; !selectable && i <= (*it).right(); ++i) {
- Qt::ItemFlags flags = d->model->index(row, i, parent).flags();
- selectable = flags & Qt::ItemIsSelectable;
- }
- if (selectable){
- column = qMax(column, (*it).right());
- break;
+ for (int i = column; i <= (*it).right(); ++i) {
+ if (!isSelectable(row, i))
+ ++unselectable;
}
+
+ column = qMax(column, (*it).right());
+ break;
}
}
if (it == joined.constEnd())
return false;
}
- return colCount > 0; // no columns means no selected items
+ return unselectable < colCount;
}
/*!
@@ -1568,26 +1578,39 @@ bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent
}
}
}
+
+ auto isSelectable = [&](int row, int column) {
+ Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
+ return (flags & Qt::ItemIsSelectable);
+ };
+ const int rowCount = d->model->rowCount(parent);
+ int unselectable = 0;
+
// add ranges and currentSelection and check through them all
QList<QItemSelectionRange>::const_iterator it;
QList<QItemSelectionRange> joined = d->ranges;
if (d->currentSelection.count())
joined += d->currentSelection;
- int rowCount = d->model->rowCount(parent);
for (int row = 0; row < rowCount; ++row) {
- for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
- if ((*it).contains(row, column, parent)) {
- Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
- if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) {
- row = qMax(row, (*it).bottom());
- break;
- }
- }
- }
- if (it == joined.constEnd())
- return false;
+ if (!isSelectable(row, column)) {
+ ++unselectable;
+ continue;
+ }
+ for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
+ if ((*it).contains(row, column, parent)) {
+ for (int i = row; i <= (*it).bottom(); ++i) {
+ if (!isSelectable(i, column)) {
+ ++unselectable;
+ }
+ }
+ row = qMax(row, (*it).bottom());
+ break;
+ }
+ }
+ if (it == joined.constEnd())
+ return false;
}
- return rowCount > 0; // no rows means no selected items
+ return unselectable < rowCount;
}
/*!
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h
index 4775d3d47a..bd8da5c35d 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.h
+++ b/src/corelib/kernel/qabstracteventdispatcher.h
@@ -87,6 +87,7 @@ public:
QT_DEPRECATED inline void registerTimer(int timerId, int interval, QObject *object)
{ registerTimer(timerId, interval, Qt::CoarseTimer, object); }
#endif
+ // ### Qt6: change interval range to qint64 (or use QDeadlineTimer)
int registerTimer(int interval, Qt::TimerType timerType, QObject *object);
virtual void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) = 0;
virtual bool unregisterTimer(int timerId) = 0;
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index 7d529372c4..68e3c8f10d 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -311,9 +311,9 @@ static inline bool isTextFile(const QByteArray &data)
if (data.startsWith(bigEndianBOM) || data.startsWith(littleEndianBOM))
return true;
- // Check the first 32 bytes (see shared-mime spec)
+ // Check the first 128 bytes (see shared-mime spec)
const char *p = data.constData();
- const char *e = p + qMin(32, data.size());
+ const char *e = p + qMin(128, data.size());
for ( ; p < e; ++p) {
if ((unsigned char)(*p) < 32 && *p != 9 && *p !=10 && *p != 13)
return false;
diff --git a/src/corelib/serialization/qjson.cpp b/src/corelib/serialization/qjson.cpp
index e4bca3bcd0..7912b5040c 100644
--- a/src/corelib/serialization/qjson.cpp
+++ b/src/corelib/serialization/qjson.cpp
@@ -326,40 +326,35 @@ int Value::usedStorage(const Base *b) const
return alignedSize(s);
}
+inline bool isValidValueOffset(uint offset, uint tableOffset)
+{
+ return offset >= sizeof(Base)
+ && offset + sizeof(uint) <= tableOffset;
+}
+
bool Value::isValid(const Base *b) const
{
- int offset = 0;
switch (type) {
+ case QJsonValue::Null:
+ case QJsonValue::Bool:
+ return true;
case QJsonValue::Double:
- if (latinOrIntValue)
- break;
- Q_FALLTHROUGH();
+ return latinOrIntValue || isValidValueOffset(value, b->tableOffset);
case QJsonValue::String:
+ if (!isValidValueOffset(value, b->tableOffset))
+ return false;
+ if (latinOrIntValue)
+ return asLatin1String(b).isValid(b->tableOffset - value);
+ return asString(b).isValid(b->tableOffset - value);
case QJsonValue::Array:
+ return isValidValueOffset(value, b->tableOffset)
+ && static_cast<Array *>(base(b))->isValid(b->tableOffset - value);
case QJsonValue::Object:
- offset = value;
- break;
- case QJsonValue::Null:
- case QJsonValue::Bool:
+ return isValidValueOffset(value, b->tableOffset)
+ && static_cast<Object *>(base(b))->isValid(b->tableOffset - value);
default:
- break;
- }
-
- if (!offset)
- return true;
- if (offset + sizeof(uint) > b->tableOffset)
return false;
-
- int s = usedStorage(b);
- if (!s)
- return true;
- if (s < 0 || s > (int)b->tableOffset - offset)
- return false;
- if (type == QJsonValue::Array)
- return static_cast<Array *>(base(b))->isValid(s);
- if (type == QJsonValue::Object)
- return static_cast<Object *>(base(b))->isValid(s);
- return true;
+ }
}
/*!
diff --git a/src/corelib/serialization/qjson_p.h b/src/corelib/serialization/qjson_p.h
index 7743382806..dc56a49084 100644
--- a/src/corelib/serialization/qjson_p.h
+++ b/src/corelib/serialization/qjson_p.h
@@ -450,7 +450,7 @@ static inline void copyString(char *dest, const QString &str, bool compress)
/*
- Base is the base class for both Object and Array. Both classe work more or less the same way.
+ Base is the base class for both Object and Array. Both classes work more or less the same way.
The class starts with a header (defined by the struct below), then followed by data (the data for
values in the Array case and Entry's (see below) for objects.
diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp
index 9794bca60d..ab27b45fda 100644
--- a/src/corelib/serialization/qjsondocument.cpp
+++ b/src/corelib/serialization/qjsondocument.cpp
@@ -210,6 +210,9 @@ QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidat
return QJsonDocument();
}
+ if (size < (int)(sizeof(QJsonPrivate::Header) + sizeof(QJsonPrivate::Base)))
+ return QJsonDocument();
+
QJsonPrivate::Data *d = new QJsonPrivate::Data((char *)data, size);
d->ownsData = false;
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index d0f83d2b6a..7e1b43f9b1 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -65,7 +65,7 @@ struct QPodArrayOps
Q_ASSERT(newSize > uint(this->size));
Q_ASSERT(newSize <= this->alloc);
- ::memset(this->end(), 0, (newSize - this->size) * sizeof(T));
+ ::memset(static_cast<void *>(this->end()), 0, (newSize - this->size) * sizeof(T));
this->size = int(newSize);
}
@@ -121,8 +121,9 @@ struct QPodArrayOps
Q_ASSERT(e <= where || b > this->end()); // No overlap
Q_ASSERT(size_t(e - b) <= this->alloc - uint(this->size));
- ::memmove(where + (e - b), where, (static_cast<const T*>(this->end()) - where) * sizeof(T));
- ::memcpy(where, b, (e - b) * sizeof(T));
+ ::memmove(static_cast<void *>(where + (e - b)), static_cast<void *>(where),
+ (static_cast<const T*>(this->end()) - where) * sizeof(T));
+ ::memcpy(static_cast<void *>(where), static_cast<const void *>(b), (e - b) * sizeof(T));
this->size += (e - b);
}
@@ -133,7 +134,8 @@ struct QPodArrayOps
Q_ASSERT(b >= this->begin() && b < this->end());
Q_ASSERT(e > this->begin() && e < this->end());
- ::memmove(b, e, (static_cast<T *>(this->end()) - e) * sizeof(T));
+ ::memmove(static_cast<void *>(b), static_cast<void *>(e),
+ (static_cast<T *>(this->end()) - e) * sizeof(T));
this->size -= (e - b);
}
};
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 421e716d14..7c601e1336 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -238,7 +238,8 @@ qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t heade
Returns a duplicate string.
Allocates space for a copy of \a src, copies it, and returns a
- pointer to the copy. If \a src is 0, it immediately returns 0.
+ pointer to the copy. If \a src is nullptr, it immediately returns
+ nullptr.
Ownership is passed to the caller, so the returned string must be
deleted using \c delete[].
@@ -247,7 +248,7 @@ qCalculateGrowingBlockSize(size_t elementCount, size_t elementSize, size_t heade
char *qstrdup(const char *src)
{
if (!src)
- return 0;
+ return nullptr;
char *dst = new char[strlen(src) + 1];
return qstrcpy(dst, src);
}
@@ -255,26 +256,28 @@ char *qstrdup(const char *src)
/*! \relates QByteArray
Copies all the characters up to and including the '\\0' from \a
- src into \a dst and returns a pointer to \a dst. If \a src is 0,
- it immediately returns 0.
+ src into \a dst and returns a pointer to \a dst. If \a src is
+ nullptr, it immediately returns nullptr.
This function assumes that \a dst is large enough to hold the
contents of \a src.
+ \note If \a dst and \a src overlap, the behavior is undefined.
+
\sa qstrncpy()
*/
char *qstrcpy(char *dst, const char *src)
{
if (!src)
- return 0;
+ return nullptr;
#ifdef Q_CC_MSVC
const int len = int(strlen(src));
// This is actually not secure!!! It will be fixed
// properly in a later release!
if (len >= 0 && strcpy_s(dst, len+1, src) == 0)
return dst;
- return 0;
+ return nullptr;
#else
return strcpy(dst, src);
#endif
@@ -287,11 +290,13 @@ char *qstrcpy(char *dst, const char *src)
Copies at most \a len bytes from \a src (stopping at \a len or the
terminating '\\0' whichever comes first) into \a dst and returns a
pointer to \a dst. Guarantees that \a dst is '\\0'-terminated. If
- \a src or \a dst is 0, returns 0 immediately.
+ \a src or \a dst is nullptr, returns nullptr immediately.
This function assumes that \a dst is at least \a len characters
long.
+ \note If \a dst and \a src overlap, the behavior is undefined.
+
\note When compiling with Visual C++ compiler version 14.00
(Visual C++ 2005) or later, internally the function strncpy_s
will be used.
@@ -302,7 +307,7 @@ char *qstrcpy(char *dst, const char *src)
char *qstrncpy(char *dst, const char *src, uint len)
{
if (!src || !dst)
- return 0;
+ return nullptr;
if (len > 0) {
#ifdef Q_CC_MSVC
strncpy_s(dst, len, src, len - 1);
@@ -320,7 +325,7 @@ char *qstrncpy(char *dst, const char *src, uint len)
A safe \c strlen() function.
Returns the number of characters that precede the terminating '\\0',
- or 0 if \a str is 0.
+ or 0 if \a str is nullptr.
\sa qstrnlen()
*/
@@ -332,7 +337,7 @@ char *qstrncpy(char *dst, const char *src, uint len)
A safe \c strnlen() function.
Returns the number of characters that precede the terminating '\\0', but
- at most \a maxlen. If \a str is 0, returns 0.
+ at most \a maxlen. If \a str is nullptr, returns 0.
\sa qstrlen()
*/
@@ -346,10 +351,10 @@ char *qstrncpy(char *dst, const char *src, uint len)
is less than \a str2, 0 if \a str1 is equal to \a str2 or a
positive value if \a str1 is greater than \a str2.
- Special case 1: Returns 0 if \a str1 and \a str2 are both 0.
+ Special case 1: Returns 0 if \a str1 and \a str2 are both nullptr.
- Special case 2: Returns an arbitrary non-zero value if \a str1 is 0
- or \a str2 is 0 (but not both).
+ Special case 2: Returns an arbitrary non-zero value if \a str1 is
+ nullptr or \a str2 is nullptr (but not both).
\sa qstrncmp(), qstricmp(), qstrnicmp(), {8-bit Character Comparisons}
*/
@@ -371,10 +376,10 @@ int qstrcmp(const char *str1, const char *str2)
str1 is equal to \a str2 or a positive value if \a str1 is greater
than \a str2.
- Special case 1: Returns 0 if \a str1 and \a str2 are both 0.
+ Special case 1: Returns 0 if \a str1 and \a str2 are both nullptr.
- Special case 2: Returns a random non-zero value if \a str1 is 0
- or \a str2 is 0 (but not both).
+ Special case 2: Returns a random non-zero value if \a str1 is nullptr
+ or \a str2 is nullptr (but not both).
\sa qstrcmp(), qstricmp(), qstrnicmp(), {8-bit Character Comparisons}
*/
@@ -390,10 +395,10 @@ int qstrcmp(const char *str1, const char *str2)
str1 is equal to \a str2 or a positive value if \a str1 is greater
than \a str2.
- Special case 1: Returns 0 if \a str1 and \a str2 are both 0.
+ Special case 1: Returns 0 if \a str1 and \a str2 are both nullptr.
- Special case 2: Returns a random non-zero value if \a str1 is 0
- or \a str2 is 0 (but not both).
+ Special case 2: Returns a random non-zero value if \a str1 is nullptr
+ or \a str2 is nullptr (but not both).
\sa qstrcmp(), qstrncmp(), qstrnicmp(), {8-bit Character Comparisons}
*/
@@ -424,10 +429,10 @@ int qstricmp(const char *str1, const char *str2)
is equal to \a str2 or a positive value if \a str1 is greater than \a
str2.
- Special case 1: Returns 0 if \a str1 and \a str2 are both 0.
+ Special case 1: Returns 0 if \a str1 and \a str2 are both nullptr.
- Special case 2: Returns a random non-zero value if \a str1 is 0
- or \a str2 is 0 (but not both).
+ Special case 2: Returns a random non-zero value if \a str1 is nullptr
+ or \a str2 is nullptr (but not both).
\sa qstrcmp(), qstrncmp(), qstricmp(), {8-bit Character Comparisons}
*/
@@ -777,19 +782,6 @@ QByteArray qUncompress(const uchar* data, int nbytes)
}
#endif
-static inline bool qIsUpper(char c)
-{
- return c >= 'A' && c <= 'Z';
-}
-
-static inline char qToLower(char c)
-{
- if (c >= 'A' && c <= 'Z')
- return c - 'A' + 'a';
- else
- return c;
-}
-
/*!
\class QByteArray
\inmodule QtCore
@@ -4131,9 +4123,10 @@ QByteArray &QByteArray::setNum(double n, char f, int prec)
QLocaleData::DoubleForm form = QLocaleData::DFDecimal;
uint flags = QLocaleData::ZeroPadExponent;
- if (qIsUpper(f))
+ char lower = latin1_lowercased[uchar(f)];
+ if (f != lower)
flags |= QLocaleData::CapitalEorX;
- f = qToLower(f);
+ f = lower;
switch (f) {
case 'f':
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index 551e01e076..d03518e70d 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -44,7 +44,9 @@
#include "qset.h"
#include "qlocale.h"
#include "qdatetime.h"
+#if QT_CONFIG(timezone)
#include "qtimezone.h"
+#endif
#include "qregexp.h"
#include "qdebug.h"
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index 33835e3d28..17aba8035b 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -408,15 +408,20 @@ void **QListData::erase(void **xi)
from strings.
QList stores a list of items. The default constructor creates an
- empty list. To insert items into the list, you can use
- operator<<():
+ empty list. You can use the initializer-list constructor to create
+ a list with elements:
- \snippet code/src_corelib_tools_qlistdata.cpp 1
+ \snippet code/src_corelib_tools_qlistdata.cpp 1a
QList provides these basic functions to add, move, and remove
items: insert(), replace(), removeAt(), move(), and swap(). In
addition, it provides the following convenience functions:
- append(), prepend(), removeFirst(), and removeLast().
+ append(), \l{operator<<()}, \l{operator+=()}, prepend(), removeFirst(),
+ and removeLast().
+
+ \l{operator<<()} allows to conveniently add multiple elements to a list:
+
+ \snippet code/src_corelib_tools_qlistdata.cpp 1b
QList uses 0-based indexes, just like C++ arrays. To access the
item at a particular index position, you can use operator[](). On
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index a0e408b94a..bccf8c5740 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -246,7 +246,8 @@ namespace QtSharedPointer {
struct ExternalRefCountWithContiguousData: public ExternalRefCountData
{
typedef ExternalRefCountData Parent;
- T data;
+ typedef typename std::remove_cv<T>::type NoCVType;
+ NoCVType data;
static void deleter(ExternalRefCountData *self)
{
@@ -262,7 +263,7 @@ namespace QtSharedPointer {
}
static void noDeleter(ExternalRefCountData *) { }
- static inline ExternalRefCountData *create(T **ptr, DestroyerFn destroy)
+ static inline ExternalRefCountData *create(NoCVType **ptr, DestroyerFn destroy)
{
ExternalRefCountWithContiguousData *d =
static_cast<ExternalRefCountWithContiguousData *>(::operator new(sizeof(ExternalRefCountWithContiguousData)));
@@ -437,10 +438,12 @@ public:
# endif
typename Private::DestroyerFn noDestroy = &Private::noDeleter;
QSharedPointer result(Qt::Uninitialized);
- result.d = Private::create(&result.value, noDestroy);
+ typename std::remove_cv<T>::type *ptr;
+ result.d = Private::create(&ptr, noDestroy);
// now initialize the data
- new (result.data()) T(std::forward<Args>(arguments)...);
+ new (ptr) T(std::forward<Args>(arguments)...);
+ result.value = ptr;
result.d->destroyer = destroy;
result.d->setQObjectShared(result.value, true);
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index eb56b31348..18684caefb 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -219,9 +219,8 @@
// AVX intrinsics
# if defined(__AVX__) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS) && (defined(Q_CC_INTEL) || defined(Q_CC_MSVC))
// AES, PCLMULQDQ instructions:
-// All processors that support AVX support AES, PCLMULQDQ
-// (but neither MSVC nor the Intel compiler define these macros)
-# define __AES__ 1
+// All processors that support AVX support PCLMULQDQ
+// (but neither MSVC nor the Intel compiler define this macro)
# define __PCLMUL__ 1
# endif
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index f6360f5504..bcc94e260a 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -259,7 +259,7 @@ static bool simdTestMask(const char *&ptr, const char *end, quint32 maskval)
# if defined(__AVX2__)
// AVX2 implementation: test 32 bytes at a time
const __m256i mask256 = _mm256_broadcastd_epi32(_mm_cvtsi32_si128(maskval));
- while (ptr + 32 < end) {
+ while (ptr + 32 <= end) {
__m256i data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(ptr));
if (!_mm256_testz_si256(mask256, data))
return false;
@@ -271,7 +271,7 @@ static bool simdTestMask(const char *&ptr, const char *end, quint32 maskval)
// SSE 4.1 implementation: test 32 bytes at a time (two 16-byte
// comparisons, unrolled)
const __m128i mask = _mm_set1_epi32(maskval);
- while (ptr + 32 < end) {
+ while (ptr + 32 <= end) {
__m128i data1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr));
__m128i data2 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr + 16));
if (!_mm_testz_si128(mask, data1))
@@ -283,7 +283,7 @@ static bool simdTestMask(const char *&ptr, const char *end, quint32 maskval)
# endif
# if defined(__SSE4_1__)
// AVX2 and SSE4.1: final 16-byte comparison
- if (ptr + 16 < end) {
+ if (ptr + 16 <= end) {
__m128i data1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr));
if (!_mm_testz_si128(mask, data1))
return false;
@@ -325,7 +325,7 @@ bool QtPrivate::isAscii(QLatin1String s) Q_DECL_NOTHROW
}
#endif
- while (ptr + 4 < end) {
+ while (ptr + 4 <= end) {
quint32 data = qFromUnaligned<quint32>(ptr);
if (data & 0x80808080U)
return false;
@@ -646,30 +646,70 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
}
#endif // __mips_dsp
#ifdef __SSE2__
- const char *ptr = reinterpret_cast<const char*>(a);
- qptrdiff distance = reinterpret_cast<const char*>(b) - ptr;
- a += l & ~7;
- b += l & ~7;
- l &= 7;
-
- // we're going to read ptr[0..15] (16 bytes)
- for ( ; ptr + 15 < reinterpret_cast<const char *>(a); ptr += 16) {
- __m128i a_data = _mm_loadu_si128((const __m128i*)ptr);
- __m128i b_data = _mm_loadu_si128((const __m128i*)(ptr + distance));
+ const QChar *end = a + l;
+ qptrdiff offset = 0;
+
+ // we're going to read a[0..15] and b[0..15] (32 bytes)
+ for ( ; a + offset + 16 <= end; offset += 16) {
+#ifdef __AVX2__
+ __m256i a_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(a + offset));
+ __m256i b_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(b + offset));
+ __m256i result = _mm256_cmpeq_epi16(a_data, b_data);
+ uint mask = _mm256_movemask_epi8(result);
+#else
+ __m128i a_data1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset));
+ __m128i a_data2 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset + 8));
+ __m128i b_data1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset));
+ __m128i b_data2 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset + 8));
+ __m128i result1 = _mm_cmpeq_epi16(a_data1, b_data1);
+ __m128i result2 = _mm_cmpeq_epi16(a_data2, b_data2);
+ uint mask = _mm_movemask_epi8(result1) | (_mm_movemask_epi8(result2) << 16);
+#endif
+ mask = ~mask;
+ if (mask) {
+ // found a different character
+ uint idx = qCountTrailingZeroBits(mask);
+ return a[offset + idx / 2].unicode() - b[offset + idx / 2].unicode();
+ }
+ }
+
+ // we're going to read a[0..7] and b[0..7] (16 bytes)
+ if (a + offset + 8 <= end) {
+ __m128i a_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset));
+ __m128i b_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset));
__m128i result = _mm_cmpeq_epi16(a_data, b_data);
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
- // found a different byte
+ // found a different character
+ uint idx = qCountTrailingZeroBits(mask);
+ return a[offset + idx / 2].unicode() - b[offset + idx / 2].unicode();
+ }
+
+ offset += 8;
+ }
+
+ // we're going to read a[0..3] and b[0..3] (8 bytes)
+ if (a + offset + 4 <= end) {
+ __m128i a_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(a + offset));
+ __m128i b_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(b + offset));
+ __m128i result = _mm_cmpeq_epi16(a_data, b_data);
+ uint mask = ~_mm_movemask_epi8(result);
+ if (uchar(mask)) {
+ // found a different character
uint idx = qCountTrailingZeroBits(mask);
- return reinterpret_cast<const QChar *>(ptr + idx)->unicode()
- - reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode();
+ return a[offset + idx / 2].unicode() - b[offset + idx / 2].unicode();
}
+
+ offset += 4;
}
+
+ // reset l
+ l &= 3;
+
const auto lambda = [=](size_t i) -> int {
- return reinterpret_cast<const QChar *>(ptr)[i].unicode()
- - reinterpret_cast<const QChar *>(ptr + distance)[i].unicode();
+ return a[offset + i].unicode() - b[offset + i].unicode();
};
- return UnrollTailLoop<7>::exec(l, 0, lambda, lambda);
+ return UnrollTailLoop<3>::exec(l, 0, lambda, lambda);
#endif
#if defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64) // vaddv is only available on Aarch64
if (l >= 8) {
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp
index d10d9ad9d0..c9db39a29f 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/tools/qstringlist.cpp
@@ -98,14 +98,25 @@ QT_BEGIN_NAMESPACE
\tableofcontents
+ \section1 Initializing
+
+ The default constructor creates an empty list. You can use the
+ initializer-list constructor to create a list with elements:
+
+ \snippet qstringlist/main.cpp 0a
+
\section1 Adding Strings
Strings can be added to a list using the \l
+ {QList::insert()}{insert()} \l
{QList::append()}{append()}, \l
{QList::operator+=()}{operator+=()} and \l
- {QStringList::operator<<()}{operator<<()} functions. For example:
+ {operator<<()} functions.
+
+ \l{operator<<()} can be used to
+ conveniently add multiple elements to a list:
- \snippet qstringlist/main.cpp 0
+ \snippet qstringlist/main.cpp 0b
\section1 Iterating Over the Strings
diff --git a/src/dbus/qdbusmisc.cpp b/src/dbus/qdbusmisc.cpp
index 930c3bd2da..eb8f61c783 100644
--- a/src/dbus/qdbusmisc.cpp
+++ b/src/dbus/qdbusmisc.cpp
@@ -181,6 +181,13 @@ int qDBusParametersForMethod(const QList<QByteArray> &parameterTypes, QVector<in
}
int id = QMetaType::type(type);
+#ifdef QT_BOOTSTRAPPED
+ // in bootstrap mode QDBusMessage isn't included, thus we need to resolve it manually here
+ if (type == "QDBusMessage") {
+ id = QDBusMetaTypeId::message();
+ }
+#endif
+
if (id == QMetaType::UnknownType) {
errorMsg = QLatin1String("Unregistered input type in parameter list: ") + QLatin1String(type);
return -1;
diff --git a/src/gui/kernel/qinputdevicemanager.cpp b/src/gui/kernel/qinputdevicemanager.cpp
index 37b1450d5a..6e4e5a9c93 100644
--- a/src/gui/kernel/qinputdevicemanager.cpp
+++ b/src/gui/kernel/qinputdevicemanager.cpp
@@ -109,30 +109,9 @@ Qt::KeyboardModifiers QInputDeviceManager::keyboardModifiers() const
return d->keyboardModifiers;
}
-void QInputDeviceManager::setKeyboardModifiers(Qt::KeyboardModifiers modsBeforeEvent, int key)
+void QInputDeviceManager::setKeyboardModifiers(Qt::KeyboardModifiers mods)
{
Q_D(QInputDeviceManager);
- Qt::KeyboardModifiers mods;
- switch (key) {
- case Qt::Key_Shift:
- mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::ShiftModifier);
- break;
- case Qt::Key_Control:
- mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::ControlModifier);
- break;
- case Qt::Key_Alt:
- mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::AltModifier);
- break;
- case Qt::Key_Meta:
- mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::MetaModifier);
- break;
- case Qt::Key_AltGr:
- mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::GroupSwitchModifier);
- break;
- default:
- mods = modsBeforeEvent;
- break;
- }
d->keyboardModifiers = mods;
}
diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h
index ddf1e6befa..d73c5526d0 100644
--- a/src/gui/kernel/qinputdevicemanager_p.h
+++ b/src/gui/kernel/qinputdevicemanager_p.h
@@ -79,7 +79,7 @@ public:
void setCursorPos(const QPoint &pos);
Qt::KeyboardModifiers keyboardModifiers() const;
- void setKeyboardModifiers(Qt::KeyboardModifiers modsBeforeEvent, int key);
+ void setKeyboardModifiers(Qt::KeyboardModifiers mods);
signals:
void deviceListChanged(QInputDeviceManager::DeviceType type);
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index 6c19eab287..fa1eb6f6bf 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -648,10 +648,16 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e)
// Find next
const QShortcutEntry *current = 0, *next = 0;
int i = 0, enabledShortcuts = 0;
+#if defined(DEBUG_QSHORTCUTMAP)
+ QVector<const QShortcutEntry*> ambiguousShortcuts;
+#endif
while(i < d->identicals.size()) {
current = d->identicals.at(i);
if (current->enabled || !next){
++enabledShortcuts;
+#if defined(DEBUG_QSHORTCUTMAP)
+ ambiguousShortcuts.append(current);
+#endif
if (enabledShortcuts > d->ambigCount + 1)
break;
next = current;
@@ -665,6 +671,13 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e)
return;
// Dispatch next enabled
#if defined(DEBUG_QSHORTCUTMAP)
+ if (ambiguousShortcuts.size() > 1) {
+ qDebug() << "The following shortcuts are about to be activated ambiguously:";
+ for (const QShortcutEntry *entry : qAsConst(ambiguousShortcuts)) {
+ qDebug().nospace() << "- " << entry->keyseq << " (belonging to " << entry->owner << ")";
+ }
+ }
+
qDebug().nospace()
<< "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\""
<< next->keyseq.toString() << "\", " << next->id << ", "
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 5243ae66a2..c310ab5213 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -258,11 +258,12 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt:
QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
}
-void QWindowSystemInterface::handleWindowScreenChanged(QWindow *window, QScreen *screen)
+QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowScreenChanged, QWindow *window, QScreen *screen)
{
+
QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e =
new QWindowSystemInterfacePrivate::WindowScreenChangedEvent(window, screen);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
}
QT_DEFINE_QPA_EVENT_HANDLER(void, handleSafeAreaMarginsChanged, QWindow *window)
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index b22495f9d0..a7cc30be4b 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -205,6 +205,7 @@ public:
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState = -1);
+ template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen);
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index b94fd34b51..6f3c92ca64 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -520,7 +520,12 @@ public:
const typename Simd::Float32x4 v_r0 = Simd::v_dup(data->gradient.radial.focal.radius);
const typename Simd::Float32x4 v_dr = Simd::v_dup(op->radial.dr);
+#if defined(__ARM_NEON__)
+ // NEON doesn't have SIMD sqrt, but uses rsqrt instead that can't be taken of 0.
+ const typename Simd::Float32x4 v_min = Simd::v_dup(std::numeric_limits<float>::epsilon());
+#else
const typename Simd::Float32x4 v_min = Simd::v_dup(0.0f);
+#endif
const typename Simd::Float32x4 v_max = Simd::v_dup(float(GRADIENT_STOPTABLE_SIZE-1));
const typename Simd::Float32x4 v_half = Simd::v_dup(0.5f);
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 9877a23fa6..2957b8d5c0 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -2494,7 +2494,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout
QTextTableData *td = static_cast<QTextTableData *>(data(lastIt.currentFrame()));
QTextLayout *layout = block.layout();
- QFixed height = QFixed::fromReal(layout->lineAt(0).height());
+ QFixed height = layout->lineCount() > 0 ? QFixed::fromReal(layout->lineAt(0).height()) : QFixed();
if (layoutStruct->pageBottom == origPageBottom) {
layoutStruct->y -= height;
@@ -2506,10 +2506,12 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout
layoutBlock(block, docPos, blockFormat, layoutStruct, layoutFrom, layoutTo, previousBlockFormatPtr);
}
- QPointF linePos((td->position.x + td->size.width).toReal(),
- (td->position.y + td->size.height - height).toReal());
+ if (layout->lineCount() > 0) {
+ QPointF linePos((td->position.x + td->size.width).toReal(),
+ (td->position.y + td->size.height - height).toReal());
- layout->lineAt(0).setPosition(linePos - layout->position());
+ layout->lineAt(0).setPosition(linePos - layout->position());
+ }
}
if (blockFormat.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysAfter)
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 07644b869f..35e79a69f2 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -178,7 +178,9 @@ static void ensureInitialized()
it sends. It contains the proxy and cache configuration, as well as the
signals related to such issues, and reply signals that can be used to
monitor the progress of a network operation. One QNetworkAccessManager
- should be enough for the whole Qt application.
+ instance should be enough for the whole Qt application. Since
+ QNetworkAccessManager is based on QObject, it can only be used from the
+ thread it belongs to.
Once a QNetworkAccessManager object has been created, the application can
use it to send requests over the network. A group of standard functions
diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp
index f62a03b11d..2ec4acf26c 100644
--- a/src/network/access/qnetworkcookiejar.cpp
+++ b/src/network/access/qnetworkcookiejar.cpp
@@ -241,6 +241,17 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const
if ((*it).isSecure() && !isEncrypted)
continue;
+ QString domain = it->domain();
+ if (domain.startsWith(QLatin1Char('.'))) /// Qt6?: remove when compliant with RFC6265
+ domain = domain.mid(1);
+#if QT_CONFIG(topleveldomain)
+ if (qIsEffectiveTLD(domain) && url.host() != domain)
+ continue;
+#else
+ if (!domain.contains(QLatin1Char('.')) && url.host() != domain)
+ continue;
+#endif // topleveldomain
+
// insert this cookie into result, sorted by path
QList<QNetworkCookie>::Iterator insertIt = result.begin();
while (insertIt != result.end()) {
@@ -340,6 +351,11 @@ bool QNetworkCookieJar::validateCookie(const QNetworkCookie &cookie, const QUrl
if (domain.startsWith(QLatin1Char('.')))
domain = domain.mid(1);
+ // We shouldn't reject if:
+ // "[...] the domain-attribute is identical to the canonicalized request-host"
+ // https://tools.ietf.org/html/rfc6265#section-5.3 step 5
+ if (host == domain)
+ return true;
#if QT_CONFIG(topleveldomain)
// the check for effective TLDs makes the "embedded dot" rule from RFC 2109 section 4.3.2
// redundant; the "leading dot" rule has been relaxed anyway, see QNetworkCookie::normalize()
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index 1d7c5bec51..9ce2128ead 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -889,6 +889,8 @@ static int parseHeaderName(const QByteArray &headerName)
return QNetworkRequest::ContentLengthHeader;
else if (qstricmp(headerName.constData(), "cookie") == 0)
return QNetworkRequest::CookieHeader;
+ else if (qstricmp(headerName.constData(), "content-disposition") == 0)
+ return QNetworkRequest::ContentDispositionHeader;
break;
case 'l':
@@ -944,6 +946,7 @@ static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QBy
case QNetworkRequest::UserAgentHeader:
case QNetworkRequest::ServerHeader:
case QNetworkRequest::ContentTypeHeader:
+ case QNetworkRequest::ContentDispositionHeader:
// copy exactly, convert to QString
return QString::fromLatin1(value);
diff --git a/src/network/kernel/qnetworkinterface_linux.cpp b/src/network/kernel/qnetworkinterface_linux.cpp
index 23ed2e0e15..b3b5e242b4 100644
--- a/src/network/kernel/qnetworkinterface_linux.cpp
+++ b/src/network/kernel/qnetworkinterface_linux.cpp
@@ -169,7 +169,7 @@ template <typename Lambda> struct ProcessNetlinkRequest
forever {
qsizetype len = recv(sock, buf, bufsize, 0);
hdr = reinterpret_cast<struct nlmsghdr *>(buf);
- if (!NLMSG_OK(hdr, len))
+ if (!NLMSG_OK(hdr, quint32(len)))
return;
auto arg = reinterpret_cast<FirstArgument>(NLMSG_DATA(hdr));
@@ -194,7 +194,7 @@ template <typename Lambda> struct ProcessNetlinkRequest
hdr = NLMSG_NEXT(hdr, len);
arg = reinterpret_cast<FirstArgument>(NLMSG_DATA(hdr));
payloadLen = NLMSG_PAYLOAD(hdr, 0);
- } while (NLMSG_OK(hdr, len));
+ } while (NLMSG_OK(hdr, quint32(len)));
if (len == 0)
continue; // get new datagram
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 1fc7817fe8..cecb4fb753 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -1517,7 +1517,7 @@ bool QSslSocketBackendPrivate::importPkcs12(QIODevice *device,
if (!key->d->fromEVP_PKEY(pkey)) {
qCWarning(lcSsl, "Unable to convert private key");
q_OPENSSL_sk_pop_free(reinterpret_cast<OPENSSL_STACK *>(ca),
- reinterpret_cast<void (*)(void *)>(q_OPENSSL_sk_free));
+ reinterpret_cast<void (*)(void *)>(q_X509_free));
q_X509_free(x509);
q_EVP_PKEY_free(pkey);
q_PKCS12_free(p12);
@@ -1532,8 +1532,6 @@ bool QSslSocketBackendPrivate::importPkcs12(QIODevice *device,
*caCertificates = QSslSocketBackendPrivate::STACKOFX509_to_QSslCertificates(ca);
// Clean up
- // TODO: verify ASAP, in the past we had sk_pop_free with q_OPENSSL_sk_free
- // which seems to be blatantly wrong and even crashes with 1.1.
q_OPENSSL_sk_pop_free(reinterpret_cast<OPENSSL_STACK *>(ca),
reinterpret_cast<void (*)(void *)>(q_X509_free));
diff --git a/src/network/ssl/qsslsocket_winrt.cpp b/src/network/ssl/qsslsocket_winrt.cpp
index 53a8a8b61b..e72edcbc52 100644
--- a/src/network/ssl/qsslsocket_winrt.cpp
+++ b/src/network/ssl/qsslsocket_winrt.cpp
@@ -647,6 +647,10 @@ HRESULT QSslSocketBackendPrivate::onSslUpgrade(IAsyncAction *action, AsyncStatus
connectionEncrypted = true;
emit q->encrypted();
+ // The write buffer may already have data written to it, so we need to call transmit.
+ // This has to be done in 'q's thread, and not in the current thread (the XAML thread).
+ QMetaObject::invokeMethod(q, [this](){ transmit(); });
+
if (pendingClose) {
pendingClose = false;
q->disconnectFromHost();
diff --git a/src/platformheaders/eglfsfunctions/qeglfsfunctions.qdoc b/src/platformheaders/eglfsfunctions/qeglfsfunctions.qdoc
index fc392ac369..0bee9190cf 100644
--- a/src/platformheaders/eglfsfunctions/qeglfsfunctions.qdoc
+++ b/src/platformheaders/eglfsfunctions/qeglfsfunctions.qdoc
@@ -91,6 +91,12 @@
*/
/*!
+ \fn bool QEglFSFunctions::vsp2SetLayerAlpha(const QScreen *screen, int id, qreal alpha)
+ \internal
+ \preliminary
+*/
+
+/*!
\fn void QEglFSFunctions::vsp2AddBlendListener(const QScreen *screen, void(*callback)())
\internal
\preliminary
@@ -121,6 +127,11 @@
\internal
*/
+/*!
+ \typedef QEglFSFunctions::Vsp2SetLayerAlphaType
+ \internal
+*/
+
/*! \fn QByteArray QEglFSFunctions::vsp2AddBlendListenerTypeIdentifier()
\internal
*/
@@ -140,3 +151,7 @@
/*! \fn QByteArray QEglFSFunctions::vsp2SetLayerPositionTypeIdentifier()
\internal
*/
+
+/*! \fn QByteArray QEglFSFunctions::vsp2SetLayerAlphaTypeIdentifier()
+ \internal
+ */
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index f31f58945b..91c2dc8cf0 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -451,16 +451,15 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory<QFontEngineFT>::fontEngine(const
{
CTFontDescriptorRef descriptor = static_cast<CTFontDescriptorRef>(usrPtr);
- if (NSURL *url = descriptorAttribute<NSURL>(descriptor, kCTFontURLAttribute)) {
+ if (NSValue *fontDataValue = descriptorAttribute<NSValue>(descriptor, (CFStringRef)kQtFontDataAttribute)) {
+ QByteArray *fontData = static_cast<QByteArray *>(fontDataValue.pointerValue);
+ return QFontEngineFT::create(*fontData, fontDef.pixelSize,
+ static_cast<QFont::HintingPreference>(fontDef.hintingPreference));
+ } else if (NSURL *url = descriptorAttribute<NSURL>(descriptor, kCTFontURLAttribute)) {
Q_ASSERT(url.fileURL);
QFontEngine::FaceId faceId;
faceId.filename = QString::fromNSString(url.path).toUtf8();
return QFontEngineFT::create(fontDef, faceId);
-
- } else if (NSValue *fontDataValue = descriptorAttribute<NSValue>(descriptor, (CFStringRef)kQtFontDataAttribute)) {
- QByteArray *fontData = static_cast<QByteArray *>(fontDataValue.pointerValue);
- return QFontEngineFT::create(*fontData, fontDef.pixelSize,
- static_cast<QFont::HintingPreference>(fontDef.hintingPreference));
}
Q_UNREACHABLE();
}
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
index 47a65eded8..b21d5d9ef5 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
@@ -225,7 +225,8 @@ void QEvdevKeyboardHandler::readKeycode()
void QEvdevKeyboardHandler::processKeyEvent(int nativecode, int unicode, int qtcode,
Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat)
{
- QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(modifiers, qtcode);
+ if (!autoRepeat)
+ QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(QEvdevKeyboardHandler::toQtModifiers(m_modifiers));
QWindowSystemInterface::handleExtendedKeyEvent(0, (isPress ? QEvent::KeyPress : QEvent::KeyRelease),
qtcode, modifiers, nativecode + 8, 0, int(modifiers),
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
index 5264736dd6..ae81bca00f 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
@@ -148,14 +148,13 @@ void QEvdevMouseManager::handleMouseEvent(int x, int y, bool abs, Qt::MouseButto
QPoint pos(m_x + m_xoffset, m_y + m_yoffset);
// Cannot track the keyboard modifiers ourselves here. Instead, report the
// modifiers from the last key event that has been seen by QGuiApplication.
- Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers();
- QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, button, type, mods);
+ QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, button, type, QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers());
}
void QEvdevMouseManager::handleWheelEvent(QPoint delta)
{
QPoint pos(m_x + m_xoffset, m_y + m_yoffset);
- QWindowSystemInterface::handleWheelEvent(0, pos, pos, QPoint(), delta, QGuiApplication::keyboardModifiers());
+ QWindowSystemInterface::handleWheelEvent(0, pos, pos, QPoint(), delta, QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers());
}
void QEvdevMouseManager::addMouse(const QString &deviceNode)
diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
index ec01f95947..5152725468 100644
--- a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
+++ b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
@@ -135,7 +135,8 @@ QLibInputKeyboard::QLibInputKeyboard()
#ifndef QT_NO_XKBCOMMON_EVDEV
: m_ctx(0),
m_keymap(0),
- m_state(0)
+ m_state(0),
+ m_mods(Qt::NoModifier)
#endif
{
#ifndef QT_NO_XKBCOMMON_EVDEV
@@ -203,22 +204,27 @@ void QLibInputKeyboard::processKey(libinput_event_keyboard *e)
Qt::KeyboardModifiers mods = Qt::NoModifier;
const int qtkey = keysymToQtKey(sym, &mods, text);
- xkb_state_component modtype = xkb_state_component(XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED);
- if (xkb_state_mod_index_is_active(m_state, m_modindex[0], modtype) && (qtkey != Qt::Key_Control || !pressed))
+ if (qtkey == Qt::Key_Control)
mods |= Qt::ControlModifier;
- if (xkb_state_mod_index_is_active(m_state, m_modindex[1], modtype) && (qtkey != Qt::Key_Alt || !pressed))
+ if (qtkey == Qt::Key_Alt)
mods |= Qt::AltModifier;
- if (xkb_state_mod_index_is_active(m_state, m_modindex[2], modtype) && (qtkey != Qt::Key_Shift || !pressed))
+ if (qtkey == Qt::Key_Shift)
mods |= Qt::ShiftModifier;
- if (xkb_state_mod_index_is_active(m_state, m_modindex[3], modtype) && (qtkey != Qt::Key_Meta || !pressed))
+ if (qtkey == Qt::Key_Meta)
mods |= Qt::MetaModifier;
-
xkb_state_update_key(m_state, k, pressed ? XKB_KEY_DOWN : XKB_KEY_UP);
- QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(mods, qtkey);
+ if (mods != Qt::NoModifier) {
+ if (pressed)
+ m_mods |= mods;
+ else
+ m_mods &= ~mods;
+
+ QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(m_mods);
+ }
QWindowSystemInterface::handleExtendedKeyEvent(nullptr,
pressed ? QEvent::KeyPress : QEvent::KeyRelease,
- qtkey, mods, k, sym, mods, text);
+ qtkey, m_mods, k, sym, m_mods, text);
if (pressed && xkb_keymap_key_repeats(m_keymap, k)) {
m_repeatData.qtkey = qtkey;
diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h
index b7ee8a363f..9e09bccd79 100644
--- a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h
+++ b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h
@@ -93,6 +93,7 @@ private:
QString unicodeText;
int repeatCount;
} m_repeatData;
+ Qt::KeyboardModifiers m_mods;
#endif
};
diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp
index cb08ab53b2..c54b61fc66 100644
--- a/src/platformsupport/input/libinput/qlibinputpointer.cpp
+++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp
@@ -125,7 +125,7 @@ void QLibInputPointer::processAxis(libinput_event_pointer *e)
#endif
const int factor = 8;
angleDelta *= -factor;
- Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers();
+ Qt::KeyboardModifiers mods = QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers();
QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, QPoint(), angleDelta, mods);
}
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index c021128e4c..8c98dc69f7 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -314,6 +314,7 @@ NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap pixmap, const QPoin
if (pixmap.devicePixelRatio() > 1.0) {
QSize layoutSize = pixmap.size() / pixmap.devicePixelRatio();
QPixmap scaledPixmap = pixmap.scaled(layoutSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ scaledPixmap.setDevicePixelRatio(1.0);
nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(scaledPixmap));
CGImageRef cgImage = qt_mac_toCGImage(pixmap.toImage());
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 9a96895d07..815882ab06 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -73,8 +73,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
return newFont;
}
-@class QT_MANGLE_NAMESPACE(QNSFontPanelDelegate);
-
@interface QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) : NSObject<NSWindowDelegate, QNSPanelDelegate>
{
@public
@@ -110,7 +108,8 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
[mFontPanel setRestorable:NO];
[mFontPanel setDelegate:self];
- [[NSFontManager sharedFontManager] setDelegate:self];
+
+ [NSFontManager sharedFontManager].target = self; // Action is changeFont:
[mFontPanel retain];
return self;
@@ -120,7 +119,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
{
[mStolenContentView release];
[mFontPanel setDelegate:nil];
- [[NSFontManager sharedFontManager] setDelegate:nil];
+ [NSFontManager sharedFontManager].target = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index b729c7f4c0..e5954f277c 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -265,6 +265,16 @@ QRectF qt_mac_flip(const QRectF &rect, const QRectF &reference)
// -------------------------------------------------------------------------
+/*!
+ \fn Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
+
+ Returns the Qt::Button that corresponds to an NSEvent.buttonNumber.
+
+ \note AppKit will use buttonNumber 0 to indicate both "left button"
+ and "no button". Only NSEvents that describes mouse press/release
+ events (e.g NSEventTypeOtherMouseDown) will contain a valid
+ button number.
+*/
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
{
if (buttonNum >= 0 && buttonNum <= 31)
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 54254455e4..1e311ed388 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -404,8 +404,10 @@ void QCocoaWindow::setVisible(bool visible)
removeMonitor();
monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask|NSOtherMouseDownMask|NSMouseMovedMask handler:^(NSEvent *e) {
QPointF localPoint = QCocoaScreen::mapFromNative([NSEvent mouseLocation]);
+ const auto button = e.type == NSEventTypeMouseMoved ? Qt::NoButton : cocoaButton2QtButton([e buttonNumber]);
+ const auto eventType = e.type == NSEventTypeMouseMoved ? QEvent::MouseMove : QEvent::MouseButtonPress;
QWindowSystemInterface::handleMouseEvent(window(), window()->mapFromGlobal(localPoint.toPoint()), localPoint,
- cocoaButton2QtButton([e buttonNumber]));
+ Qt::MouseButtons(uint(NSEvent.pressedMouseButtons & 0xFFFF)), button, eventType);
}];
}
}
@@ -1334,7 +1336,7 @@ void QCocoaWindow::recreateWindowIfNeeded()
void QCocoaWindow::requestUpdate()
{
qCDebug(lcQpaCocoaDrawing) << "QCocoaWindow::requestUpdate" << window();
- [qnsview_cast(m_view) requestUpdate];
+ QPlatformWindow::requestUpdate();
}
void QCocoaWindow::requestActivateWindow()
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index a88cd5feda..c88ffc76d7 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -358,7 +358,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
m_platformWindow->handleExposeEvent(dirtyRegion);
}
- if (windowPrivate->updateRequestPending) {
+ if (m_updateRequested && windowPrivate->updateRequestPending) {
// A call to QWindow::requestUpdate was issued during event delivery above,
// but AppKit will reset the needsDisplay state of the view after completing
// the current display cycle, so we need to defer the request to redisplay.
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index b3d48c1ec3..eade407500 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -574,6 +574,11 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
d->setPageSize(QPageSize(QPageSize::id(value.toInt())));
break;
case PPK_PrinterName: {
+ QVariant pageSize = QVariant::fromValue(d->m_pageLayout.pageSize());
+ const bool isFullPage = d->m_pageLayout.mode() == QPageLayout::FullPageMode;
+ QVariant orientation = QVariant::fromValue(d->m_pageLayout.orientation());
+ QVariant margins = QVariant::fromValue(QPair<QMarginsF, QPageLayout::Unit>(d->m_pageLayout.margins(),
+ d->m_pageLayout.units()));
QString id = value.toString();
if (id.isEmpty())
id = QCocoaPrinterSupport().defaultPrintDeviceId();
@@ -583,7 +588,14 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
PMPrinter printer = d->m_printDevice->macPrinter();
PMRetain(printer);
PMSessionSetCurrentPMPrinter(d->session(), printer);
- // TODO Do we need to check if the page size, etc, are valid on new printer?
+ // Ensure the settings are up to date and valid
+ if (d->m_printDevice->supportedPageSize(pageSize.value<QPageSize>()).isValid())
+ setProperty(PPK_QPageSize, pageSize);
+ else
+ setProperty(PPK_CustomPaperSize, pageSize.value<QPageSize>().size(QPageSize::Point));
+ setProperty(PPK_FullPage, QVariant(isFullPage));
+ setProperty(PPK_Orientation, orientation);
+ setProperty(PPK_QPageMargins, margins);
break;
}
case PPK_CustomPaperSize:
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp
index 98cf1d3bfb..212ebde05a 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp
@@ -52,12 +52,28 @@ QT_BEGIN_NAMESPACE
void QEglFSRcarIntegration::platformInit()
{
+ bool ok;
+
QEglFSDeviceIntegration::platformInit();
PVRGrfxServerInit();
mScreenSize = q_screenSizeFromFb(0);
mNativeDisplay = (NativeDisplayType)EGL_DEFAULT_DISPLAY;
+
+ mNativeDisplayID = qEnvironmentVariableIntValue("QT_QPA_WM_DISP_ID", &ok);
+ if (!ok)
+ mNativeDisplayID = RCAR_DEFAULT_DISPLAY;
+
+ r_wm_Error_t wm_err = R_WM_DevInit(mNativeDisplayID);
+ if (wm_err != R_WM_ERR_OK)
+ qFatal("Failed to init WM Dev: %d, error: %d", mNativeDisplayID, wm_err);
+ wm_err = R_WM_ScreenBgColorSet(mNativeDisplayID, 0x20, 0x20, 0x20); // Grey
+ if (wm_err != R_WM_ERR_OK)
+ qFatal("Failed to set screen background: %d", wm_err);
+ wm_err = R_WM_ScreenEnable(mNativeDisplayID);
+ if (wm_err != R_WM_ERR_OK)
+ qFatal("Failed to enable screen: %d", wm_err);
}
QSize QEglFSRcarIntegration::screenSize() const
@@ -104,14 +120,6 @@ EGLNativeWindowType QEglFSRcarIntegration::createNativeWindow(QPlatformWindow *w
{
bool ok;
- mNativeDisplayID = qEnvironmentVariableIntValue("QT_QPA_WM_DISP_ID", &ok);
- if (!ok)
- mNativeDisplayID = RCAR_DEFAULT_DISPLAY;
-
- r_wm_Error_t wm_err = R_WM_DevInit(mNativeDisplayID);
- if (wm_err != R_WM_ERR_OK)
- qFatal("Failed to init WM Dev: %d, error: %d", mNativeDisplayID, wm_err);
-
mNativeWindow = (EGLNativeWindowTypeREL*)malloc(sizeof(EGLNativeWindowTypeREL));
memset(mNativeWindow, 0, sizeof(EGLNativeWindowTypeREL));
@@ -134,7 +142,7 @@ EGLNativeWindowType QEglFSRcarIntegration::createNativeWindow(QPlatformWindow *w
mNativeWindow->Surface.Type = R_WM_SURFACE_FB;
mNativeWindow->Surface.BufMode = R_WM_WINBUF_ALLOC_INTERNAL;
- wm_err = R_WM_WindowCreate(mNativeDisplayID, mNativeWindow);
+ r_wm_Error_t wm_err = R_WM_WindowCreate(mNativeDisplayID, mNativeWindow);
if (wm_err != R_WM_ERR_OK)
qFatal("Failed to create window layer: %d", wm_err);
wm_err = R_WM_DevEventRegister(mNativeDisplayID, R_WM_EVENT_VBLANK, 0);
diff --git a/src/plugins/platforms/qnx/qqnxkeytranslator.h b/src/plugins/platforms/qnx/qqnxkeytranslator.h
index 043e38fec9..9400b88dbb 100644
--- a/src/plugins/platforms/qnx/qqnxkeytranslator.h
+++ b/src/plugins/platforms/qnx/qqnxkeytranslator.h
@@ -48,179 +48,68 @@
QT_BEGIN_NAMESPACE
-Qt::Key keyTranslator( int key )
+int qtKeyForPrivateUseQnxKey( int key )
{
switch (key) {
- case KEYCODE_PAUSE:
- return Qt::Key_Pause;
-
- case KEYCODE_SCROLL_LOCK:
- return Qt::Key_ScrollLock;
-
- case KEYCODE_PRINT:
- return Qt::Key_Print;
-
- case KEYCODE_SYSREQ:
- return Qt::Key_SysReq;
-
+ case KEYCODE_PAUSE: return Qt::Key_Pause;
+ case KEYCODE_SCROLL_LOCK: return Qt::Key_ScrollLock;
+ case KEYCODE_PRINT: return Qt::Key_Print;
+ case KEYCODE_SYSREQ: return Qt::Key_SysReq;
// case KEYCODE_BREAK:
-
- case KEYCODE_ESCAPE:
- return Qt::Key_Escape;
-
- case KEYCODE_BACKSPACE:
- return Qt::Key_Backspace;
-
- case KEYCODE_TAB:
- return Qt::Key_Tab;
-
- case KEYCODE_BACK_TAB:
- return Qt::Key_Backtab;
-
- case KEYCODE_RETURN:
- return Qt::Key_Return;
-
- case KEYCODE_CAPS_LOCK:
- return Qt::Key_CapsLock;
-
- case KEYCODE_LEFT_SHIFT:
- case KEYCODE_RIGHT_SHIFT:
- return Qt::Key_Shift;
-
- case KEYCODE_LEFT_CTRL:
- case KEYCODE_RIGHT_CTRL:
- return Qt::Key_Control;
-
- case KEYCODE_LEFT_ALT:
- case KEYCODE_RIGHT_ALT:
- return Qt::Key_Alt;
-
- case KEYCODE_MENU:
- return Qt::Key_Menu;
-
- case KEYCODE_LEFT_HYPER:
- return Qt::Key_Hyper_L;
-
- case KEYCODE_RIGHT_HYPER:
- return Qt::Key_Hyper_R;
-
- case KEYCODE_INSERT:
- return Qt::Key_Insert;
-
- case KEYCODE_HOME:
- return Qt::Key_Home;
-
- case KEYCODE_PG_UP:
- return Qt::Key_PageUp;
-
- case KEYCODE_DELETE:
- return Qt::Key_Delete;
-
- case KEYCODE_END:
- return Qt::Key_End;
-
- case KEYCODE_PG_DOWN:
- return Qt::Key_PageDown;
-
- case KEYCODE_LEFT:
- return Qt::Key_Left;
-
- case KEYCODE_RIGHT:
- return Qt::Key_Right;
-
- case KEYCODE_UP:
- return Qt::Key_Up;
-
- case KEYCODE_DOWN:
- return Qt::Key_Down;
-
- case KEYCODE_NUM_LOCK:
- return Qt::Key_NumLock;
-
- case KEYCODE_KP_PLUS:
- return Qt::Key_Plus;
-
- case KEYCODE_KP_MINUS:
- return Qt::Key_Minus;
-
- case KEYCODE_KP_MULTIPLY:
- return Qt::Key_Asterisk;
-
- case KEYCODE_KP_DIVIDE:
- return Qt::Key_Slash;
-
- case KEYCODE_KP_ENTER:
- return Qt::Key_Enter;
-
- case KEYCODE_KP_HOME:
- return Qt::Key_Home;
-
- case KEYCODE_KP_UP:
- return Qt::Key_Up;
-
- case KEYCODE_KP_PG_UP:
- return Qt::Key_PageUp;
-
- case KEYCODE_KP_LEFT:
- return Qt::Key_Left;
-
- // Is this right?
- case KEYCODE_KP_FIVE:
- return Qt::Key_5;
-
- case KEYCODE_KP_RIGHT:
- return Qt::Key_Right;
-
- case KEYCODE_KP_END:
- return Qt::Key_End;
-
- case KEYCODE_KP_DOWN:
- return Qt::Key_Down;
-
- case KEYCODE_KP_PG_DOWN:
- return Qt::Key_PageDown;
-
- case KEYCODE_KP_INSERT:
- return Qt::Key_Insert;
-
- case KEYCODE_KP_DELETE:
- return Qt::Key_Delete;
-
- case KEYCODE_F1:
- return Qt::Key_F1;
-
- case KEYCODE_F2:
- return Qt::Key_F2;
-
- case KEYCODE_F3:
- return Qt::Key_F3;
-
- case KEYCODE_F4:
- return Qt::Key_F4;
-
- case KEYCODE_F5:
- return Qt::Key_F5;
-
- case KEYCODE_F6:
- return Qt::Key_F6;
-
- case KEYCODE_F7:
- return Qt::Key_F7;
-
- case KEYCODE_F8:
- return Qt::Key_F8;
-
- case KEYCODE_F9:
- return Qt::Key_F9;
-
- case KEYCODE_F10:
- return Qt::Key_F10;
-
- case KEYCODE_F11:
- return Qt::Key_F11;
-
- case KEYCODE_F12:
- return Qt::Key_F12;
+ case KEYCODE_ESCAPE: return Qt::Key_Escape;
+ case KEYCODE_BACKSPACE: return Qt::Key_Backspace;
+ case KEYCODE_TAB: return Qt::Key_Tab;
+ case KEYCODE_BACK_TAB: return Qt::Key_Backtab;
+ case KEYCODE_RETURN: return Qt::Key_Return;
+ case KEYCODE_CAPS_LOCK: return Qt::Key_CapsLock;
+ case KEYCODE_LEFT_SHIFT: return Qt::Key_Shift;
+ case KEYCODE_RIGHT_SHIFT: return Qt::Key_Shift;
+ case KEYCODE_LEFT_CTRL: return Qt::Key_Control;
+ case KEYCODE_RIGHT_CTRL: return Qt::Key_Control;
+ case KEYCODE_LEFT_ALT: return Qt::Key_Alt;
+ case KEYCODE_RIGHT_ALT: return Qt::Key_Alt;
+ case KEYCODE_MENU: return Qt::Key_Menu;
+ case KEYCODE_LEFT_HYPER: return Qt::Key_Hyper_L;
+ case KEYCODE_RIGHT_HYPER: return Qt::Key_Hyper_R;
+ case KEYCODE_INSERT: return Qt::Key_Insert;
+ case KEYCODE_HOME: return Qt::Key_Home;
+ case KEYCODE_PG_UP: return Qt::Key_PageUp;
+ case KEYCODE_DELETE: return Qt::Key_Delete;
+ case KEYCODE_END: return Qt::Key_End;
+ case KEYCODE_PG_DOWN: return Qt::Key_PageDown;
+ case KEYCODE_LEFT: return Qt::Key_Left;
+ case KEYCODE_RIGHT: return Qt::Key_Right;
+ case KEYCODE_UP: return Qt::Key_Up;
+ case KEYCODE_DOWN: return Qt::Key_Down;
+ case KEYCODE_NUM_LOCK: return Qt::Key_NumLock;
+ case KEYCODE_KP_PLUS: return Qt::Key_Plus;
+ case KEYCODE_KP_MINUS: return Qt::Key_Minus;
+ case KEYCODE_KP_MULTIPLY: return Qt::Key_Asterisk;
+ case KEYCODE_KP_DIVIDE: return Qt::Key_Slash;
+ case KEYCODE_KP_ENTER: return Qt::Key_Enter;
+ case KEYCODE_KP_HOME: return Qt::Key_Home;
+ case KEYCODE_KP_UP: return Qt::Key_Up;
+ case KEYCODE_KP_PG_UP: return Qt::Key_PageUp;
+ case KEYCODE_KP_LEFT: return Qt::Key_Left;
+ case KEYCODE_KP_FIVE: return Qt::Key_5;
+ case KEYCODE_KP_RIGHT: return Qt::Key_Right;
+ case KEYCODE_KP_END: return Qt::Key_End;
+ case KEYCODE_KP_DOWN: return Qt::Key_Down;
+ case KEYCODE_KP_PG_DOWN: return Qt::Key_PageDown;
+ case KEYCODE_KP_INSERT: return Qt::Key_Insert;
+ case KEYCODE_KP_DELETE: return Qt::Key_Delete;
+ case KEYCODE_F1: return Qt::Key_F1;
+ case KEYCODE_F2: return Qt::Key_F2;
+ case KEYCODE_F3: return Qt::Key_F3;
+ case KEYCODE_F4: return Qt::Key_F4;
+ case KEYCODE_F5: return Qt::Key_F5;
+ case KEYCODE_F6: return Qt::Key_F6;
+ case KEYCODE_F7: return Qt::Key_F7;
+ case KEYCODE_F8: return Qt::Key_F8;
+ case KEYCODE_F9: return Qt::Key_F9;
+ case KEYCODE_F10: return Qt::Key_F10;
+ case KEYCODE_F11: return Qt::Key_F11;
+ case KEYCODE_F12: return Qt::Key_F12;
// See keycodes.h for more, but these are all the basics. And printables are already included.
@@ -231,7 +120,21 @@ Qt::Key keyTranslator( int key )
break;
}
- return Qt::Key_Escape;
+ return Qt::Key_unknown;
+}
+
+QString keyStringForPrivateUseQnxKey( int key )
+{
+ switch (key) {
+ case KEYCODE_ESCAPE: return QStringLiteral("\x1B");
+ case KEYCODE_BACKSPACE: return QStringLiteral("\b");
+ case KEYCODE_TAB: return QStringLiteral("\t");
+ case KEYCODE_RETURN: return QStringLiteral("\r");
+ case KEYCODE_DELETE: return QStringLiteral("\x7F");
+ case KEYCODE_KP_ENTER: return QStringLiteral("\r");
+ }
+
+ return QString();
}
bool isKeypadKey( int key )
diff --git a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp
index 3eebb9c742..3bd6a86b59 100644
--- a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp
+++ b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp
@@ -91,6 +91,9 @@ void *QQnxNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q
void *QQnxNativeInterface::nativeResourceForIntegration(const QByteArray &resource)
{
+ if (resource == "screenContext")
+ return m_integration->screenContext();
+
return 0;
}
diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
index dc844189d1..0014ef8c6e 100644
--- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
@@ -158,7 +158,7 @@ QQnxBuffer &QQnxRasterWindow::renderBuffer()
"Failed to clear window buffer");
}
- Q_SCREEN_CHECKERROR(screen_flush_blits(platformScreen->nativeContext(), 0),
+ Q_SCREEN_CHECKERROR(screen_flush_blits(platformScreen->nativeContext(), SCREEN_WAIT_IDLE),
"Failed to flush blits");
// Use the first available render buffer
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index 5d230e2145..ff1133aaa7 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -58,6 +58,37 @@
#define qScreenEventDebug QT_NO_QDEBUG_MACRO
#endif
+static int qtKey(int virtualKey, QChar::Category category)
+{
+ if (Q_UNLIKELY(category == QChar::Other_NotAssigned))
+ return virtualKey;
+ else if (category == QChar::Other_PrivateUse)
+ return qtKeyForPrivateUseQnxKey(virtualKey);
+ else
+ return QChar::toUpper(virtualKey);
+}
+
+static QString keyString(int sym, QChar::Category category)
+{
+ if (Q_UNLIKELY(category == QChar::Other_NotAssigned)) {
+ return QString();
+ } else if (category == QChar::Other_PrivateUse) {
+ return keyStringForPrivateUseQnxKey(sym);
+ } else {
+ uint ucs4_sym = sym;
+ return QString::fromUcs4(&ucs4_sym, 1);
+ }
+}
+
+static QString capKeyString(int cap, int modifiers, int key)
+{
+ if (cap >= 0x20 && cap <= 0x0ff) {
+ if (modifiers & KEYMOD_CTRL)
+ return QChar((int)(key & 0x3f));
+ }
+ return QString();
+}
+
QT_BEGIN_NAMESPACE
QQnxScreenEventHandler::QQnxScreenEventHandler(QQnxIntegration *integration)
@@ -154,6 +185,13 @@ void QQnxScreenEventHandler::injectKeyboardEvent(int flags, int sym, int modifie
{
Q_UNUSED(scan);
+ if (!(flags & KEY_CAP_VALID))
+ return;
+
+ // Correct erroneous information.
+ if ((flags & KEY_SYM_VALID) && sym == static_cast<int>(0xFFFFFFFF))
+ flags &= ~(KEY_SYM_VALID);
+
Qt::KeyboardModifiers qtMod = Qt::NoModifier;
if (modifiers & KEYMOD_SHIFT)
qtMod |= Qt::ShiftModifier;
@@ -161,37 +199,20 @@ void QQnxScreenEventHandler::injectKeyboardEvent(int flags, int sym, int modifie
qtMod |= Qt::ControlModifier;
if (modifiers & KEYMOD_ALT)
qtMod |= Qt::AltModifier;
+ if (isKeypadKey(cap))
+ qtMod |= Qt::KeypadModifier;
- // determine event type
QEvent::Type type = (flags & KEY_DOWN) ? QEvent::KeyPress : QEvent::KeyRelease;
- // Check if the key cap is valid
- if (flags & KEY_CAP_VALID) {
- Qt::Key key;
- QString keyStr;
+ int virtualKey = (flags & KEY_SYM_VALID) ? sym : cap;
+ QChar::Category category = QChar::category(virtualKey);
+ int key = qtKey(virtualKey, category);
+ QString keyStr = (flags & KEY_SYM_VALID) ? keyString(sym, category) :
+ capKeyString(cap, modifiers, key);
- if (cap >= 0x20 && cap <= 0x0ff) {
- key = Qt::Key(std::toupper(cap)); // Qt expects the CAP to be upper case.
-
- if ( qtMod & Qt::ControlModifier ) {
- keyStr = QChar((int)(key & 0x3f));
- } else {
- if (flags & KEY_SYM_VALID)
- keyStr = QChar(sym);
- }
- } else if ((cap > 0x0ff && cap < UNICODE_PRIVATE_USE_AREA_FIRST) || cap > UNICODE_PRIVATE_USE_AREA_LAST) {
- key = (Qt::Key)cap;
- keyStr = QChar(sym);
- } else {
- if (isKeypadKey(cap))
- qtMod |= Qt::KeypadModifier; // Is this right?
- key = keyTranslator(cap);
- }
-
- QWindowSystemInterface::handleExtendedKeyEvent(QGuiApplication::focusWindow(), type, key, qtMod,
- scan, sym, modifiers, keyStr);
- qScreenEventDebug() << "Qt key t=" << type << ", k=" << key << ", s=" << keyStr;
- }
+ QWindowSystemInterface::handleExtendedKeyEvent(QGuiApplication::focusWindow(), type, key, qtMod,
+ scan, virtualKey, modifiers, keyStr);
+ qScreenEventDebug() << "Qt key t=" << type << ", k=" << key << ", s=" << keyStr;
}
void QQnxScreenEventHandler::setScreenEventThread(QQnxScreenEventThread *eventThread)
@@ -591,6 +612,10 @@ void QQnxScreenEventHandler::handlePropertyEvent(screen_event_t event)
case SCREEN_PROPERTY_FOCUS:
handleKeyboardFocusPropertyEvent(window);
break;
+ case SCREEN_PROPERTY_SIZE:
+ case SCREEN_PROPERTY_POSITION:
+ handleGeometryPropertyEvent(window);
+ break;
default:
// event ignored
qScreenEventDebug() << "Ignore property event for property: " << property;
@@ -617,6 +642,28 @@ void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t wi
m_focusLostTimer = startTimer(50);
}
+void QQnxScreenEventHandler::handleGeometryPropertyEvent(screen_window_t window)
+{
+ int pos[2];
+ if (screen_get_window_property_iv(window, SCREEN_PROPERTY_POSITION, pos) != 0) {
+ qFatal("QQnx: failed to query window property, errno=%d", errno);
+ }
+
+ int size[2];
+ if (screen_get_window_property_iv(window, SCREEN_PROPERTY_SIZE, size) != 0) {
+ qFatal("QQnx: failed to query window property, errno=%d", errno);
+ }
+
+ QRect rect(pos[0], pos[1], size[0], size[1]);
+ QWindow *qtWindow = QQnxIntegration::window(window);
+ if (qtWindow) {
+ qtWindow->setGeometry(rect);
+ QWindowSystemInterface::handleGeometryChange(qtWindow, rect);
+ }
+
+ qScreenEventDebug() << qtWindow << "moved to" << rect;
+}
+
void QQnxScreenEventHandler::timerEvent(QTimerEvent *event)
{
if (event->timerId() == m_focusLostTimer) {
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h
index d872f9b9aa..40697b7a09 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h
@@ -85,6 +85,7 @@ private:
void handleDisplayEvent(screen_event_t event);
void handlePropertyEvent(screen_event_t event);
void handleKeyboardFocusPropertyEvent(screen_window_t window);
+ void handleGeometryPropertyEvent(screen_window_t window);
private:
enum {
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 072012064f..98a4b261fd 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -246,14 +246,12 @@ struct QWindowsContextPrivate {
QScopedPointer<QWindowsTabletSupport> m_tabletSupport;
#endif
const HRESULT m_oleInitializeResult;
- const QByteArray m_eventType;
QWindow *m_lastActiveWindow = nullptr;
bool m_asyncExpose = false;
};
QWindowsContextPrivate::QWindowsContextPrivate()
: m_oleInitializeResult(OleInitialize(NULL))
- , m_eventType(QByteArrayLiteral("windows_generic_MSG"))
{
QWindowsContext::user32dll.init();
QWindowsContext::shcoredll.init();
@@ -866,6 +864,33 @@ static bool shouldHaveNonClientDpiScaling(const QWindow *window)
;
}
+static inline bool isInputMessage(UINT m)
+{
+ switch (m) {
+ case WM_IME_STARTCOMPOSITION:
+ case WM_IME_ENDCOMPOSITION:
+ case WM_IME_COMPOSITION:
+ case WM_TOUCH:
+ case WM_MOUSEHOVER:
+ case WM_MOUSELEAVE:
+ case WM_NCHITTEST:
+ case WM_NCMOUSEHOVER:
+ case WM_NCMOUSELEAVE:
+ case WM_SIZING:
+ case WM_MOVING:
+ case WM_SYSCOMMAND:
+ case WM_COMMAND:
+ case WM_DWMNCRENDERINGCHANGED:
+ case WM_PAINT:
+ return true;
+ default:
+ break;
+ }
+ return (m >= WM_MOUSEFIRST && m <= WM_MOUSELAST)
+ || (m >= WM_NCMOUSEMOVE && m <= WM_NCXBUTTONDBLCLK)
+ || (m >= WM_KEYFIRST && m <= WM_KEYLAST);
+}
+
/*!
\brief Main windows procedure registered for windows.
@@ -901,21 +926,14 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
QWindowsWindow *platformWindow = findPlatformWindow(hwnd);
*platformWindowPtr = platformWindow;
- // Run the native event filters.
- long filterResult = 0;
- QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance();
- if (dispatcher && dispatcher->filterNativeEvent(d->m_eventType, &msg, &filterResult)) {
- *result = LRESULT(filterResult);
+ // Run the native event filters. QTBUG-67095: Exclude input messages which are sent
+ // by QEventDispatcherWin32::processEvents()
+ if (!isInputMessage(msg.message) && filterNativeEvent(&msg, result))
+ return true;
+
+ if (platformWindow && filterNativeEvent(platformWindow->window(), &msg, result))
return true;
- }
- if (platformWindow) {
- filterResult = 0;
- if (QWindowSystemInterface::handleNativeEvent(platformWindow->window(), d->m_eventType, &msg, &filterResult)) {
- *result = LRESULT(filterResult);
- return true;
- }
- }
if (et & QtWindows::InputMethodEventFlag) {
QWindowsInputContext *windowsInputContext = ::windowsInputContext();
// Disable IME assuming this is a special implementation hooking into keyboard input.
@@ -1393,4 +1411,30 @@ extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND hwnd, UINT message, WPAR
return result;
}
+
+static inline QByteArray nativeEventType() { return QByteArrayLiteral("windows_generic_MSG"); }
+
+// Send to QAbstractEventDispatcher
+bool QWindowsContext::filterNativeEvent(MSG *msg, LRESULT *result)
+{
+ QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance();
+ long filterResult = 0;
+ if (dispatcher && dispatcher->filterNativeEvent(nativeEventType(), msg, &filterResult)) {
+ *result = LRESULT(filterResult);
+ return true;
+ }
+ return false;
+}
+
+// Send to QWindowSystemInterface
+bool QWindowsContext::filterNativeEvent(QWindow *window, MSG *msg, LRESULT *result)
+{
+ long filterResult = 0;
+ if (QWindowSystemInterface::handleNativeEvent(window, nativeEventType(), &msg, &filterResult)) {
+ *result = LRESULT(filterResult);
+ return true;
+ }
+ return false;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index f2ec307be2..0a7f20ca83 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -212,6 +212,9 @@ public:
QTouchDevice *touchDevice() const;
+ static bool filterNativeEvent(MSG *msg, LRESULT *result);
+ static bool filterNativeEvent(QWindow *window, MSG *msg, LRESULT *result);
+
private:
void handleFocusEvent(QtWindows::WindowsEventType et, QWindowsWindow *w);
#ifndef QT_NO_CONTEXTMENU
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index b9dd2c557e..2dbca6047c 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -530,6 +530,14 @@ bool QWindowsInputContext::endComposition(HWND hwnd)
if (m_compositionContext.focusObject.isNull())
return false;
+ // QTBUG-58300: Ignore WM_IME_ENDCOMPOSITION when CTRL is pressed to prevent
+ // for example the text being cleared when pressing CTRL+A
+ if (m_locale.language() == QLocale::Korean
+ && QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
+ reset();
+ return true;
+ }
+
m_endCompositionRecursionGuard = true;
imeNotifyCancelComposition(m_compositionContext.hwnd);
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index af62936a18..950d8ecd36 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -102,6 +102,7 @@ QWindowsKeyMapper::QWindowsKeyMapper()
QGuiApplication *app = static_cast<QGuiApplication *>(QGuiApplication::instance());
QObject::connect(app, &QGuiApplication::applicationStateChanged,
app, clearKeyRecorderOnApplicationInActive);
+ changeKeyboard();
}
QWindowsKeyMapper::~QWindowsKeyMapper()
@@ -317,9 +318,9 @@ static const uint KeyTbl[] = { // Keyboard mapping table
Qt::Key_9, // 105 0x69 VK_NUMPAD9 | Numeric keypad 9 key
Qt::Key_Asterisk, // 106 0x6A VK_MULTIPLY | Multiply key
Qt::Key_Plus, // 107 0x6B VK_ADD | Add key
- Qt::Key_Comma, // 108 0x6C VK_SEPARATOR | Separator key
+ Qt::Key_unknown, // 108 0x6C VK_SEPARATOR | Separator key (locale-dependent)
Qt::Key_Minus, // 109 0x6D VK_SUBTRACT | Subtract key
- Qt::Key_Period, // 110 0x6E VK_DECIMAL | Decimal key
+ Qt::Key_unknown, // 110 0x6E VK_DECIMAL | Decimal key (locale-dependent)
Qt::Key_Slash, // 111 0x6F VK_DIVIDE | Divide key
Qt::Key_F1, // 112 0x70 VK_F1 | F1 key
Qt::Key_F2, // 113 0x71 VK_F2 | F2 key
@@ -810,7 +811,7 @@ bool QWindowsKeyMapper::translateKeyEvent(QWindow *widget, HWND hwnd,
// Reset layout map when system keyboard layout is changed
if (msg.message == WM_INPUTLANGCHANGE) {
- deleteLayouts();
+ changeKeyboard();
return true;
}
@@ -830,7 +831,7 @@ bool QWindowsKeyMapper::translateKeyEvent(QWindow *widget, HWND hwnd,
if (PeekMessage(&peekedMsg, hwnd, 0, 0, PM_NOREMOVE) && peekedMsg.message == WM_DEADCHAR)
return true;
- return translateKeyEventInternal(widget, msg, false);
+ return translateKeyEventInternal(widget, msg, false, result);
}
bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, const MSG &msg)
@@ -854,15 +855,19 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con
sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0);
// QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise,
// the keys are not passed to the active media player.
+# if QT_CONFIG(shortcut)
const QKeySequence sequence(Qt::Modifier(state) + qtKey);
return QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(sequence);
+# else
+ return false;
+# endif
#else
Q_UNREACHABLE();
return false;
#endif
}
-bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &msg, bool /* grab */)
+bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &msg, bool /* grab */, LRESULT *lResult)
{
const UINT msgType = msg.message;
@@ -1056,6 +1061,10 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
QChar uch;
if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) {
+ if (QWindowsContext::filterNativeEvent(&wm_char, lResult))
+ return true;
+ if (receiver && QWindowsContext::filterNativeEvent(receiver, &wm_char, lResult))
+ return true;
// Found a ?_CHAR
uch = QChar(ushort(wm_char.wParam));
if (uch.isHighSurrogate()) {
@@ -1264,8 +1273,19 @@ QList<int> QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const
for (size_t i = 1; i < NumMods; ++i) {
Qt::KeyboardModifiers neededMods = ModsTbl[i];
quint32 key = kbItem.qtKey[i];
- if (key && key != baseKey && ((keyMods & neededMods) == neededMods))
- result << int(key + (keyMods & ~neededMods));
+ if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) {
+ const Qt::KeyboardModifiers missingMods = keyMods & ~neededMods;
+ const int matchedKey = int(key) + missingMods;
+ const QList<int>::iterator it =
+ std::find_if(result.begin(), result.end(),
+ [key] (int k) { return (k & ~Qt::KeyboardModifierMask) == key; });
+ // QTBUG-67200: Use the match with the least modifiers (prefer
+ // Shift+9 over Alt + Shift + 9) resulting in more missing modifiers.
+ if (it == result.end())
+ result << matchedKey;
+ else if (missingMods > (*it & Qt::KeyboardModifierMask))
+ *it = matchedKey;
+ }
}
return result;
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.h b/src/plugins/platforms/windows/qwindowskeymapper.h
index 2657644780..c6b46b0c30 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.h
+++ b/src/plugins/platforms/windows/qwindowskeymapper.h
@@ -90,7 +90,7 @@ public:
QList<int> possibleKeys(const QKeyEvent *e) const;
private:
- bool translateKeyEventInternal(QWindow *receiver, const MSG &msg, bool grab);
+ bool translateKeyEventInternal(QWindow *receiver, const MSG &msg, bool grab, LRESULT *lResult);
bool translateMultimediaKeyEventInternal(QWindow *receiver, const MSG &msg);
void updateKeyMap(const MSG &msg);
diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp
index b89e1b66a3..71802b9017 100644
--- a/src/plugins/platforms/windows/qwindowsmenu.cpp
+++ b/src/plugins/platforms/windows/qwindowsmenu.cpp
@@ -390,6 +390,7 @@ void QWindowsMenuItem::setChecked(bool isChecked)
menuItemSetChangeState(parentMenuHandle(), m_id, FALSE, m_checked, MF_CHECKED, MF_UNCHECKED);
}
+#if QT_CONFIG(shortcut)
void QWindowsMenuItem::setShortcut(const QKeySequence &shortcut)
{
qCDebug(lcQpaMenus) << __FUNCTION__ << '(' << shortcut << ')' << this;
@@ -399,6 +400,7 @@ void QWindowsMenuItem::setShortcut(const QKeySequence &shortcut)
if (m_parentMenu != nullptr)
updateText();
}
+#endif
void QWindowsMenuItem::setEnabled(bool enabled)
{
@@ -441,10 +443,12 @@ UINT QWindowsMenuItem::state() const
QString QWindowsMenuItem::nativeText() const
{
QString result = m_text;
+#if QT_CONFIG(shortcut)
if (!m_shortcut.isEmpty()) {
result += QLatin1Char('\t');
result += m_shortcut.toString(QKeySequence::NativeText);
}
+#endif
return result;
}
@@ -894,8 +898,10 @@ void QWindowsMenuItem::formatDebug(QDebug &d) const
d << ", subMenu=" << static_cast<const void *>(m_subMenu);
d << ", tag=" << showbase << hex
<< tag() << noshowbase << dec << ", id=" << m_id;
+#if QT_CONFIG(shortcut)
if (!m_shortcut.isEmpty())
d << ", shortcut=" << m_shortcut;
+#endif
if (m_visible)
d << " [visible]";
if (m_enabled)
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 814291c54a..17851618b4 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -395,10 +395,24 @@ static bool isValidWheelReceiver(QWindow *candidate)
static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int delta,
Qt::Orientation orientation, Qt::KeyboardModifiers mods)
{
+ // Redirect wheel event to one of the following, in order of preference:
+ // 1) The window under mouse
+ // 2) The window receiving the event
// If a window is blocked by modality, it can't get the event.
- if (isValidWheelReceiver(window)) {
- QWindowSystemInterface::handleWheelEvent(window,
- QWindowsGeometryHint::mapFromGlobal(window, globalPos),
+
+ QWindow *receiver = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE);
+ while (receiver && receiver->flags().testFlag(Qt::WindowTransparentForInput))
+ receiver = receiver->parent();
+ bool handleEvent = true;
+ if (!isValidWheelReceiver(receiver)) {
+ receiver = window;
+ if (!isValidWheelReceiver(receiver))
+ handleEvent = false;
+ }
+
+ if (handleEvent) {
+ QWindowSystemInterface::handleWheelEvent(receiver,
+ QWindowsGeometryHint::mapFromGlobal(receiver, globalPos),
globalPos, delta, orientation, mods);
}
}
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index f1762146ec..f8d6ae222e 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -1144,11 +1144,11 @@ void QWindowsWindow::initialize()
const Qt::WindowState state = w->windowState();
if (state != Qt::WindowMaximized && state != Qt::WindowFullScreen
&& creationContext->requestedGeometryIn != creationContext->obtainedGeometry) {
- QWindowSystemInterface::handleGeometryChange(w, creationContext->obtainedGeometry);
+ QWindowSystemInterface::handleGeometryChange<QWindowSystemInterface::SynchronousDelivery>(w, creationContext->obtainedGeometry);
}
QPlatformScreen *obtainedScreen = screenForGeometry(creationContext->obtainedGeometry);
if (obtainedScreen && screen() != obtainedScreen)
- QWindowSystemInterface::handleWindowScreenChanged(w, obtainedScreen->screen());
+ QWindowSystemInterface::handleWindowScreenChanged<QWindowSystemInterface::SynchronousDelivery>(w, obtainedScreen->screen());
}
}
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
index 8d151b760b..b401100dd4 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -301,8 +301,10 @@ QXcbCursorCacheKey::QXcbCursorCacheKey(const QCursor &c)
QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
: QXcbObject(conn), m_screen(screen), m_gtkCursorThemeInitialized(false)
{
+#if QT_CONFIG(cursor)
// see NUM_BITMAPS in libXcursor/src/xcursorint.h
m_bitmapCache.setMaxCost(8);
+#endif
if (cursorCount++)
return;
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index df458e85d7..e1bd8eb752 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -750,7 +750,12 @@ void QXcbScreen::updateGeometry(const QRect &geometry, uint8_t rotation)
m_sizeMillimeters = sizeInMillimeters(geometry.size(), virtualDpi());
qreal dpi = geometry.width() / physicalSize().width() * qreal(25.4);
- m_pixelDensity = qMax(1, qRound(dpi/96));
+ qreal rawFactor = dpi/96;
+ int roundedFactor = qFloor(rawFactor);
+ // Round up for .8 and higher. This favors "small UI" over "large UI".
+ if (rawFactor - roundedFactor >= 0.8)
+ roundedFactor = qCeil(rawFactor);
+ m_pixelDensity = qMax(1, roundedFactor);
m_geometry = geometry;
m_availableGeometry = geometry & m_virtualDesktop->workArea();
QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry);
diff --git a/src/plugins/platformthemes/flatpak/qflatpakfiledialog.cpp b/src/plugins/platformthemes/flatpak/qflatpakfiledialog.cpp
index 186084abd4..c31b326357 100644
--- a/src/plugins/platformthemes/flatpak/qflatpakfiledialog.cpp
+++ b/src/plugins/platformthemes/flatpak/qflatpakfiledialog.cpp
@@ -210,7 +210,7 @@ void QFlatpakFileDialog::openPortal()
QRegularExpressionMatch match = regexp.match(filter);
if (match.hasMatch()) {
QString userVisibleName = match.captured(1);
- QStringList filterStrings = match.captured(2).split(QLatin1String(" "));
+ QStringList filterStrings = match.captured(2).split(QLatin1Char(' '), QString::SkipEmptyParts);
FilterConditionList filterConditions;
for (const QString &filterString : filterStrings) {
diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp
index bd0d641e79..6c29a99705 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp
@@ -276,7 +276,10 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
// Get the equivalent page size for this printer as supported names may be different
- setPageSize(m_pageLayout.pageSize());
+ if (m_printDevice.supportedPageSize(m_pageLayout.pageSize()).isValid())
+ setPageSize(m_pageLayout.pageSize());
+ else
+ setPageSize(QPageSize(m_pageLayout.pageSize().size(QPageSize::Point), QPageSize::Point));
}
void QCupsPrintEnginePrivate::setPageSize(const QPageSize &pageSize)
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
index 6375825720..2a770d0245 100644
--- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
@@ -55,7 +55,9 @@
#include <qcache.h>
#include <qregularexpression.h>
#endif
+#if QT_CONFIG(timezone)
#include <QTimeZone>
+#endif
#include <QScopedValueRollback>
#if defined Q_OS_WIN
@@ -438,8 +440,10 @@ static QString timespecToString(const QDateTime &dateTime)
return QStringLiteral("Z");
case Qt::OffsetFromUTC:
return secondsToOffset(dateTime.offsetFromUtc());
+#if QT_CONFIG(timezone)
case Qt::TimeZone:
return secondsToOffset(dateTime.timeZone().offsetFromUtc(dateTime));
+#endif
default:
return QString();
}
@@ -492,10 +496,10 @@ bool QSQLiteResult::exec()
#if (SQLITE_VERSION_NUMBER >= 3003011)
// In the case of the reuse of a named placeholder
- // We need to check explicitly that paramCount is greater than 1, as sqlite
+ // We need to check explicitly that paramCount is greater than or equal to 1, as sqlite
// can end up in a case where for virtual tables it returns 0 even though it
// has parameters
- if (paramCount > 1 && paramCount < values.count()) {
+ if (paramCount >= 1 && paramCount < values.count()) {
const auto countIndexes = [](int counter, const QVector<int> &indexList) {
return counter + indexList.length();
};
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 569eeef0ff..95809906c1 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -121,7 +121,6 @@
#include <qwizard.h>
#endif
#include <qdebug.h>
-#include <qlibrary.h>
#if QT_CONFIG(datetimeedit)
#include <qdatetimeedit.h>
#endif
diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h
index 4eac0a59d6..8c712e838a 100644
--- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h
+++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h
@@ -110,7 +110,9 @@
#include <qstyleoption.h>
#include <qtextedit.h>
#include <qtextstream.h>
+#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
+#endif
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
#endif
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h
index b649426811..d66b17e9f8 100644
--- a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h
+++ b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h
@@ -75,7 +75,9 @@
#if QT_CONFIG(spinbox)
#include <qspinbox.h>
#endif
+#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
+#endif
#if QT_CONFIG(combobox)
#include <qcombobox.h>
#endif
diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
index 733b3a9e9c..9d2e770191 100644
--- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
@@ -79,7 +79,9 @@
#if QT_CONFIG(pushbutton)
#include <qpushbutton.h>
#endif
+#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
+#endif
#include <qlabel.h>
#include <qvarlengtharray.h>
#include <qdebug.h>
@@ -3311,12 +3313,12 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con
res = 160;
break;
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case PM_ToolBarHandleExtent:
res = int(QStyleHelper::dpiScaled(8.));
break;
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
case PM_DockWidgetSeparatorExtent:
case PM_DockWidgetTitleMargin:
res = int(QStyleHelper::dpiScaled(4.));
diff --git a/src/printsupport/dialogs/qabstractprintdialog.cpp b/src/printsupport/dialogs/qabstractprintdialog.cpp
index 71b5500bab..1a2aa7afac 100644
--- a/src/printsupport/dialogs/qabstractprintdialog.cpp
+++ b/src/printsupport/dialogs/qabstractprintdialog.cpp
@@ -45,11 +45,6 @@
QT_BEGIN_NAMESPACE
-// hack
-class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
-{
-};
-
/*!
\class QAbstractPrintDialog
\brief The QAbstractPrintDialog class provides a base implementation for
@@ -145,7 +140,7 @@ QAbstractPrintDialog::~QAbstractPrintDialog()
*/
void QPrintDialog::setOption(PrintDialogOption option, bool on)
{
- Q_D(QPrintDialog);
+ auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
if (!(d->options & option) != !on)
setOptions(d->options ^ option);
}
@@ -158,7 +153,7 @@ void QPrintDialog::setOption(PrintDialogOption option, bool on)
*/
bool QPrintDialog::testOption(PrintDialogOption option) const
{
- Q_D(const QPrintDialog);
+ auto *d = static_cast<const QAbstractPrintDialogPrivate *>(d_ptr.data());
return (d->options & option) != 0;
}
@@ -177,7 +172,7 @@ bool QPrintDialog::testOption(PrintDialogOption option) const
*/
void QPrintDialog::setOptions(PrintDialogOptions options)
{
- Q_D(QPrintDialog);
+ auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
PrintDialogOptions changed = (options ^ d->options);
if (!changed)
@@ -188,7 +183,7 @@ void QPrintDialog::setOptions(PrintDialogOptions options)
QPrintDialog::PrintDialogOptions QPrintDialog::options() const
{
- Q_D(const QPrintDialog);
+ auto *d = static_cast<const QAbstractPrintDialogPrivate *>(d_ptr.data());
return d->options;
}
@@ -464,7 +459,7 @@ void QAbstractPrintDialog::setOptionTabs(const QList<QWidget*> &tabs)
*/
void QPrintDialog::done(int result)
{
- Q_D(QPrintDialog);
+ auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
QDialog::done(result);
if (result == Accepted)
emit accepted(printer());
@@ -487,7 +482,7 @@ void QPrintDialog::done(int result)
*/
void QPrintDialog::open(QObject *receiver, const char *member)
{
- Q_D(QPrintDialog);
+ auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
connect(this, SIGNAL(accepted(QPrinter*)), receiver, member);
d->receiverToDisconnectOnClose = receiver;
d->memberToDisconnectOnClose = member;
diff --git a/src/printsupport/dialogs/qabstractprintdialog_p.h b/src/printsupport/dialogs/qabstractprintdialog_p.h
index a17a28f564..b646b74f34 100644
--- a/src/printsupport/dialogs/qabstractprintdialog_p.h
+++ b/src/printsupport/dialogs/qabstractprintdialog_p.h
@@ -69,16 +69,15 @@ class QAbstractPrintDialogPrivate : public QDialogPrivate
public:
QAbstractPrintDialogPrivate()
- : printer(nullptr), pd(nullptr), ownsPrinter(false)
+ : printer(nullptr), pd(nullptr)
, options(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange |
QAbstractPrintDialog::PrintCollateCopies | QAbstractPrintDialog::PrintShowPageSize),
- minPage(0), maxPage(INT_MAX)
+ minPage(0), maxPage(INT_MAX), ownsPrinter(false)
{
}
QPrinter *printer;
QPrinterPrivate *pd;
- bool ownsPrinter;
QPointer<QObject> receiverToDisconnectOnClose;
QByteArray memberToDisconnectOnClose;
@@ -88,6 +87,8 @@ public:
void setPrinter(QPrinter *newPrinter);
int minPage;
int maxPage;
+
+ bool ownsPrinter;
};
QT_END_NAMESPACE
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index caab7867dc..86daea3b02 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -146,7 +146,9 @@ private slots:
private:
friend class QUnixPrintWidgetPrivate;
+#if QT_CONFIG(cups)
QPrinter *m_printer;
+#endif
Ui::QPrintPropertiesWidget widget;
QDialogButtonBox *m_buttons;
#if QT_CONFIG(cupsjobwidget)
@@ -351,7 +353,9 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrintDevice *
QPrinter::OutputFormat outputFormat, const QString &printerName,
QAbstractPrintDialog *parent)
: QDialog(parent)
+#if QT_CONFIG(cups)
, m_printer(printer)
+#endif
{
setWindowTitle(tr("Printer Properties"));
QVBoxLayout *lay = new QVBoxLayout(this);
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index a943d24cb1..ca4d1d0bd6 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1234,7 +1234,10 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
if (printDevice.isValid()) {
d->m_printDevice = printDevice;
d->initialize();
- setProperty(PPK_QPageSize, pageSize);
+ if (d->m_printDevice.supportedPageSize(pageSize.value<QPageSize>()).isValid())
+ setProperty(PPK_QPageSize, pageSize);
+ else
+ setProperty(PPK_CustomPaperSize, pageSize.value<QPageSize>().size(QPageSize::Point));
setProperty(PPK_FullPage, QVariant(isFullPage));
setProperty(PPK_Orientation, orientation);
setProperty(PPK_QPageMargins, margins);
diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp
index 18ae14be3a..e970be2c8d 100644
--- a/src/testlib/qabstractitemmodeltester.cpp
+++ b/src/testlib/qabstractitemmodeltester.cpp
@@ -4,9 +4,9 @@
** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the test suite of the Qt Toolkit.
+** This file is part of the QtTest module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** $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
@@ -15,13 +15,24 @@
** 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 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** 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-3.0.html.
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/testlib/qabstractitemmodeltester.h b/src/testlib/qabstractitemmodeltester.h
index 706c0ac16f..07bc170a7a 100644
--- a/src/testlib/qabstractitemmodeltester.h
+++ b/src/testlib/qabstractitemmodeltester.h
@@ -3,9 +3,9 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the test suite of the Qt Toolkit.
+** This file is part of the QtTest module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** $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
@@ -14,13 +14,24 @@
** 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 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** 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-3.0.html.
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h
index 79fe68004e..daa0d7aea0 100644
--- a/src/testlib/qtestsystem.h
+++ b/src/testlib/qtestsystem.h
@@ -112,23 +112,7 @@ namespace QTest
#ifdef QT_GUI_LIB
Q_REQUIRED_RESULT inline static bool qWaitForWindowActive(QWindow *window, int timeout = 5000)
{
- bool becameActive = qWaitFor([&]() { return window->isActive(); }, timeout);
-
- // Try ensuring the platform window receives the real position.
- // (i.e. that window->pos() reflects reality)
- // isActive() ( == FocusIn in case of X) does not guarantee this. It seems some WMs randomly
- // send the final ConfigureNotify (the one with the non-bogus 0,0 position) after the FocusIn.
- // If we just let things go, every mapTo/FromGlobal call the tests perform directly after
- // qWaitForWindowShown() will generate bogus results.
- if (becameActive) {
- int waitNo = 0; // 0, 0 might be a valid position after all, so do not wait for ever
- while (window->position().isNull()) {
- if (waitNo++ > timeout / 10)
- break;
- qWait(10);
- }
- }
- return window->isActive();
+ return qWaitFor([&]() { return window->isActive(); }, timeout);
}
Q_REQUIRED_RESULT inline static bool qWaitForWindowExposed(QWindow *window, int timeout = 5000)
diff --git a/src/testlib/qtesttable.cpp b/src/testlib/qtesttable.cpp
index 953495a18a..8d42668a5b 100644
--- a/src/testlib/qtesttable.cpp
+++ b/src/testlib/qtesttable.cpp
@@ -138,7 +138,7 @@ QTestData *QTestTable::testData(int index) const
return size_t(index) < d->dataList.size() ? d->dataList[index] : nullptr;
}
-class NamePredicate : public std::unary_function<QTestTablePrivate::Element, bool>
+class NamePredicate
{
public:
explicit NamePredicate(const char *needle) : m_needle(needle) {}
diff --git a/src/tools/qlalr/compress.cpp b/src/tools/qlalr/compress.cpp
index a486e68c4a..0ededbd920 100644
--- a/src/tools/qlalr/compress.cpp
+++ b/src/tools/qlalr/compress.cpp
@@ -37,7 +37,7 @@
#define QLALR_NO_CHECK_SORTED_TABLE
-struct _Fit: public std::binary_function<int, int, bool>
+struct _Fit
{
inline bool operator () (int a, int b) const
{
@@ -45,7 +45,7 @@ struct _Fit: public std::binary_function<int, int, bool>
}
};
-struct _PerfectMatch: public std::binary_function<int, int, bool>
+struct _PerfectMatch
{
inline bool operator () (int a, int b) const
{ return a == b; }
@@ -135,7 +135,7 @@ private:
const_iterator _M_endNonZeros;
};
-struct _SortUncompressedRow: public std::binary_function<UncompressedRow, UncompressedRow, bool>
+struct _SortUncompressedRow
{
inline bool operator () (const UncompressedRow &a, const UncompressedRow &b) const
{ return a.count (0) > b.count (0); }
diff --git a/src/tools/qlalr/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp
index ed0f53d43e..b14c73a8fe 100644
--- a/src/tools/qlalr/cppgenerator.cpp
+++ b/src/tools/qlalr/cppgenerator.cpp
@@ -186,7 +186,7 @@ void CppGenerator::operator () ()
else if (u < 0)
{
if (verbose)
- qout << "*** Warning. Found a reduce/reduce conflict in state " << q << " on token ``" << s << "'' between rule "
+ qout() << "*** Warning. Found a reduce/reduce conflict in state " << q << " on token ``" << s << "'' between rule "
<< r << " and " << -u << endl;
++reduce_reduce_conflict_count;
@@ -194,7 +194,7 @@ void CppGenerator::operator () ()
u = qMax (u, -r);
if (verbose)
- qout << "\tresolved using rule " << -u << endl;
+ qout() << "\tresolved using rule " << -u << endl;
}
else if (u > 0)
@@ -227,7 +227,7 @@ void CppGenerator::operator () ()
++shift_reduce_conflict_count;
if (verbose)
- qout << "*** Warning. Found a shift/reduce conflict in state " << q << " on token ``" << s << "'' with rule " << r << endl;
+ qout() << "*** Warning. Found a shift/reduce conflict in state " << q << " on token ``" << s << "'' with rule " << r << endl;
}
}
}
@@ -238,10 +238,10 @@ void CppGenerator::operator () ()
{
if (shift_reduce_conflict_count != grammar.expected_shift_reduce
|| reduce_reduce_conflict_count != grammar.expected_reduce_reduce)
- qerr << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << endl;
+ qerr() << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << endl;
if (verbose)
- qout << endl << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << endl
+ qout() << endl << "*** Conflicts: " << shift_reduce_conflict_count << " shift/reduce, " << reduce_reduce_conflict_count << " reduce/reduce" << endl
<< endl;
}
@@ -266,7 +266,7 @@ void CppGenerator::operator () ()
RulePointer rule = grammar.rules.begin () + i;
if (rule != grammar.goal)
- qerr << "*** Warning: Rule ``" << *rule << "'' is useless!" << endl;
+ qerr() << "*** Warning: Rule ``" << *rule << "'' is useless!" << endl;
}
}
diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp
index 0ccf4c1588..ec960925aa 100644
--- a/src/tools/qlalr/lalr.cpp
+++ b/src/tools/qlalr/lalr.cpp
@@ -40,8 +40,17 @@
#define QLALR_NO_DEBUG_LOOKAHEADS
QT_BEGIN_NAMESPACE
-QTextStream qerr (stderr, QIODevice::WriteOnly);
-QTextStream qout (stdout, QIODevice::WriteOnly);
+QTextStream &qerr()
+{
+ static QTextStream result(stderr, QIODevice::WriteOnly);
+ return result;
+}
+
+QTextStream &qout()
+{
+ static QTextStream result(stdout, QIODevice::WriteOnly);
+ return result;
+}
bool operator < (Name a, Name b)
{
@@ -233,8 +242,9 @@ void Grammar::buildExtendedGrammar ()
non_terminals.insert (accept_symbol);
}
-struct Nullable: public std::unary_function<Name, bool>
+struct Nullable
{
+ typedef Name argument_type;
Automaton *_M_automaton;
Nullable (Automaton *aut):
@@ -303,7 +313,7 @@ void Automaton::buildNullables ()
}
#ifndef QLALR_NO_DEBUG_NULLABLES
- qerr << "nullables = {" << nullables << endl;
+ qerr() << "nullables = {" << nullables << endl;
#endif
}
@@ -446,7 +456,7 @@ void Automaton::buildLookbackSets ()
lookbacks.insert (item, Lookback (p, A));
#ifndef QLALR_NO_DEBUG_LOOKBACKS
- qerr << "*** (" << id (q) << ", " << *rule << ") lookback (" << id (p) << ", " << *A << ")" << endl;
+ qerr() << "*** (" << id (q) << ", " << *rule << ") lookback (" << id (p) << ", " << *A << ")" << endl;
#endif
}
}
@@ -477,7 +487,7 @@ void Automaton::buildDirectReads ()
#ifndef QLALR_NO_DEBUG_DIRECT_READS
for (QMap<Name, NameSet>::iterator dr = q->reads.begin (); dr != q->reads.end (); ++dr)
- qerr << "*** DR(" << id (q) << ", " << dr.key () << ") = " << dr.value () << endl;
+ qerr() << "*** DR(" << id (q) << ", " << dr.key () << ") = " << dr.value () << endl;
#endif
}
}
@@ -506,11 +516,11 @@ void Automaton::buildReadsDigraph ()
source->insertEdge (target);
#ifndef QLALR_NO_DEBUG_READS
- qerr << "*** ";
- dump (qerr, source);
- qerr << " reads ";
- dump (qerr, target);
- qerr << endl;
+ qerr() << "*** ";
+ dump (qerr(), source);
+ qerr() << " reads ";
+ dump (qerr(), target);
+ qerr() << endl;
#endif
}
}
@@ -545,7 +555,7 @@ void Automaton::visitReadNode (ReadNode node)
_M_reads_stack.push (node);
#ifndef QLALR_NO_DEBUG_INCLUDES
- // qerr << "*** Debug. visit node (" << id (node->data.state) << ", " << node->data.nt << ") N = " << N << endl;
+ // qerr() << "*** Debug. visit node (" << id (node->data.state) << ", " << node->data.nt << ") N = " << N << endl;
#endif
for (ReadsGraph::edge_iterator edge = node->begin (); edge != node->end (); ++edge)
@@ -625,7 +635,7 @@ void Automaton::buildIncludesDigraph ()
source->insertEdge (target);
#ifndef QLALR_NO_DEBUG_INCLUDES
- qerr << "*** (" << id (p) << ", " << *A << ") includes (" << id (pp) << ", " << *name << ")" << endl;
+ qerr() << "*** (" << id (p) << ", " << *A << ") includes (" << id (pp) << ", " << *name << ")" << endl;
#endif // QLALR_NO_DEBUG_INCLUDES
continue;
@@ -647,7 +657,7 @@ void Automaton::buildIncludesDigraph ()
source->insertEdge (target);
#ifndef QLALR_NO_DEBUG_INCLUDES
- qerr << "*** (" << id (p) << ", " << *A << ") includes (" << id (pp) << ", " << *name << ")" << endl;
+ qerr() << "*** (" << id (p) << ", " << *A << ") includes (" << id (pp) << ", " << *name << ")" << endl;
#endif // QLALR_NO_DEBUG_INCLUDES
}
}
@@ -664,7 +674,7 @@ void Automaton::visitIncludeNode (IncludeNode node)
_M_includes_stack.push (node);
#ifndef QLALR_NO_DEBUG_INCLUDES
- // qerr << "*** Debug. visit node (" << id (node->data.state) << ", " << node->data.nt << ") N = " << N << endl;
+ // qerr() << "*** Debug. visit node (" << id (node->data.state) << ", " << node->data.nt << ") N = " << N << endl;
#endif
for (IncludesGraph::edge_iterator edge = node->begin (); edge != node->end (); ++edge)
@@ -676,11 +686,11 @@ void Automaton::visitIncludeNode (IncludeNode node)
node->dfn = qMin (N, r->dfn);
#ifndef QLALR_NO_DEBUG_INCLUDES
- qerr << "*** Merge. follows";
- dump (qerr, node);
- qerr << " += follows";
- dump (qerr, r);
- qerr << endl;
+ qerr() << "*** Merge. follows";
+ dump (qerr(), node);
+ qerr() << " += follows";
+ dump (qerr(), r);
+ qerr() << endl;
#endif
NameSet &dst = node->data.state->follows [node->data.nt];
@@ -714,9 +724,9 @@ void Automaton::buildLookaheads ()
StatePointer q = lookback.state;
#ifndef QLALR_NO_DEBUG_LOOKAHEADS
- qerr << "(" << id (p) << ", " << *item->rule << ") lookbacks ";
- dump (qerr, lookback);
- qerr << " with follows (" << id (q) << ", " << lookback.nt << ") = " << q->follows [lookback.nt] << endl;
+ qerr() << "(" << id (p) << ", " << *item->rule << ") lookbacks ";
+ dump (qerr(), lookback);
+ qerr() << " with follows (" << id (q) << ", " << lookback.nt << ") = " << q->follows [lookback.nt] << endl;
#endif
lookaheads [item].insert (q->follows [lookback.nt].begin (), q->follows [lookback.nt].end ());
diff --git a/src/tools/qlalr/lalr.g b/src/tools/qlalr/lalr.g
index 5e335c5a3b..05d30c21fd 100644
--- a/src/tools/qlalr/lalr.g
+++ b/src/tools/qlalr/lalr.g
@@ -261,7 +261,7 @@ int Recognizer::nextToken()
if (ch == QLatin1Char ('"'))
inp ();
else
- qerr << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << endl;
_M_current_value = text;
return (token = STRING_LITERAL);
@@ -314,7 +314,7 @@ int Recognizer::nextToken()
return (token = PREC);
else
{
- qerr << _M_input_file << ":" << _M_line << ": Unknown keyword `" << text << "'" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Unknown keyword `" << text << "'" << endl;
exit (EXIT_FAILURE);
return (token = ERROR);
}
@@ -439,7 +439,7 @@ bool Recognizer::parse (const QString &input_file)
QFile file(_M_input_file);
if (! file.open(QFile::ReadOnly))
{
- qerr << "qlalr: no input file\n";
+ qerr() << "qlalr: no input file\n";
return false;
}
@@ -659,7 +659,7 @@ case $rule_number: {
if (_M_grammar->terminals.find (_M_current_rule->lhs) != _M_grammar->terminals.end ())
{
- qerr << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl;
return false;
}
@@ -683,7 +683,7 @@ case $rule_number: {
if (_M_grammar->terminals.find (_M_current_rule->lhs) != _M_grammar->terminals.end ())
{
- qerr << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl;
return false;
}
@@ -712,7 +712,7 @@ case $rule_number: {
Name tok = _M_grammar->intern (sym(2));
if (! _M_grammar->isTerminal (tok))
{
- qerr << _M_input_file << ":" << _M_line << ": `" << *tok << " is not a terminal symbol" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": `" << *tok << " is not a terminal symbol" << endl;
_M_current_rule->prec = _M_grammar->names.end ();
}
else
@@ -758,7 +758,7 @@ case $rule_number: {
}
}
- qerr << _M_input_file << ":" << _M_line << ": Syntax error" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Syntax error" << endl;
return false;
}
diff --git a/src/tools/qlalr/lalr.h b/src/tools/qlalr/lalr.h
index b303b897d4..6a2baaa462 100644
--- a/src/tools/qlalr/lalr.h
+++ b/src/tools/qlalr/lalr.h
@@ -501,9 +501,8 @@ QTextStream &operator << (QTextStream &out, const Item &item);
QTextStream &operator << (QTextStream &out, const NameSet &ns);
QT_BEGIN_NAMESPACE
-// ... hmm
-extern QTextStream qerr;
-extern QTextStream qout;
+QTextStream &qerr();
+QTextStream &qout();
QT_END_NAMESPACE
#endif // LALR_H
diff --git a/src/tools/qlalr/main.cpp b/src/tools/qlalr/main.cpp
index c16bdcdf17..5971eb201d 100644
--- a/src/tools/qlalr/main.cpp
+++ b/src/tools/qlalr/main.cpp
@@ -44,7 +44,7 @@
static void help_me ()
{
- qerr << "Usage: qlalr [options] [input file name]" << endl
+ qerr() << "Usage: qlalr [options] [input file name]" << endl
<< endl
<< " --help, -h\t\tdisplay this help and exit" << endl
<< " --verbose, -v\t\tverbose output" << endl
@@ -91,7 +91,7 @@ int main (int argc, char *argv[])
file_name = arg;
else
- qerr << "*** Warning. Ignore argument `" << arg << "'" << endl;
+ qerr() << "*** Warning. Ignore argument `" << arg << "'" << endl;
}
if (file_name.isEmpty ())
@@ -108,13 +108,13 @@ int main (int argc, char *argv[])
if (grammar.rules.isEmpty ())
{
- qerr << "*** Fatal. No rules!" << endl;
+ qerr() << "*** Fatal. No rules!" << endl;
exit (EXIT_FAILURE);
}
else if (grammar.start == grammar.names.end ())
{
- qerr << "*** Fatal. No start symbol!" << endl;
+ qerr() << "*** Fatal. No start symbol!" << endl;
exit (EXIT_FAILURE);
}
@@ -131,13 +131,13 @@ int main (int argc, char *argv[])
if (generate_dot)
{
- DotGraph genDotFile (qout);
+ DotGraph genDotFile (qout());
genDotFile (&aut);
}
else if (generate_report)
{
- ParseTable genParseTable (qout);
+ ParseTable genParseTable (qout());
genParseTable(&aut);
}
diff --git a/src/tools/qlalr/recognizer.cpp b/src/tools/qlalr/recognizer.cpp
index 8c7665f1b9..ab797c85d0 100644
--- a/src/tools/qlalr/recognizer.cpp
+++ b/src/tools/qlalr/recognizer.cpp
@@ -97,7 +97,7 @@ int Recognizer::nextToken()
if (ch == QLatin1Char ('"'))
inp ();
else
- qerr << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << endl;
_M_current_value = text;
return (token = STRING_LITERAL);
@@ -150,7 +150,7 @@ int Recognizer::nextToken()
return (token = PREC);
else
{
- qerr << _M_input_file << ":" << _M_line << ": Unknown keyword `" << text << "'" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Unknown keyword `" << text << "'" << endl;
exit (EXIT_FAILURE);
return (token = ERROR);
}
@@ -275,7 +275,7 @@ bool Recognizer::parse (const QString &input_file)
QFile file(_M_input_file);
if (! file.open(QFile::ReadOnly))
{
- qerr << "qlalr: no input file\n";
+ qerr() << "qlalr: no input file\n";
return false;
}
@@ -405,7 +405,7 @@ case 34: {
if (_M_grammar->terminals.find (_M_current_rule->lhs) != _M_grammar->terminals.end ())
{
- qerr << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl;
return false;
}
@@ -420,7 +420,7 @@ case 38: {
if (_M_grammar->terminals.find (_M_current_rule->lhs) != _M_grammar->terminals.end ())
{
- qerr << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Invalid non terminal `" << *_M_current_rule->lhs << "'" << endl;
return false;
}
@@ -443,7 +443,7 @@ case 40: {
Name tok = _M_grammar->intern (sym(2));
if (! _M_grammar->isTerminal (tok))
{
- qerr << _M_input_file << ":" << _M_line << ": `" << *tok << " is not a terminal symbol" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": `" << *tok << " is not a terminal symbol" << endl;
_M_current_rule->prec = _M_grammar->names.end ();
}
else
@@ -474,7 +474,7 @@ case 43: {
}
}
- qerr << _M_input_file << ":" << _M_line << ": Syntax error" << endl;
+ qerr() << _M_input_file << ":" << _M_line << ": Syntax error" << endl;
return false;
}
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 6f0e436ae0..5ef304c9f1 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -79,7 +79,9 @@ QVistaBackButton::QVistaBackButton(QWidget *widget)
{
setFocusPolicy(Qt::NoFocus);
// Native dialogs use ALT-Left even in RTL mode, so do the same, even if it might be counter-intuitive.
+#if QT_CONFIG(shortcut)
setShortcut(QKeySequence(Qt::ALT | Qt::Key_Left));
+#endif
}
QSize QVistaBackButton::sizeHint() const
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 0d434c7097..404bebd40c 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -130,6 +130,7 @@ QT_BEGIN_NAMESPACE
}
Q_CORE_EXPORT void qt_call_post_routines();
+Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1);
QApplicationPrivate *QApplicationPrivate::self = 0;
@@ -3068,8 +3069,19 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
switch (e->type()) {
case QEvent::KeyPress: {
- int key = static_cast<QKeyEvent*>(e)->key();
- qt_in_tab_key_event = (key == Qt::Key_Backtab
+ QKeyEvent* keyEvent = static_cast<QKeyEvent*>(e);
+ const int key = keyEvent->key();
+ // When a key press is received which is not spontaneous then it needs to
+ // be manually sent as a shortcut override event to ensure that any
+ // matching shortcut is triggered first. This enables emulation/playback
+ // of recorded events to still have the same effect.
+ if (!e->spontaneous() && receiver->isWidgetType()) {
+ if (qt_sendShortcutOverrideEvent(qobject_cast<QWidget *>(receiver), keyEvent->timestamp(),
+ key, keyEvent->modifiers(), keyEvent->text(),
+ keyEvent->isAutoRepeat(), keyEvent->count()))
+ return true;
+ }
+ qt_in_tab_key_event = (key == Qt::Key_Backtab
|| key == Qt::Key_Tab
|| key == Qt::Key_Left
|| key == Qt::Key_Up
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 8a5b863bb5..595ff3eb6e 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -1559,8 +1559,6 @@ QFormLayout::TakeRowResult QFormLayout::takeRow(int row)
QFormLayoutItem *label = d->m_matrix(row, 0);
QFormLayoutItem *field = d->m_matrix(row, 1);
- Q_ASSERT(field);
-
d->m_things.removeOne(label);
d->m_things.removeOne(field);
d->m_matrix.removeRow(row);
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index f3db4f4e2d..9ce1c1c2d4 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -44,7 +44,9 @@
#if QT_CONFIG(menubar)
#include "qmenubar.h"
#endif
+#if QT_CONFIG(toolbar)
#include "qtoolbar.h"
+#endif
#if QT_CONFIG(sizegrip)
#include "qsizegrip.h"
#endif
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 52640daf55..25890e888b 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -44,7 +44,9 @@
#if QT_CONFIG(menubar)
#include "qmenubar.h"
#endif
+#if QT_CONFIG(toolbar)
#include "qtoolbar.h"
+#endif
#include "qevent.h"
#include "qstyle.h"
#include "qvariant.h"
diff --git a/src/widgets/kernel/qmacgesturerecognizer.cpp b/src/widgets/kernel/qmacgesturerecognizer.cpp
index 6dedd3c2d0..d39b93e320 100644
--- a/src/widgets/kernel/qmacgesturerecognizer.cpp
+++ b/src/widgets/kernel/qmacgesturerecognizer.cpp
@@ -43,6 +43,7 @@
#include "qevent.h"
#include "qwidget.h"
#include "qdebug.h"
+#include <QtCore/qcoreapplication.h>
#ifndef QT_NO_GESTURES
@@ -181,6 +182,16 @@ QGesture *QMacPanGestureRecognizer::create(QObject *target)
return 0;
}
+void QMacPanGestureRecognizer::timerEvent(QTimerEvent *ev)
+{
+ if (ev->timerId() == _panTimer.timerId()) {
+ if (_panTimer.isActive())
+ _panTimer.stop();
+ if (_target)
+ QCoreApplication::sendEvent(_target, ev);
+ }
+}
+
QGestureRecognizer::Result
QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *event)
{
@@ -195,7 +206,8 @@ QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *
if (ev->touchPoints().size() == 1) {
reset(gesture);
_startPos = QCursor::pos();
- _panTimer.start(panBeginDelay, target);
+ _target = target;
+ _panTimer.start(panBeginDelay, this);
_panCanceled = false;
return QGestureRecognizer::MayBeGesture;
}
@@ -242,7 +254,6 @@ QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *
case QEvent::Timer: {
QTimerEvent *ev = static_cast<QTimerEvent *>(event);
if (ev->timerId() == _panTimer.timerId()) {
- _panTimer.stop();
if (_panCanceled)
break;
// Begin new pan session!
diff --git a/src/widgets/kernel/qmacgesturerecognizer_p.h b/src/widgets/kernel/qmacgesturerecognizer_p.h
index be3f3266ac..e381a6cc2f 100644
--- a/src/widgets/kernel/qmacgesturerecognizer_p.h
+++ b/src/widgets/kernel/qmacgesturerecognizer_p.h
@@ -55,6 +55,7 @@
#include "qtimer.h"
#include "qpoint.h"
#include "qgesturerecognizer.h"
+#include <QtCore/qpointer.h>
#ifndef QT_NO_GESTURES
@@ -88,10 +89,13 @@ public:
QGesture *create(QObject *target);
QGestureRecognizer::Result recognize(QGesture *gesture, QObject *watched, QEvent *event);
void reset(QGesture *gesture);
+protected:
+ void timerEvent(QTimerEvent *ev) override;
private:
QPointF _startPos;
QBasicTimer _panTimer;
bool _panCanceled;
+ QPointer<QObject> _target;
};
QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index c347ca0b59..a86834002c 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1677,6 +1677,7 @@ QWidget::~QWidget()
}
}
+ d->wasDeleted = true;
if (d->declarativeData) {
if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
if (QAbstractDeclarativeData::destroyed_qml1)
@@ -8476,7 +8477,7 @@ bool QWidgetPrivate::close_helper(CloseMode mode)
data.is_closing = 1;
QPointer<QWidget> that = q;
- QPointer<QWidget> parentWidget = q->parentWidget();
+ QPointer<QWidget> parentWidget = (q->parentWidget() && !QObjectPrivate::get(q->parentWidget())->wasDeleted) ? q->parentWidget() : nullptr;
bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose);
if (mode != CloseNoEvent) {
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 1078652234..949076b260 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -237,6 +237,7 @@ bool QWidgetWindow::event(QEvent *event)
switch (event->type()) {
case QEvent::Close:
handleCloseEvent(static_cast<QCloseEvent *>(event));
+ QWindow::event(event);
return true;
case QEvent::Enter:
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
index d388327687..097931913e 100644
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -48,6 +48,7 @@
#include <QMdiSubWindow>
#endif
#include <QAbstractScrollArea>
+#include <QPainter>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp
index b452c63551..130260704f 100644
--- a/src/widgets/statemachine/qguistatemachine.cpp
+++ b/src/widgets/statemachine/qguistatemachine.cpp
@@ -251,10 +251,10 @@ static QEvent *cloneEvent(QEvent *e)
return new QWhatsThisClickedEvent(*static_cast<QWhatsThisClickedEvent*>(e));
#endif // QT_CONFIG(whatsthis)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case QEvent::ToolBarChange:
return new QToolBarChangeEvent(*static_cast<QToolBarChangeEvent*>(e));
-#endif //QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
case QEvent::ApplicationActivate:
return new QEvent(*e);
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 557277b9e0..7420bfb3f7 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -81,7 +81,9 @@
#if QT_CONFIG(tabwidget)
#include <qtabwidget.h>
#endif
+#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
+#endif
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
#endif
@@ -276,7 +278,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
}
}
break;
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case PE_PanelMenuBar:
if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
break;
@@ -295,7 +297,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
break;
case PE_PanelToolBar:
break;
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(progressbar)
case PE_IndicatorProgressChunk:
{
@@ -477,7 +479,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
}
break;
#endif // QT_CONFIG(dockwidget)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case PE_IndicatorToolBarHandle:
p->save();
p->translate(opt->rect.x(), opt->rect.y());
@@ -515,7 +517,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0);
break;
}
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(spinbox)
case PE_IndicatorSpinPlus:
case PE_IndicatorSpinMinus: {
@@ -2153,7 +2155,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
}
break;
#endif // QT_CONFIG(combobox)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case CE_ToolBar:
if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
// Compatibility with styles that use PE_PanelToolBar
@@ -2169,7 +2171,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
&toolBar->palette.brush(QPalette::Button));
}
break;
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
case CE_ColumnViewGrip: {
// draw background gradients
QLinearGradient g(0, 0, opt->rect.width(), 0);
@@ -3072,7 +3074,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
}
break;
#endif // QT_CONFIG(itemviews)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case SE_ToolBarHandle:
if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
if (tbopt->features & QStyleOptionToolBar::Movable) {
@@ -3090,7 +3092,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
}
}
break;
-#endif //QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
default:
break;
}
@@ -4570,7 +4572,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
ret = 0;
break;
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case PM_ToolBarFrameWidth:
ret = 1;
break;
@@ -4594,7 +4596,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
case PM_ToolBarExtensionExtent:
ret = int(QStyleHelper::dpiScaled(12.));
break;
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(tabbar)
case PM_TabBarTabOverlap:
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 0c6825cb36..7474cd23d6 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -3513,7 +3513,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
int frameWidth = 2;
rect = visualRect(option->direction, option->rect, rect);
rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth,
- option->rect.width() - 19 - 2 * frameWidth,
+ option->rect.width() - int(QStyleHelper::dpiScaled(19)) - 2 * frameWidth,
option->rect.height() - 2 * frameWidth);
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
if (!box->editable) {
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 3666bce205..e7fa26e2d4 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -1040,7 +1040,7 @@ QStyleOptionButton::QStyleOptionButton(int version)
*/
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
/*!
\class QStyleOptionToolBar
\brief The QStyleOptionToolBar class is used to describe the
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index 2880917510..9fbaf34a86 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -296,7 +296,7 @@ typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV3;
#endif // QT_CONFIG(tabbar)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
class Q_WIDGETS_EXPORT QStyleOptionToolBar : public QStyleOption
{
@@ -321,7 +321,7 @@ protected:
Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures)
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
class Q_WIDGETS_EXPORT QStyleOptionProgressBar : public QStyleOption
{
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index e12aeb900b..94509f621e 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -111,7 +111,9 @@
#include "qdrawutil.h"
#include <limits.h>
+#if QT_CONFIG(toolbar)
#include <QtWidgets/qtoolbar.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -1979,7 +1981,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
if (frm->features & QStyleOptionFrame::Flat)
extraClass |= PseudoClass_Flat;
}
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
else if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
if (tb->toolBarArea == Qt::LeftToolBarArea)
extraClass |= PseudoClass_Left;
@@ -1999,7 +2001,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
else if (tb->positionWithinLine == QStyleOptionToolBar::OnlyOne)
extraClass |= PseudoClass_OnlyOne;
}
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(toolbox)
else if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
if (tb->position == QStyleOptionToolBox::OnlyOneTab)
@@ -3594,13 +3596,13 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (rule.hasBorder()) {
rule.drawBorder(p, rule.borderRect(opt->rect));
} else {
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
QStyleOptionToolBar newTb(*tb);
newTb.rect = rule.borderRect(opt->rect);
baseStyle()->drawControl(ce, &newTb, p, w);
}
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
}
return;
@@ -3837,7 +3839,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if(hasStyleRule(w, PseudoElement_HeaderViewSection)) {
QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
if (!subRule.hasNativeBorder() || !subRule.baseStyleCanDraw()
- || subRule.hasBackground() || subRule.hasPalette()) {
+ || subRule.hasBackground() || subRule.hasPalette() || subRule.hasFont) {
ParentStyle::drawControl(ce, opt, p, w);
return;
}
@@ -3874,12 +3876,14 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
QStyleOptionHeader hdr(*header);
QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button);
- QFont oldFont = p->font();
- if (subRule.hasFont)
+ if (subRule.hasFont) {
+ QFont oldFont = p->font();
p->setFont(subRule.font.resolve(p->font()));
- baseStyle()->drawControl(ce, &hdr, p, w);
- if (subRule.hasFont)
+ ParentStyle::drawControl(ce, &hdr, p, w);
p->setFont(oldFont);
+ } else {
+ baseStyle()->drawControl(ce, &hdr, p, w);
+ }
return;
}
break;
@@ -4983,11 +4987,13 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
if (!subRule.hasGeometry()) {
QSize nativeContentsSize;
bool nullIcon = hdr->icon.isNull();
+ const int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w);
int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w);
const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text)
: hdr->fontMetrics.size(0, hdr->text);
- nativeContentsSize.setHeight(qMax(iconSize, txt.height()));
- nativeContentsSize.setWidth(iconSize + txt.width());
+ nativeContentsSize.setHeight(margin + qMax(iconSize, txt.height()) + margin);
+ nativeContentsSize.setWidth((nullIcon ? 0 : margin) + iconSize
+ + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin);
sz = sz.expandedTo(nativeContentsSize);
}
return subRule.size(sz);
@@ -5919,12 +5925,12 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction);
}
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case SE_ToolBarHandle:
if (hasStyleRule(w, PseudoElement_ToolBarHandle))
return ParentStyle::subElementRect(se, opt, w);
break;
-#endif //QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
// On mac we make pixel adjustments to layouts which are not
// desireable when you have custom style sheets on them
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 89011350ec..7c9d917784 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -661,7 +661,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
bool doRestore = false;
switch (pe) {
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case PE_IndicatorToolBarSeparator:
{
QRect rect = opt->rect;
@@ -721,7 +721,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
p->restore();
break;
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
case PE_FrameButtonTool:
case PE_PanelButtonTool: {
QPen oldPen = p->pen();
@@ -1572,7 +1572,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
p->fillRect(opt->rect, fill);
}
break; }
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case CE_ToolBar:
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
// Reserve the beveled appearance only for mainwindow toolbars
@@ -1673,7 +1673,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
break;
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
case CE_ProgressBarContents:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index e70d096e04..04a44e1f37 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -73,7 +73,9 @@
#include <private/qabstractitemmodel_p.h>
#include <private/qabstractscrollarea_p.h>
#include <private/qlineedit_p.h>
+#if QT_CONFIG(completer)
#include <private/qcompleter_p.h>
+#endif
#include <qdebug.h>
#if QT_CONFIG(effects)
# include <private/qeffects_p.h>
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 9f5b739230..d93e71e32f 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -858,7 +858,7 @@ void QDialogButtonBoxPrivate::_q_handleButtonClicked()
if (!guard)
return;
- switch (buttonRole) {
+ switch (QPlatformDialogHelper::ButtonRole(buttonRole)) {
case QPlatformDialogHelper::AcceptRole:
case QPlatformDialogHelper::YesRole:
emit q->accepted();
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 71726eaeee..75289e9d1f 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -53,6 +53,7 @@
#include "qmainwindow.h"
#include "qwidgetanimator_p.h"
#include "qmainwindowlayout_p.h"
+#include "qmenu_p.h"
#include "qdockwidget_p.h"
#include <private/qlayoutengine_p.h>
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index bf0a88e7fb..2014bdabf3 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -45,7 +45,9 @@
#if QT_CONFIG(dockwidget)
#include "qdockwidget.h"
#endif
+#if QT_CONFIG(toolbar)
#include "qtoolbar.h"
+#endif
#include <qapplication.h>
#include <qmenu.h>
@@ -61,7 +63,9 @@
#include <qpainter.h>
#include <private/qwidget_p.h>
+#if QT_CONFIG(toolbar)
#include "qtoolbar_p.h"
+#endif
#include "qwidgetanimator_p.h"
#ifdef Q_OS_OSX
#include <qpa/qplatformnativeinterface.h>
@@ -706,7 +710,7 @@ Qt::DockWidgetArea QMainWindow::corner(Qt::Corner corner) const
{ return d_func()->layout->corner(corner); }
#endif
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
static bool checkToolBarArea(Qt::ToolBarArea area, const char *where)
{
@@ -874,7 +878,7 @@ bool QMainWindow::toolBarBreak(QToolBar *toolbar) const
return d_func()->layout->toolBarBreak(toolbar);
}
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(dockwidget)
@@ -1312,7 +1316,7 @@ bool QMainWindow::event(QEvent *event)
return true;
switch (event->type()) {
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case QEvent::ToolBarChange: {
d->layout->toggleToolBarsVisible();
return true;
@@ -1344,7 +1348,7 @@ bool QMainWindow::event(QEvent *event)
return QWidget::event(event);
}
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
/*!
\property QMainWindow::unifiedTitleAndToolBarOnMac
@@ -1389,7 +1393,7 @@ bool QMainWindow::unifiedTitleAndToolBarOnMac() const
return false;
}
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
/*!
\internal
@@ -1435,7 +1439,7 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event)
break;
}
#endif // QT_CONFIG(dockwidget)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar *>(child)) {
if (tb->parentWidget() != this)
return;
@@ -1506,7 +1510,7 @@ QMenu *QMainWindow::createPopupMenu()
menu->addSeparator();
}
#endif // QT_CONFIG(dockwidget)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
QList<QToolBar *> toolbars = findChildren<QToolBar *>();
if (toolbars.size()) {
if (!menu)
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
index 069683d4ac..8f2a192446 100644
--- a/src/widgets/widgets/qmainwindow.h
+++ b/src/widgets/widgets/qmainwindow.h
@@ -74,7 +74,7 @@ class Q_WIDGETS_EXPORT QMainWindow : public QWidget
Q_PROPERTY(bool dockNestingEnabled READ isDockNestingEnabled WRITE setDockNestingEnabled)
#endif // QT_CONFIG(dockwidget)
Q_PROPERTY(DockOptions dockOptions READ dockOptions WRITE setDockOptions)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
Q_PROPERTY(bool unifiedTitleAndToolBarOnMac READ unifiedTitleAndToolBarOnMac WRITE setUnifiedTitleAndToolBarOnMac)
#endif
@@ -145,7 +145,7 @@ public:
Qt::DockWidgetArea corner(Qt::Corner corner) const;
#endif
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea);
void insertToolBarBreak(QToolBar *before);
@@ -190,7 +190,7 @@ public Q_SLOTS:
void setAnimated(bool enabled);
void setDockNestingEnabled(bool enabled);
#endif
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
void setUnifiedTitleAndToolBarOnMac(bool set);
#endif
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index d4ce0ffa4c..43c22910f9 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -45,10 +45,12 @@
#include "qdockwidget.h"
#include "qdockwidget_p.h"
#endif
+#if QT_CONFIG(toolbar)
#include "qtoolbar_p.h"
-#include "qmainwindow.h"
#include "qtoolbar.h"
#include "qtoolbarlayout_p.h"
+#endif
+#include "qmainwindow.h"
#include "qwidgetanimator_p.h"
#if QT_CONFIG(rubberband)
#include "qrubberband.h"
@@ -75,6 +77,7 @@
# include <qtextstream.h>
#endif
+#include <private/qmenu_p.h>
#include <private/qapplication_p.h>
#include <private/qlayoutengine_p.h>
#include <private/qwidgetresizehandler_p.h>
@@ -604,7 +607,7 @@ void QDockWidgetGroupWindow::apply()
QMainWindowLayoutState::QMainWindowLayoutState(QMainWindow *win)
:
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
toolBarAreaLayout(win),
#endif
#if QT_CONFIG(dockwidget)
@@ -629,9 +632,9 @@ QSize QMainWindowLayoutState::sizeHint() const
result = centralWidgetItem->sizeHint();
#endif
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
result = toolBarAreaLayout.sizeHint(result);
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
return result;
}
@@ -647,16 +650,16 @@ QSize QMainWindowLayoutState::minimumSize() const
result = centralWidgetItem->minimumSize();
#endif
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
result = toolBarAreaLayout.minimumSize(result);
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
return result;
}
void QMainWindowLayoutState::apply(bool animated)
{
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
toolBarAreaLayout.apply(animated);
#endif
@@ -675,12 +678,12 @@ void QMainWindowLayoutState::apply(bool animated)
void QMainWindowLayoutState::fitLayout()
{
QRect r;
-#ifdef QT_NO_TOOLBAR
+#if !QT_CONFIG(toolbar)
r = rect;
#else
toolBarAreaLayout.rect = rect;
r = toolBarAreaLayout.fitLayout();
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(dockwidget)
dockAreaLayout.rect = r;
@@ -692,7 +695,7 @@ void QMainWindowLayoutState::fitLayout()
void QMainWindowLayoutState::deleteAllLayoutItems()
{
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
toolBarAreaLayout.deleteAllLayoutItems();
#endif
@@ -714,7 +717,7 @@ void QMainWindowLayoutState::deleteCentralWidgetItem()
QLayoutItem *QMainWindowLayoutState::itemAt(int index, int *x) const
{
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (QLayoutItem *ret = toolBarAreaLayout.itemAt(x, index))
return ret;
#endif
@@ -732,7 +735,7 @@ QLayoutItem *QMainWindowLayoutState::itemAt(int index, int *x) const
QLayoutItem *QMainWindowLayoutState::takeAt(int index, int *x)
{
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (QLayoutItem *ret = toolBarAreaLayout.takeAt(x, index))
return ret;
#endif
@@ -755,7 +758,7 @@ QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const
{
QList<int> result;
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
// is it a toolbar?
if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
result = toolBarAreaLayout.indexOf(toolBar);
@@ -790,7 +793,7 @@ bool QMainWindowLayoutState::contains(QWidget *widget) const
return true;
#endif
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (!toolBarAreaLayout.indexOf(widget).isEmpty())
return true;
#endif
@@ -833,7 +836,7 @@ QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,
{
QList<int> result;
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
// is it a toolbar?
if (qobject_cast<QToolBar*>(widget) != 0) {
result = toolBarAreaLayout.gapIndex(pos);
@@ -871,7 +874,7 @@ bool QMainWindowLayoutState::insertGap(const QList<int> &path, QLayoutItem *item
int i = path.first();
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (i == 0) {
Q_ASSERT(qobject_cast<QToolBar*>(item->widget()) != 0);
return toolBarAreaLayout.insertGap(path.mid(1), item);
@@ -892,7 +895,7 @@ void QMainWindowLayoutState::remove(const QList<int> &path)
{
int i = path.first();
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (i == 0)
toolBarAreaLayout.remove(path.mid(1));
#endif
@@ -905,7 +908,7 @@ void QMainWindowLayoutState::remove(const QList<int> &path)
void QMainWindowLayoutState::remove(QLayoutItem *item)
{
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
toolBarAreaLayout.remove(item);
#endif
@@ -921,7 +924,7 @@ void QMainWindowLayoutState::remove(QLayoutItem *item)
void QMainWindowLayoutState::clear()
{
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
toolBarAreaLayout.clear();
#endif
@@ -943,7 +946,7 @@ QLayoutItem *QMainWindowLayoutState::item(const QList<int> &path)
{
int i = path.first();
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (i == 0) {
const QToolBarAreaLayoutItem *tbItem = toolBarAreaLayout.item(path.mid(1));
Q_ASSERT(tbItem);
@@ -963,7 +966,7 @@ QRect QMainWindowLayoutState::itemRect(const QList<int> &path) const
{
int i = path.first();
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (i == 0)
return toolBarAreaLayout.itemRect(path.mid(1));
#endif
@@ -980,7 +983,7 @@ QRect QMainWindowLayoutState::gapRect(const QList<int> &path) const
{
int i = path.first();
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (i == 0)
return toolBarAreaLayout.itemRect(path.mid(1));
#endif
@@ -997,7 +1000,7 @@ QLayoutItem *QMainWindowLayoutState::plug(const QList<int> &path)
{
int i = path.first();
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (i == 0)
return toolBarAreaLayout.plug(path.mid(1));
#endif
@@ -1014,7 +1017,7 @@ QLayoutItem *QMainWindowLayoutState::unplug(const QList<int> &path, QMainWindowL
{
int i = path.first();
-#ifdef QT_NO_TOOLBAR
+#if !QT_CONFIG(toolbar)
Q_UNUSED(other);
#else
if (i == 0)
@@ -1045,7 +1048,7 @@ void QMainWindowLayoutState::saveState(QDataStream &stream) const
}
#endif
#endif
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
toolBarAreaLayout.saveState(stream);
#endif
}
@@ -1092,7 +1095,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
stream >> marker;
switch(marker)
{
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case QToolBarAreaLayout::ToolBarStateMarker:
case QToolBarAreaLayout::ToolBarStateMarkerEx:
{
@@ -1102,7 +1105,7 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
}
}
break;
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
#if QT_CONFIG(dockwidget)
case QDockAreaLayout::DockWidgetStateMarker:
@@ -1211,7 +1214,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
#endif // QT_CONFIG(tabwidget)
#endif // QT_CONFIG(dockwidget)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
case QToolBarAreaLayout::ToolBarStateMarker:
case QToolBarAreaLayout::ToolBarStateMarkerEx:
{
@@ -1232,7 +1235,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
}
}
break;
-#endif //QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
default:
return false;
}// switch
@@ -1246,7 +1249,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
** QMainWindowLayoutState - toolbars
*/
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
static inline void validateToolBarArea(Qt::ToolBarArea &area)
{
@@ -1421,7 +1424,7 @@ void QMainWindowLayout::toggleToolBarsVisible()
}
}
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
/******************************************************************************
** QMainWindowLayoutState - dock areas
@@ -1904,7 +1907,7 @@ QLayoutItem *QMainWindowLayout::takeAt(int index)
layoutState.remove(ret);
}
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) {
currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex();
if (!currentGapPos.isEmpty()) {
@@ -2016,7 +2019,7 @@ void QMainWindowLayout::setCurrentHoveredFloat(QDockWidgetGroupWindow *w)
static void fixToolBarOrientation(QLayoutItem *item, int dockPos)
{
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
QToolBar *toolBar = qobject_cast<QToolBar*>(item->widget());
if (toolBar == 0)
return;
@@ -2143,7 +2146,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
{
//this function is called from within the Widget Animator whenever an animation is finished
//on a certain widget
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
QToolBarLayout *tbl = qobject_cast<QToolBarLayout*>(tb->layout());
if (tbl->animating) {
@@ -2214,7 +2217,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
dw->d_func()->plug(currentGapRect);
}
#endif
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
tb->d_func()->plug(currentGapRect);
#endif
@@ -2460,7 +2463,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
}
}
#endif // QT_CONFIG(dockwidget)
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
tb->d_func()->unplug(r);
}
@@ -2606,7 +2609,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
if (qobject_cast<QDockWidgetGroupWindow *>(widget))
allowed = true;
#endif
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
allowed = tb->isAreaAllowed(toToolBarArea(path.at(1)));
#endif
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 53e045aaae..4ccfb1786e 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -69,7 +69,9 @@
#if QT_CONFIG(dockwidget)
#include "qdockarealayout_p.h"
#endif
+#if QT_CONFIG(toolbar)
#include "qtoolbararealayout_p.h"
+#endif
QT_REQUIRE_CONFIG(mainwindow);
@@ -89,13 +91,15 @@ public:
QList<int> hoverSeparator;
QPoint hoverPos;
-#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
+#if QT_CONFIG(dockwidget)
+#if QT_CONFIG(cursor)
QCursor separatorCursor(const QList<int> &path);
void adjustCursor(const QPoint &pos);
QCursor oldCursor;
QCursor adjustedCursor;
bool hasOldCursor = false;
bool cursorAdjusted = false;
+#endif // QT_CONFIG(cursor)
QList<int> movingSeparator;
QPoint movingSeparatorOrigin, movingSeparatorPos;
@@ -105,12 +109,12 @@ public:
bool separatorMove(const QPoint &pos);
bool endSeparatorMove(const QPoint &pos);
-#endif
+#endif // QT_CONFIG(dockwidget)
bool windowEvent(QEvent *e);
};
-#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
+#if QT_CONFIG(dockwidget) && QT_CONFIG(cursor)
template <typename Layout>
QCursor QMainWindowLayoutSeparatorHelper<Layout>::separatorCursor(const QList<int> &path)
{
@@ -183,12 +187,14 @@ void QMainWindowLayoutSeparatorHelper<Layout>::adjustCursor(const QPoint &pos)
}
}
}
+#endif // QT_CONFIG(cursor) && QT_CONFIG(dockwidget)
template <typename Layout>
bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
{
QWidget *w = window();
switch (event->type()) {
+#if QT_CONFIG(dockwidget)
case QEvent::Paint: {
QPainter p(w);
QRegion r = static_cast<QPaintEvent *>(event)->region();
@@ -196,7 +202,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
break;
}
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
case QEvent::HoverMove: {
adjustCursor(static_cast<QHoverEvent *>(event)->pos());
break;
@@ -212,7 +218,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
case QEvent::ShortcutOverride: // when a menu pops up
adjustCursor(QPoint(0, 0));
break;
-#endif // QT_NO_CURSOR
+#endif // QT_CONFIG(cursor)
case QEvent::MouseButtonPress: {
QMouseEvent *e = static_cast<QMouseEvent *>(event);
@@ -227,7 +233,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
case QEvent::MouseMove: {
QMouseEvent *e = static_cast<QMouseEvent *>(event);
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
adjustCursor(e->pos());
#endif
if (e->buttons() & Qt::LeftButton) {
@@ -251,7 +257,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
break;
}
-#if !defined(QT_NO_CURSOR)
+#if QT_CONFIG(cursor)
case QEvent::CursorChange:
// CursorChange events are triggered as mouse moves to new widgets even
// if the cursor doesn't actually change, so do not change oldCursor if
@@ -264,7 +270,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
w->setCursor(adjustedCursor);
}
break;
-#endif
+#endif // QT_CONFIG(cursor)
case QEvent::Timer:
if (static_cast<QTimerEvent *>(event)->timerId() == separatorMoveTimer.timerId()) {
// let's move the separators
@@ -284,12 +290,14 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
return true;
}
break;
+#endif // QT_CONFIG(dockwidget)
default:
break;
}
return false;
}
+#if QT_CONFIG(dockwidget)
template <typename Layout>
bool QMainWindowLayoutSeparatorHelper<Layout>::startSeparatorMove(const QPoint &pos)
{
@@ -321,9 +329,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::endSeparatorMove(const QPoint &)
layout()->savedState.clear();
return true;
}
-#endif
-#if QT_CONFIG(dockwidget)
class QDockWidgetGroupWindow : public QWidget
{
Q_OBJECT
@@ -369,7 +375,7 @@ public:
private:
QLayout *lay() const { return const_cast<QDockWidgetGroupWindowItem *>(this)->widget()->layout(); }
};
-#endif
+#endif // QT_CONFIG(dockwidget)
/* This data structure represents the state of all the tool-bars and dock-widgets. It's value based
so it can be easilly copied into a temporary variable. All operations are performed without moving
@@ -385,7 +391,7 @@ public:
QMainWindowLayoutState(QMainWindow *win);
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
QToolBarAreaLayout toolBarAreaLayout;
#endif
@@ -462,7 +468,7 @@ public:
// toolbars
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
void addToolBarBreak(Qt::ToolBarArea area);
void insertToolBarBreak(QToolBar *before);
void removeToolBarBreak(QToolBar *before);
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index b6afb05e3a..721a35bf90 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -68,6 +68,33 @@ QT_REQUIRE_CONFIG(menu);
QT_BEGIN_NAMESPACE
+static inline int pick(Qt::Orientation o, const QPoint &pos)
+{ return o == Qt::Horizontal ? pos.x() : pos.y(); }
+
+static inline int pick(Qt::Orientation o, const QSize &size)
+{ return o == Qt::Horizontal ? size.width() : size.height(); }
+
+static inline int &rpick(Qt::Orientation o, QPoint &pos)
+{ return o == Qt::Horizontal ? pos.rx() : pos.ry(); }
+
+static inline int &rpick(Qt::Orientation o, QSize &size)
+{ return o == Qt::Horizontal ? size.rwidth() : size.rheight(); }
+
+static inline QSizePolicy::Policy pick(Qt::Orientation o, const QSizePolicy &policy)
+{ return o == Qt::Horizontal ? policy.horizontalPolicy() : policy.verticalPolicy(); }
+
+static inline int perp(Qt::Orientation o, const QPoint &pos)
+{ return o == Qt::Vertical ? pos.x() : pos.y(); }
+
+static inline int perp(Qt::Orientation o, const QSize &size)
+{ return o == Qt::Vertical ? size.width() : size.height(); }
+
+static inline int &rperp(Qt::Orientation o, QPoint &pos)
+{ return o == Qt::Vertical ? pos.rx() : pos.ry(); }
+
+static inline int &rperp(Qt::Orientation o, QSize &size)
+{ return o == Qt::Vertical ? size.rwidth() : size.rheight(); }
+
class QTornOffMenu;
class QEventLoop;
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index b0a75288e8..4758f64c8c 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -52,7 +52,9 @@
#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
#endif
+#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
+#endif
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
#endif
diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp
index afb17f533b..8f7271c2dc 100644
--- a/src/widgets/widgets/qpushbutton.cpp
+++ b/src/widgets/widgets/qpushbutton.cpp
@@ -53,7 +53,9 @@
#include "qpushbutton.h"
#include "qstyle.h"
#include "qstyleoption.h"
+#if QT_CONFIG(toolbar)
#include "qtoolbar.h"
+#endif
#include "qdebug.h"
#include "qlayoutitem.h"
#if QT_CONFIG(dialogbuttonbox)
@@ -596,7 +598,7 @@ QPoint QPushButtonPrivate::adjustedMenuPosition()
Q_Q(QPushButton);
bool horizontal = true;
-#if !defined(QT_NO_TOOLBAR)
+#if QT_CONFIG(toolbar)
QToolBar *tb = qobject_cast<QToolBar*>(parent);
if (tb && tb->orientation() == Qt::Vertical)
horizontal = false;
diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index 894053ec19..df847e4894 100644
--- a/src/widgets/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
@@ -376,7 +376,8 @@ QTabWidget::~QTabWidget()
\fn int QTabWidget::addTab(QWidget *page, const QString &label)
Adds a tab with the given \a page and \a label to the tab widget,
- and returns the index of the tab in the tab bar.
+ and returns the index of the tab in the tab bar. Ownership of \a page
+ is passed on to the QTabWidget.
If the tab's \a label contains an ampersand, the letter following
the ampersand is used as a shortcut for the tab, e.g. if the
@@ -403,7 +404,8 @@ int QTabWidget::addTab(QWidget *child, const QString &label)
\overload
Adds a tab with the given \a page, \a icon, and \a label to the tab
- widget, and returns the index of the tab in the tab bar.
+ widget, and returns the index of the tab in the tab bar. Ownership
+ of \a page is passed on to the QTabWidget.
This function is the same as addTab(), but with an additional \a
icon.
@@ -419,7 +421,8 @@ int QTabWidget::addTab(QWidget *child, const QIcon& icon, const QString &label)
Inserts a tab with the given \a label and \a page into the tab
widget at the specified \a index, and returns the index of the
- inserted tab in the tab bar.
+ inserted tab in the tab bar. Ownership of \a page is passed on to the
+ QTabWidget.
The label is displayed in the tab and may vary in appearance depending
on the configuration of the tab widget.
@@ -458,7 +461,8 @@ int QTabWidget::insertTab(int index, QWidget *w, const QString &label)
Inserts a tab with the given \a label, \a page, and \a icon into
the tab widget at the specified \a index, and returns the index of the
- inserted tab in the tab bar.
+ inserted tab in the tab bar. Ownership of \a page is passed on to the
+ QTabWidget.
This function is the same as insertTab(), but with an additional
\a icon.
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index 7b6a2a329f..4e90bce69d 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -39,8 +39,6 @@
#include "qtoolbar.h"
-#ifndef QT_NO_TOOLBAR
-
#include <qapplication.h>
#if QT_CONFIG(combobox)
#include <qcombobox.h>
@@ -1288,5 +1286,3 @@ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const
QT_END_NAMESPACE
#include "moc_qtoolbar.cpp"
-
-#endif // QT_NO_TOOLBAR
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index 0253541a2e..4ae83190d1 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -44,10 +44,9 @@
#include <QtWidgets/qaction.h>
#include <QtWidgets/qwidget.h>
-QT_BEGIN_NAMESPACE
-
+QT_REQUIRE_CONFIG(toolbar);
-#ifndef QT_NO_TOOLBAR
+QT_BEGIN_NAMESPACE
class QToolBarPrivate;
@@ -211,8 +210,6 @@ private:
inline QAction *QToolBar::actionAt(int ax, int ay) const
{ return actionAt(QPoint(ax, ay)); }
-#endif // QT_NO_TOOLBAR
-
QT_END_NAMESPACE
#endif // QDYNAMICTOOLBAR_H
diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h
index 616f53f717..4db75762c8 100644
--- a/src/widgets/widgets/qtoolbar_p.h
+++ b/src/widgets/widgets/qtoolbar_p.h
@@ -57,9 +57,9 @@
#include "private/qwidget_p.h"
#include <QtCore/qbasictimer.h>
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(toolbar);
-#ifndef QT_NO_TOOLBAR
+QT_BEGIN_NAMESPACE
class QToolBarLayout;
class QTimer;
@@ -127,8 +127,6 @@ public:
QBasicTimer waitForPopupTimer;
};
-#endif // QT_NO_TOOLBAR
-
QT_END_NAMESPACE
#endif // QDYNAMICTOOLBAR_P_H
diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp
index 0c57d9251d..edf497111b 100644
--- a/src/widgets/widgets/qtoolbararealayout.cpp
+++ b/src/widgets/widgets/qtoolbararealayout.cpp
@@ -53,8 +53,6 @@
** QToolBarAreaLayoutItem
*/
-#ifndef QT_NO_TOOLBAR
-
QT_BEGIN_NAMESPACE
// qmainwindow.cpp
@@ -1391,5 +1389,3 @@ bool QToolBarAreaLayout::isEmpty() const
}
QT_END_NAMESPACE
-
-#endif // QT_NO_TOOLBAR
diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h
index 901f04cf14..dffbab1f21 100644
--- a/src/widgets/widgets/qtoolbararealayout_p.h
+++ b/src/widgets/widgets/qtoolbararealayout_p.h
@@ -52,40 +52,14 @@
//
#include <QtWidgets/private/qtwidgetsglobal_p.h>
+#include "qmenu_p.h"
#include <QList>
#include <QSize>
#include <QRect>
-QT_BEGIN_NAMESPACE
-
-static inline int pick(Qt::Orientation o, const QPoint &pos)
-{ return o == Qt::Horizontal ? pos.x() : pos.y(); }
-
-static inline int pick(Qt::Orientation o, const QSize &size)
-{ return o == Qt::Horizontal ? size.width() : size.height(); }
-
-static inline int &rpick(Qt::Orientation o, QPoint &pos)
-{ return o == Qt::Horizontal ? pos.rx() : pos.ry(); }
-
-static inline int &rpick(Qt::Orientation o, QSize &size)
-{ return o == Qt::Horizontal ? size.rwidth() : size.rheight(); }
-
-static inline QSizePolicy::Policy pick(Qt::Orientation o, const QSizePolicy &policy)
-{ return o == Qt::Horizontal ? policy.horizontalPolicy() : policy.verticalPolicy(); }
-
-static inline int perp(Qt::Orientation o, const QPoint &pos)
-{ return o == Qt::Vertical ? pos.x() : pos.y(); }
+QT_REQUIRE_CONFIG(toolbar);
-static inline int perp(Qt::Orientation o, const QSize &size)
-{ return o == Qt::Vertical ? size.width() : size.height(); }
-
-static inline int &rperp(Qt::Orientation o, QPoint &pos)
-{ return o == Qt::Vertical ? pos.rx() : pos.ry(); }
-
-static inline int &rperp(Qt::Orientation o, QSize &size)
-{ return o == Qt::Vertical ? size.rwidth() : size.rheight(); }
-
-#ifndef QT_NO_TOOLBAR
+QT_BEGIN_NAMESPACE
class QToolBar;
class QLayoutItem;
@@ -244,7 +218,6 @@ public:
bool isEmpty() const;
};
-
QT_END_NAMESPACE
-#endif // QT_NO_TOOLBAR
+
#endif // QTOOLBARAREALAYOUT_P_H
diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp
index 118cb2ae61..f2d329d59d 100644
--- a/src/widgets/widgets/qtoolbarlayout.cpp
+++ b/src/widgets/widgets/qtoolbarlayout.cpp
@@ -59,8 +59,6 @@
#include "qtoolbarlayout_p.h"
#include "qtoolbarseparator_p.h"
-#ifndef QT_NO_TOOLBAR
-
QT_BEGIN_NAMESPACE
// qmainwindow.cpp
@@ -753,5 +751,3 @@ QToolBarItem *QToolBarLayout::createItem(QAction *action)
QT_END_NAMESPACE
#include "moc_qtoolbarlayout_p.cpp"
-
-#endif // QT_NO_TOOLBAR
diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h
index 8c60164439..b813cd5e2c 100644
--- a/src/widgets/widgets/qtoolbarlayout_p.h
+++ b/src/widgets/widgets/qtoolbarlayout_p.h
@@ -56,9 +56,9 @@
#include <private/qlayoutengine_p.h>
#include <QVector>
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(toolbar);
-#ifndef QT_NO_TOOLBAR
+QT_BEGIN_NAMESPACE
class QAction;
class QToolBarExtension;
@@ -127,8 +127,6 @@ private:
QMenu *popupMenu;
};
-#endif // QT_NO_TOOLBAR
-
QT_END_NAMESPACE
#endif // QTOOLBARLAYOUT_P_H
diff --git a/src/widgets/widgets/qtoolbarseparator.cpp b/src/widgets/widgets/qtoolbarseparator.cpp
index c99a8bcc4c..92cd08317a 100644
--- a/src/widgets/widgets/qtoolbarseparator.cpp
+++ b/src/widgets/widgets/qtoolbarseparator.cpp
@@ -39,8 +39,6 @@
#include "qtoolbarseparator_p.h"
-#ifndef QT_NO_TOOLBAR
-
#include <qstyle.h>
#include <qstyleoption.h>
#include <qtoolbar.h>
@@ -87,5 +85,3 @@ void QToolBarSeparator::paintEvent(QPaintEvent *)
QT_END_NAMESPACE
#include "moc_qtoolbarseparator_p.cpp"
-
-#endif // QT_NO_TOOLBAR
diff --git a/src/widgets/widgets/qtoolbarseparator_p.h b/src/widgets/widgets/qtoolbarseparator_p.h
index d52b4fa6ae..60b51a28cb 100644
--- a/src/widgets/widgets/qtoolbarseparator_p.h
+++ b/src/widgets/widgets/qtoolbarseparator_p.h
@@ -54,9 +54,9 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qwidget.h"
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(toolbar);
-#ifndef QT_NO_TOOLBAR
+QT_BEGIN_NAMESPACE
class QStyleOption;
class QToolBar;
@@ -80,8 +80,6 @@ public Q_SLOTS:
void setOrientation(Qt::Orientation orientation);
};
-#endif // QT_NO_TOOLBAR
-
QT_END_NAMESPACE
#endif // QDYNAMICTOOLBARSEPARATOR_P_H
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index c2bf13a3e9..c94c10574f 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -53,7 +53,9 @@
#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
#endif
+#if QT_CONFIG(toolbar)
#include <qtoolbar.h>
+#endif
#include <qvariant.h>
#include <qstylepainter.h>
#include <private/qabstractbutton_p.h>
@@ -201,7 +203,7 @@ void QToolButtonPrivate::init()
{
Q_Q(QToolButton);
defaultAction = 0;
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (qobject_cast<QToolBar*>(parent))
autoRaise = true;
else
@@ -245,13 +247,13 @@ void QToolButton::initStyleOption(QStyleOptionToolButton *option) const
bool forceNoText = false;
option->iconSize = iconSize(); //default value
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
if (parentWidget()) {
if (QToolBar *toolBar = qobject_cast<QToolBar *>(parentWidget())) {
option->iconSize = toolBar->iconSize();
}
}
-#endif // QT_NO_TOOLBAR
+#endif // QT_CONFIG(toolbar)
if (!forceNoText)
option->text = d->text;
@@ -571,7 +573,7 @@ void QToolButton::timerEvent(QTimerEvent *e)
*/
void QToolButton::changeEvent(QEvent *e)
{
-#ifndef QT_NO_TOOLBAR
+#if QT_CONFIG(toolbar)
Q_D(QToolButton);
if (e->type() == QEvent::ParentChange) {
if (qobject_cast<QToolBar*>(parentWidget()))
@@ -743,7 +745,7 @@ void QToolButtonPrivate::popupTimerDone()
repeat = q->autoRepeat();
q->setAutoRepeat(false);
bool horizontal = true;
-#if !defined(QT_NO_TOOLBAR)
+#if QT_CONFIG(toolbar)
QToolBar *tb = qobject_cast<QToolBar*>(parent);
if (tb && tb->orientation() == Qt::Vertical)
horizontal = false;
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index d3203e180b..43c1c3e365 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -1977,8 +1977,12 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
cursor.removeSelectedText();
}
+ QTextBlock block;
+
// insert commit string
if (!e->commitString().isEmpty() || e->replacementLength()) {
+ if (e->commitString().endsWith(QChar::LineFeed))
+ block = cursor.block(); // Remember the block where the preedit text is
QTextCursor c = cursor;
c.setPosition(c.position() + e->replacementStart());
c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor);
@@ -1997,7 +2001,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
}
- QTextBlock block = cursor.block();
+ if (!block.isValid())
+ block = cursor.block();
QTextLayout *layout = block.layout();
if (isGettingInput)
layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri
index a197c41b95..55804c5aaf 100644
--- a/src/widgets/widgets/widgets.pri
+++ b/src/widgets/widgets/widgets.pri
@@ -3,25 +3,16 @@
HEADERS += \
widgets/qframe.h \
widgets/qframe_p.h \
- widgets/qtoolbar.h \
- widgets/qtoolbar_p.h \
- widgets/qtoolbarlayout_p.h \
- widgets/qtoolbarseparator_p.h \
widgets/qabstractscrollarea.h \
widgets/qabstractscrollarea_p.h \
widgets/qfocusframe.h \
- widgets/qwidgetanimator_p.h \
- widgets/qtoolbararealayout_p.h
+ widgets/qwidgetanimator_p.h
SOURCES += \
widgets/qframe.cpp \
- widgets/qtoolbar.cpp \
- widgets/qtoolbarlayout.cpp \
- widgets/qtoolbarseparator.cpp \
widgets/qabstractscrollarea.cpp \
widgets/qfocusframe.cpp \
- widgets/qwidgetanimator.cpp \
- widgets/qtoolbararealayout.cpp
+ widgets/qwidgetanimator.cpp
qtConfig(abstractbutton) {
HEADERS += \
@@ -326,6 +317,21 @@ qtConfig(tabwidget) {
SOURCES += widgets/qtabwidget.cpp
}
+qtConfig(toolbar) {
+ HEADERS += \
+ widgets/qtoolbar.h \
+ widgets/qtoolbar_p.h \
+ widgets/qtoolbararealayout_p.h \
+ widgets/qtoolbarlayout_p.h \
+ widgets/qtoolbarseparator_p.h
+
+ SOURCES += \
+ widgets/qtoolbar.cpp \
+ widgets/qtoolbarlayout.cpp \
+ widgets/qtoolbararealayout.cpp \
+ widgets/qtoolbarseparator.cpp
+}
+
qtConfig(toolbox) {
HEADERS += widgets/qtoolbox.h
SOURCES += widgets/qtoolbox.cpp
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index cd13e2bd19..ad00e25e7d 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -2878,10 +2878,6 @@ void tst_QFile::nativeHandleLeaks()
#endif
QCOMPARE( fd2, fd1 );
-
-#ifdef Q_OS_WIN
- QCOMPARE( handle2, handle1 );
-#endif
}
void tst_QFile::readEof_data()
diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
index 4923baa0ca..fed05698fd 100644
--- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
@@ -104,6 +104,9 @@ void tst_QIODevice::getSetCheck()
//----------------------------------------------------------------------------------
void tst_QIODevice::constructing_QTcpSocket()
{
+#if defined(Q_OS_WINRT)
+ QSKIP("Synchronous socket calls are broken on winrt. See QTBUG-40922");
+#endif
if (!QtNetworkSettings::verifyTestNetworkSettings())
QSKIP("No network test server available");
@@ -263,6 +266,9 @@ void tst_QIODevice::unget()
buffer.ungetChar('Q');
QCOMPARE(buffer.readLine(buf, 3), qint64(1));
+#if defined(Q_OS_WINRT)
+ QSKIP("Synchronous socket calls are broken on winrt. See QTBUG-40922");
+#endif
for (int i = 0; i < 2; ++i) {
QTcpSocket socket;
QIODevice *dev;
diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro
index 7d6a7973dc..63187c9668 100644
--- a/tests/auto/corelib/io/qprocess/test/test.pro
+++ b/tests/auto/corelib/io/qprocess/test/test.pro
@@ -2,6 +2,8 @@ CONFIG += testcase
CONFIG -= debug_and_release_target
QT = core-private testlib network
SOURCES = ../tst_qprocess.cpp
+INCLUDEPATH += ../../../../../shared
+HEADERS += ../../../../../shared/emulationdetector.h
TARGET = ../tst_qprocess
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 6b4d292fe3..e19653abf0 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -27,6 +27,7 @@
**
****************************************************************************/
+#include <emulationdetector.h>
#include <QtTest/QtTest>
#include <QtCore/QProcess>
@@ -1165,6 +1166,8 @@ void tst_QProcess::processInAThread()
void tst_QProcess::processesInMultipleThreads()
{
+ if (EmulationDetector::isRunningArmOnX86())
+ QSKIP("Flakily hangs in QEMU. QTBUG-67760");
for (int i = 0; i < 10; ++i) {
// run from 1 to 10 threads, but run at least some tests
// with more threads than the ideal
diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro
index f937d23fe2..e8071297b1 100644
--- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro
+++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro
@@ -21,3 +21,5 @@ GENERATED_TESTDATA = $${runtime_resource.target}
android:!android-embedded {
RESOURCES += android_testdata.qrc
}
+
+builtin_testdata: DEFINES += BUILTIN_TESTDATA
diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
index ab1866fb2d..b7e85e8f05 100644
--- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
@@ -29,6 +29,7 @@
#include <QtTest/QtTest>
#include <QtCore/QCoreApplication>
+#include <QtCore/QMimeDatabase>
class tst_QResourceEngine: public QObject
{
@@ -125,9 +126,19 @@ void tst_QResourceEngine::checkStructure_data()
rootContents.insert(1, QLatin1String("android_testdata"));
#endif
+#if defined(BUILTIN_TESTDATA)
+ rootContents.insert(8, QLatin1String("testqrc"));
+#endif
+
+
QTest::newRow("root dir") << QString(":/")
<< QString()
- << (QStringList() << "search_file.txt")
+ << (QStringList()
+#if defined(BUILTIN_TESTDATA)
+ << "parentdir.txt"
+ << "runtime_resource.rcc"
+#endif
+ << "search_file.txt")
<< rootContents
<< QLocale::c()
<< qlonglong(0);
@@ -334,6 +345,11 @@ void tst_QResourceEngine::checkStructure()
QFETCH(QLocale, locale);
QFETCH(qlonglong, contentsSize);
+ // We rely on the existence of the root "qt-project.org" in resources. For
+ // static builds on MSVC these resources are only added if they are used.
+ QMimeDatabase db;
+ Q_UNUSED(db);
+
bool directory = (containedDirs.size() + containedFiles.size() > 0);
QLocale::setDefault(locale);
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
index b05e3968ea..6fbaa28d69 100644
--- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -95,6 +95,9 @@ private slots:
void QTBUG58851_data();
void QTBUG58851();
+ void QTBUG18001_data();
+ void QTBUG18001();
+
private:
QAbstractItemModel *model;
QItemSelectionModel *selection;
@@ -2922,5 +2925,98 @@ void tst_QItemSelectionModel::QTBUG58851()
}
}
+void tst_QItemSelectionModel::QTBUG18001_data()
+{
+ using IntPair = std::pair<int, int>;
+ using IntPairList = QList<IntPair>;
+ using IntList = QList<int>;
+ using BoolList = QList<bool>;
+
+ QTest::addColumn<IntPairList>("indexesToSelect");
+ QTest::addColumn<IntList>("selectionCommands");
+ QTest::addColumn<BoolList>("expectedSelectedRows");
+ QTest::addColumn<BoolList>("expectedSelectedColums");
+
+ int colSelect = QItemSelectionModel::Select | QItemSelectionModel::Columns;
+ int rowSelect = QItemSelectionModel::Select | QItemSelectionModel::Rows;
+
+ QTest::newRow("Select column 1")
+ << IntPairList { {0, 1} }
+ << IntList{ colSelect }
+ << BoolList{ false, false, false, false, false }
+ << BoolList{ false, true, false, false, false };
+
+ QTest::newRow("Select row 1")
+ << IntPairList { {1, 0} }
+ << IntList{ rowSelect }
+ << BoolList{ false, true, false, false, false }
+ << BoolList{ false, false, false, false, false };
+
+ QTest::newRow("Select column 1+2, row 1+2")
+ << IntPairList { {0, 1}, {0, 2}, {1, 0}, {2, 0} }
+ << IntList{ colSelect, colSelect, rowSelect, rowSelect }
+ << BoolList{ false, true, true, false, false }
+ << BoolList{ false, true, true, false, false };
+
+ QTest::newRow("Select row 1+2, col 1+2")
+ << IntPairList { {1, 0}, {2, 0}, {0, 1}, {0, 2} }
+ << IntList{ rowSelect, rowSelect, colSelect, colSelect }
+ << BoolList{ false, true, true, false, false }
+ << BoolList{ false, true, true, false, false };
+}
+
+void tst_QItemSelectionModel::QTBUG18001()
+{
+ using IntPair = std::pair<int, int>;
+ using IntPairList = QList<IntPair>;
+ using IntList = QList<int>;
+ using BoolList = QList<bool>;
+
+ QFETCH(IntPairList, indexesToSelect);
+ QFETCH(IntList, selectionCommands);
+ QFETCH(BoolList, expectedSelectedRows);
+ QFETCH(BoolList, expectedSelectedColums);
+
+ QStandardItemModel model(5, 5);
+ for (int row = 0; row < model.rowCount(); ++row) {
+ for (int column = 0; column < model.columnCount(); ++column) {
+ QStandardItem *item = new QStandardItem(QString("%0x%1").arg(row).arg(column));
+ model.setItem(row, column, item);
+
+ const bool oddRow = row % 2;
+ const bool oddCol = column % 2;
+
+ if (oddRow == oddCol)
+ item->setSelectable(false);
+ }
+ }
+
+ QItemSelectionModel selectionModel(&model);
+
+ for (int i = 0; i < indexesToSelect.count(); ++i) {
+ QModelIndex idx = model.index( indexesToSelect.at(i).first, indexesToSelect.at(i).second );
+ selectionModel.select(idx, QItemSelectionModel::SelectionFlag(selectionCommands.at(i)));
+ }
+
+ for (int i = 0; i < expectedSelectedRows.count(); ++i) {
+ const bool expected = expectedSelectedRows.at(i);
+ const bool actual = selectionModel.isRowSelected(i, QModelIndex());
+ QByteArray description = QByteArray("Row ") + QByteArray::number(i)
+ + " Expected " + QByteArray::number(expected)
+ + " Actual " + QByteArray::number(actual);
+ QVERIFY2(expected == actual, description.data());
+ }
+
+ for (int i = 0; i < expectedSelectedColums.count(); ++i) {
+ const bool expected = expectedSelectedColums.at(i);
+ const bool actual = selectionModel.isColumnSelected(i, QModelIndex());
+ QByteArray description = QByteArray("Col ") + QByteArray::number(i)
+ + " Expected " + QByteArray::number(expected)
+ + " Actual " + QByteArray::number(actual);
+ QVERIFY2(expected == actual, description.data());
+ }
+
+}
+
QTEST_MAIN(tst_QItemSelectionModel)
#include "tst_qitemselectionmodel.moc"
diff --git a/tests/auto/corelib/serialization/json/invalidBinaryData/38.bjson b/tests/auto/corelib/serialization/json/invalidBinaryData/38.bjson
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/corelib/serialization/json/invalidBinaryData/38.bjson
diff --git a/tests/auto/corelib/serialization/json/invalidBinaryData/39.bjson b/tests/auto/corelib/serialization/json/invalidBinaryData/39.bjson
new file mode 100644
index 0000000000..c6025aa9eb
--- /dev/null
+++ b/tests/auto/corelib/serialization/json/invalidBinaryData/39.bjson
Binary files differ
diff --git a/tests/auto/corelib/serialization/json/invalidBinaryData/40.bjson b/tests/auto/corelib/serialization/json/invalidBinaryData/40.bjson
new file mode 100644
index 0000000000..277096f8cb
--- /dev/null
+++ b/tests/auto/corelib/serialization/json/invalidBinaryData/40.bjson
Binary files differ
diff --git a/tests/auto/corelib/serialization/json/invalidBinaryData/41.bjson b/tests/auto/corelib/serialization/json/invalidBinaryData/41.bjson
new file mode 100644
index 0000000000..0b5940ab95
--- /dev/null
+++ b/tests/auto/corelib/serialization/json/invalidBinaryData/41.bjson
Binary files differ
diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp
index 99bdd8deb0..41c8f760dc 100644
--- a/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/serialization/json/tst_qtjson.cpp
@@ -1863,6 +1863,7 @@ void tst_QtJson::invalidBinaryData()
QFile file(files.at(i).filePath());
file.open(QIODevice::ReadOnly);
QByteArray bytes = file.readAll();
+ bytes.squeeze();
QJsonDocument document = QJsonDocument::fromRawData(bytes.constData(), bytes.size());
QVERIFY(document.isNull());
}
diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
index ca40927ef9..32e5b8ee56 100644
--- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
+++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
@@ -185,12 +185,10 @@ private Q_SLOTS:
};
template <bool> inline void booleanHelper() { }
-struct TypeInStruct { TEST_TYPE type; };
void tst_QAtomicIntegerXX::static_checks()
{
Q_STATIC_ASSERT(sizeof(QAtomicInteger<T>) == sizeof(T));
- Q_STATIC_ASSERT(Q_ALIGNOF(QAtomicInteger<T>) == Q_ALIGNOF(TypeInStruct));
// statements with no effect
(void) QAtomicInteger<T>::isReferenceCountingNative();
diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp
index 6e020ac35b..ae65d8f697 100644
--- a/tests/auto/corelib/tools/qline/tst_qline.cpp
+++ b/tests/auto/corelib/tools/qline/tst_qline.cpp
@@ -166,9 +166,6 @@ void tst_QLine::testIntersection_data()
<< 100.1599256468622
<< 50.0;
- QLineF baseA(0, -50, 0, 50);
- QLineF baseB(-50, 0, 50, 0);
-
for (int i = 0; i < 1000; ++i) {
QLineF a = QLineF::fromPolar(50, i);
a.setP1(-a.p2());
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index 203d9d8683..ade9c5e754 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -93,6 +93,7 @@ private slots:
void lambdaCustomDeleter();
#endif
void creating();
+ void creatingCvQualified();
void creatingVariadic();
void creatingQObject();
void mixTrackingPointerCode();
@@ -1771,6 +1772,13 @@ void tst_QSharedPointer::creating()
safetyCheck();
}
+void tst_QSharedPointer::creatingCvQualified()
+{
+ auto cptr = QSharedPointer<const Data>::create();
+ auto vptr = QSharedPointer<volatile Data>::create();
+ auto cvptr = QSharedPointer<const volatile Data>::create();
+}
+
void tst_QSharedPointer::creatingVariadic()
{
int i = 42;
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 86cc2cd02f..28014840a3 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -324,10 +324,8 @@ public:
public slots:
void cleanup();
private slots:
-#ifndef Q_CC_HPACC
void fromStdString();
void toStdString();
-#endif
void check_QTextIOStream();
void check_QTextStream();
void check_QDataStream();
@@ -4056,8 +4054,6 @@ void tst_QString::setRawData()
QVERIFY(cstr.data_ptr() != csd);
}
-#ifndef Q_CC_HPACC
-// This test crashes on HP-UX with aCC (not supported)
void tst_QString::fromStdString()
{
std::string stroustrup = "foo";
@@ -4068,10 +4064,7 @@ void tst_QString::fromStdString()
QString qtnull = QString::fromStdString( stdnull );
QCOMPARE( qtnull.size(), int(stdnull.size()) );
}
-#endif
-#ifndef Q_CC_HPACC
-// This test crashes on HP-UX with aCC (not supported)
void tst_QString::toStdString()
{
QString nord = "foo";
@@ -4088,7 +4081,6 @@ void tst_QString::toStdString()
std::string stdnull = qtnull.toStdString();
QCOMPARE( int(stdnull.size()), qtnull.size() );
}
-#endif
void tst_QString::utf8()
{
diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST
index cd1cb99c3c..70091121bc 100644
--- a/tests/auto/gui/kernel/qwindow/BLACKLIST
+++ b/tests/auto/gui/kernel/qwindow/BLACKLIST
@@ -3,8 +3,6 @@ linux
osx-10.12 ci
[positioning:fake]
osx-10.12 ci
-[modalWindowPosition]
-ubuntu-16.04
[modalWithChildWindow]
ubuntu-16.04
# QTBUG-66851
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 5a87ae6067..722405377e 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -588,6 +588,9 @@ void tst_QWindow::childWindowPositioning_data()
void tst_QWindow::childWindowPositioning()
{
+ if (isPlatformWayland())
+ QSKIP("Wayland: This is flaky (protocol errors for xdg-shell v6). See QTBUG-67648.");
+
const QPoint topLeftOrigin(0, 0);
ColoredWindow topLevelWindowFirst(Qt::green);
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index ba405e2860..181c609c6e 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -2963,10 +2963,6 @@ void fpe_steepSlopes()
void fpe_radialGradients()
{
-#if defined(Q_PROCESSOR_ARM)
- QEXPECT_FAIL("", "Test fails for ARM (QTBUG-59961)", Continue);
-#endif
-
FpExceptionChecker checker(FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID | FE_DIVBYZERO);
QImage img(21, 21, QImage::Format_ARGB32_Premultiplied);
diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp
index 1620c2ade6..6e18e1a663 100644
--- a/tests/auto/network/access/qftp/tst_qftp.cpp
+++ b/tests/auto/network/access/qftp/tst_qftp.cpp
@@ -2078,8 +2078,6 @@ void tst_QFtp::doneSignal()
if (QTestEventLoop::instance().timeout())
QFAIL("Network operation timed out");
- QTest::qWait(200);
-
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.first().first().toBool(), false);
}
diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index ed5d0c69a0..8b49679042 100644
--- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -164,7 +164,9 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
result.clear();
preset.clear();
cookie.setDomain(".foo.ck");
- QTest::newRow("effective-tld2-denied") << preset << cookie << "http://foo.ck" << result << false;
+ result += cookie;
+ QTest::newRow("effective-tld2-accepted2") << preset << cookie << "http://foo.ck" << result << true;
+ result.clear();
QTest::newRow("effective-tld2-denied2") << preset << cookie << "http://www.foo.ck" << result << false;
QTest::newRow("effective-tld2-denied3") << preset << cookie << "http://www.anything.foo.ck" << result << false;
cookie.setDomain(".www.ck");
@@ -208,6 +210,22 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
preset.clear();
cookie.setDomain(".com.");
QTest::newRow("rfc2109-4.3.2-ex3-2") << preset << cookie << "http://x.foo.com" << result << false;
+
+ // When using a TLD as a hostname the hostname should still get cookies (QTBUG-52040)
+ // ... and nothing else should get the cookies.
+ result.clear();
+ preset.clear();
+ cookie.setPath("/");
+ cookie.setDomain(".support");
+ result += cookie;
+ QTest::newRow("TLD-as-domain-accepted") << preset << cookie << "http://support" << result << true;
+ result.clear();
+ QTest::newRow("TLD-as-domain-rejected") << preset << cookie << "http://a.support" << result << false;
+ // Now test with no domain in the cookie, use the domain from the url (matching TLD)
+ cookie.setDomain("support");
+ result += cookie;
+ cookie.setDomain("");
+ QTest::newRow("TLD-as-domain-accepted2") << preset << cookie << "http://support" << result << true;
}
void tst_QNetworkCookieJar::setCookiesFromUrl()
@@ -351,6 +369,19 @@ void tst_QNetworkCookieJar::cookiesForUrl_data()
result.clear();
result += rootCookie;
QTest::newRow("root-path-match") << allCookies << "http://qt-project.org" << result;
+
+ // Domain in cookie happens to match a TLD
+ allCookies.clear();
+ QNetworkCookie tldCookie;
+ tldCookie.setDomain(".support");
+ tldCookie.setName("a");
+ tldCookie.setValue("b");
+ allCookies += tldCookie;
+ result.clear();
+ result += tldCookie;
+ QTest::newRow("tld-cookie-match") << allCookies << "http://support/" << result;
+ result.clear();
+ QTest::newRow("tld-cookie-no-match") << allCookies << "http://a.support/" << result;
}
void tst_QNetworkCookieJar::cookiesForUrl()
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 69bd78a4f0..0ef3dc0b61 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -7816,13 +7816,14 @@ void tst_QNetworkReply::closeDuringDownload()
QFETCH(QUrl, url);
QNetworkRequest request(url);
QNetworkReply* reply = manager.get(request);
- connect(reply, SIGNAL(readyRead()), &QTestEventLoop::instance(), SLOT(exitLoop()));
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QSignalSpy readyReadSpy(reply, &QNetworkReply::readyRead);
+ QVERIFY(readyReadSpy.wait(10000));
+ QSignalSpy destroySpy(reply, &QObject::destroyed);
reply->close();
reply->deleteLater();
- QTest::qWait(1000); //cancelling ftp takes some time, this avoids a warning caused by test's cleanup() destroying the connection cache before the abort is finished
+ // Wait for destruction to avoid a warning caused by test's cleanup()
+ // destroying the connection cache before the abort is finished
+ QVERIFY(destroySpy.wait());
}
void tst_QNetworkReply::ftpAuthentication_data()
diff --git a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp
index bc9144e40e..50c7ddb0b6 100644
--- a/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp
+++ b/tests/auto/network/access/qnetworkrequest/tst_qnetworkrequest.cpp
@@ -373,6 +373,9 @@ void tst_QNetworkRequest::rawHeaderParsing_data()
<< QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2)
<< true << "Set-Cookie"
<< "a=b; path=/\nc=d";
+ QTest::newRow("Content-Disposition") << QNetworkRequest::ContentDispositionHeader
+ << QVariant("attachment; filename=\"test.txt\"") << true
+ << "Content-Disposition" << "attachment; filename=\"test.txt\"";
}
void tst_QNetworkRequest::rawHeaderParsing()
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index 53d260f19e..779d55a77a 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -1225,12 +1225,13 @@ public:
socket.write("testing\n");
exec();
}
+signals:
+ void bytesWrittenReceived();
public slots:
- void bytesWritten(qint64) {
+ void bytesWritten(qint64) {
+ emit bytesWrittenReceived();
exit();
- }
-
-private:
+ }
};
/*
@@ -1248,11 +1249,12 @@ void tst_QLocalSocket::bytesWrittenSignal()
QLocalServer server;
QVERIFY(server.listen("qlocalsocket_readyread"));
WriteThread writeThread;
+ QSignalSpy receivedSpy(&writeThread, &WriteThread::bytesWrittenReceived);
writeThread.start();
bool timedOut = false;
QVERIFY(server.waitForNewConnection(3000, &timedOut));
QVERIFY(!timedOut);
- QTest::qWait(2000);
+ QVERIFY(receivedSpy.wait(2000));
QVERIFY(writeThread.wait(2000));
}
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index fc92ed6cbc..263a475435 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -2048,11 +2048,7 @@ void tst_QTcpSocket::connectToLocalHostNoService()
// port with no service listening.
QTcpSocket *socket = newSocket();
socket->connectToHost("localhost", 31415); // no service running here, one suspects
-
- while(socket->state() == QTcpSocket::HostLookupState || socket->state() == QTcpSocket::ConnectingState) {
- QTest::qWait(100);
- }
- QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
+ QTRY_COMPARE(socket->state(), QTcpSocket::UnconnectedState);
delete socket;
}
#endif
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
index 8165ccbc58..8ebb27e58c 100644
--- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -962,8 +962,10 @@ void tst_QUdpSocket::bindMode()
// Depending on the user's privileges, this or will succeed or
// fail. Admins are allowed to reuse the address, but nobody else.
- if (!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData())
- qWarning("Failed to bind with QUdpSocket::ReuseAddressHint, user isn't an administrator?");
+ if (!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)) {
+ qWarning("Failed to bind with QUdpSocket::ReuseAddressHint(%s), user isn't an administrator?",
+ qPrintable(socket2.errorString()));
+ }
socket.close();
QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData());
QVERIFY(!socket2.bind(socket.localPort()));
diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.1.1 b/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.1.1
new file mode 100644
index 0000000000..0ad263587f
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/more-certificates/cert-large-expiration-date.txt.1.1.1
@@ -0,0 +1,42 @@
+Certificate:
+ Data:
+ Version: 3 (0x2)
+ Serial Number:
+ ce:db:31:28:45:c4:05:40
+ Signature Algorithm: sha1WithRSAEncryption
+ Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
+ Validity
+ Not Before: Aug 4 09:53:41 2010 GMT
+ Not After : Aug 29 09:53:41 2051 GMT
+ Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd
+ Subject Public Key Info:
+ Public Key Algorithm: rsaEncryption
+ RSA Public-Key: (1024 bit)
+ Modulus:
+ 00:cd:aa:db:6f:d6:34:c9:a7:f1:c0:be:e4:41:18:
+ 19:e2:02:c9:22:e6:a7:d5:ba:03:2e:9e:28:7a:f4:
+ 5f:1a:77:5f:77:a9:11:3b:8f:7e:f0:2e:c6:9e:eb:
+ 3a:d9:12:d7:c1:0c:51:e8:24:52:3f:23:c3:42:0c:
+ 11:c6:f2:1c:a1:42:fe:b4:c2:69:83:ad:f7:70:b1:
+ 18:15:cc:20:28:62:30:f0:2c:15:e6:33:19:af:c3:
+ eb:1c:c0:91:f7:11:68:94:50:f8:49:37:08:32:d7:
+ 3e:75:df:a3:bc:69:00:15:de:cd:87:0f:5c:02:6b:
+ 82:c8:01:7d:6a:f0:1d:dc:73
+ Exponent: 65537 (0x10001)
+ X509v3 extensions:
+ X509v3 Subject Key Identifier:
+ 8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
+ X509v3 Authority Key Identifier:
+ keyid:8A:6E:19:E7:97:9B:8F:D9:7F:B3:BB:01:4F:E8:6A:2F:52:95:0D:D9
+
+ X509v3 Basic Constraints:
+ CA:TRUE
+ Signature Algorithm: sha1WithRSAEncryption
+ a1:74:8e:5d:36:96:2c:05:7e:ea:66:cc:2e:68:c7:3d:93:dc:
+ 8c:a3:11:ad:b5:7e:6e:d0:04:c4:09:bd:0a:f9:39:3b:97:d7:
+ f0:bb:0c:09:7b:83:fe:bf:87:b0:47:e8:94:b7:aa:9c:79:ad:
+ 71:9e:b7:c4:99:98:6f:1d:38:32:f8:a3:75:38:c4:e5:e7:37:
+ 37:21:ec:7b:50:8b:15:b0:97:1e:17:9c:50:17:3c:c1:df:94:
+ 55:fb:60:2e:50:40:d1:ea:23:c6:3c:21:6f:97:8c:06:16:a5:
+ 82:72:c1:63:14:64:86:eb:d7:ff:72:f6:09:f5:6d:e6:04:13:
+ 7a:6a
diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
index 1477fd212e..7f8580ddd6 100644
--- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp
@@ -922,6 +922,10 @@ void tst_QSslCertificate::toText()
QVERIFY(f101c.open(QIODevice::ReadOnly | QFile::Text));
QByteArray txt101c = f101c.readAll();
+ QFile f111(testDataDir + "more-certificates/cert-large-expiration-date.txt.1.1.1");
+ QVERIFY(f111.open(QIODevice::ReadOnly | QFile::Text));
+ QByteArray txt111 = f111.readAll();
+
QString txtcert = cert.toText();
#ifdef QT_NO_OPENSSL
@@ -930,7 +934,8 @@ void tst_QSslCertificate::toText()
QVERIFY(QString::fromLatin1(txt098) == txtcert ||
QString::fromLatin1(txt100) == txtcert ||
QString::fromLatin1(txt101) == txtcert ||
- QString::fromLatin1(txt101c) == txtcert );
+ QString::fromLatin1(txt101c) == txtcert ||
+ QString::fromLatin1(txt111) == txtcert );
}
void tst_QSslCertificate::multipleCommonNames()
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index bb01116240..e32fa7c724 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -2838,11 +2838,19 @@ void tst_QSslSocket::qtbug18498_peek()
client->setObjectName("client");
client->ignoreSslErrors();
- connect(client, SIGNAL(encrypted()), this, SLOT(exitLoop()));
+ int encryptedCounter = 2;
+ connect(client, &QSslSocket::encrypted, this, [&encryptedCounter, this](){
+ if (!--encryptedCounter)
+ exitLoop();
+ });
+ WebSocket *serversocket = server.socket;
+ connect(serversocket, &QSslSocket::encrypted, this, [&encryptedCounter, this](){
+ if (!--encryptedCounter)
+ exitLoop();
+ });
connect(client, SIGNAL(disconnected()), this, SLOT(exitLoop()));
client->startClientEncryption();
- WebSocket *serversocket = server.socket;
QVERIFY(serversocket);
serversocket->setObjectName("server");
@@ -2908,10 +2916,7 @@ void tst_QSslSocket::qtbug18498_peek2()
QScopedPointer<QSslSocket> server(listener.socket);
QVERIFY(server->write("HELLO\r\n", 7));
- QElapsedTimer stopwatch;
- stopwatch.start();
- while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000)
- QTest::qWait(100);
+ QTRY_COMPARE(client->bytesAvailable(), 7);
char c;
QCOMPARE(client->peek(&c,1), 1);
QCOMPARE(c, 'H');
@@ -2930,8 +2935,7 @@ void tst_QSslSocket::qtbug18498_peek2()
bigblock.fill('#', QIODEVICE_BUFFERSIZE + 1024);
QVERIFY(client->write(QByteArray("head")));
QVERIFY(client->write(bigblock));
- while (server->bytesAvailable() < bigblock.length() + 4 && stopwatch.elapsed() < 5000)
- QTest::qWait(100);
+ QTRY_COMPARE(server->bytesAvailable(), bigblock.length() + 4);
QCOMPARE(server->read(4), QByteArray("head"));
QCOMPARE(server->peek(bigblock.length()), bigblock);
b.reserve(bigblock.length());
@@ -2947,10 +2951,7 @@ void tst_QSslSocket::qtbug18498_peek2()
QCOMPARE(server->readAll(), bigblock);
QVERIFY(client->write("STARTTLS\r\n"));
- stopwatch.start();
- // ### Qt5 use QTRY_VERIFY
- while (server->bytesAvailable() < 10 && stopwatch.elapsed() < 5000)
- QTest::qWait(100);
+ QTRY_COMPARE(server->bytesAvailable(), 10);
QCOMPARE(server->peek(&c,1), 1);
QCOMPARE(c, 'S');
b = server->peek(3);
@@ -2983,9 +2984,7 @@ void tst_QSslSocket::qtbug18498_peek2()
client->startClientEncryption();
QVERIFY(server->write("hello\r\n", 7));
- stopwatch.start();
- while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000)
- QTest::qWait(100);
+ QTRY_COMPARE(client->bytesAvailable(), 7);
QVERIFY(server->mode() == QSslSocket::SslServerMode && client->mode() == QSslSocket::SslClientMode);
QCOMPARE(client->peek(&c,1), 1);
QCOMPARE(c, 'h');
@@ -2996,9 +2995,7 @@ void tst_QSslSocket::qtbug18498_peek2()
QCOMPARE(client->readAll(), QByteArray("ello\r\n"));
QVERIFY(client->write("goodbye\r\n"));
- stopwatch.start();
- while (server->bytesAvailable() < 9 && stopwatch.elapsed() < 5000)
- QTest::qWait(100);
+ QTRY_COMPARE(server->bytesAvailable(), 9);
QCOMPARE(server->peek(&c,1), 1);
QCOMPARE(c, 'g');
QCOMPARE(server->readAll(), QByteArray("goodbye\r\n"));
diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp
index d153146574..9abe9a77c0 100644
--- a/tests/auto/other/gestures/tst_gestures.cpp
+++ b/tests/auto/other/gestures/tst_gestures.cpp
@@ -43,24 +43,6 @@
#include <qdebug.h>
-static bool waitForWindowExposed(QWindow *window)
-{
- if (!window)
- return false;
-#ifdef Q_OS_OSX
- QTest::qWait(100);
- return window->isExposed();
-#endif
- return QTest::qWaitForWindowExposed(window);
-}
-
-static bool waitForWindowExposed(QWidget *widget)
-{
- if (!widget)
- return false;
- return waitForWindowExposed(widget->windowHandle());
-}
-
static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view)
{
return view->viewport()->mapToGlobal(view->mapFromScene(item->mapToScene(pt)));
@@ -349,6 +331,9 @@ private slots:
void graphicsViewParentPropagation();
void panelPropagation();
void panelStacksBehindParent();
+#ifdef Q_OS_MACOS
+ void deleteMacPanGestureRecognizerTargetWidget();
+#endif
void deleteGestureTargetWidget();
void deleteGestureTargetItem_data();
void deleteGestureTargetItem();
@@ -376,7 +361,7 @@ void tst_Gestures::customGesture()
GestureWidget widget;
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
widget.show();
- QVERIFY(waitForWindowExposed(&widget));
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
CustomEvent event;
event.hotSpot = widget.mapToGlobal(QPoint(5,5));
@@ -845,7 +830,7 @@ void tst_Gestures::graphicsItemGesture()
item->setPos(100, 100);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item->grabGesture(CustomGesture::GestureType);
@@ -907,7 +892,7 @@ void tst_Gestures::graphicsView()
item->setPos(100, 100);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item->grabGesture(CustomGesture::GestureType);
@@ -983,7 +968,7 @@ void tst_Gestures::graphicsItemTreeGesture()
item1_child2->setParentItem(item1);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item1->grabGesture(CustomGesture::GestureType);
@@ -1040,7 +1025,7 @@ void tst_Gestures::explicitGraphicsObjectTarget()
item2_child1->setPos(10, 10);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
@@ -1099,7 +1084,7 @@ void tst_Gestures::gestureOverChildGraphicsItem()
item2_child1->setPos(0, 0);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item1->grabGesture(CustomGesture::GestureType);
@@ -1397,7 +1382,7 @@ void tst_Gestures::testMapToScene()
item0->setPos(14, 16);
view.show(); // need to show to give it a global coordinate
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
QPoint origin = view.mapToGlobal(QPoint());
@@ -1523,7 +1508,7 @@ void tst_Gestures::autoCancelGestures()
parent.grabGesture(CustomGesture::GestureType);
child->grabGesture(secondGesture);
parent.show();
- QVERIFY(waitForWindowExposed(&parent));
+ QVERIFY(QTest::qWaitForWindowExposed(&parent));
/*
An event is sent to both the child and the parent, when the child gets it a gesture is triggered
@@ -1582,7 +1567,7 @@ void tst_Gestures::autoCancelGestures2()
child->grabGesture(secondGesture);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
CustomEvent event;
@@ -1628,7 +1613,7 @@ void tst_Gestures::graphicsViewParentPropagation()
item1_c1_c1->setPos(0, 0);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item0->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures | Qt::IgnoredGesturesPropagateToParent);
@@ -1698,7 +1683,7 @@ void tst_Gestures::panelPropagation()
item1_child1_child1->setZValue(10);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
@@ -1809,7 +1794,7 @@ void tst_Gestures::panelStacksBehindParent()
panel->setZValue(5);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
@@ -1825,6 +1810,31 @@ void tst_Gestures::panelStacksBehindParent()
QCOMPARE(panel->gestureOverrideEventsReceived, 0);
}
+#ifdef Q_OS_MACOS
+void tst_Gestures::deleteMacPanGestureRecognizerTargetWidget()
+{
+ QWidget window;
+ window.resize(400,400);
+ QGraphicsScene scene;
+ QGraphicsView *view = new QGraphicsView(&scene, &window);
+ view->resize(400, 400);
+ window.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QTouchDevice *device = QTest::createTouchDevice();
+ // QMacOSPenGestureRecognizer will start a timer on a touch press event
+ QTest::touchEvent(&window, device).press(1, QPoint(100, 100), &window);
+ delete view;
+
+ // wait until after that the QMacOSPenGestureRecognizer timer (300ms) is triggered.
+ // This is needed so that the whole test does not finish before the timer triggers
+ // and to make sure it crashes while executing *this* function. (otherwise it might give the
+ // impression that some of the subsequent test function caused the crash...)
+
+ QTest::qWait(400); // DO NOT CRASH while waiting
+}
+#endif
+
void tst_Gestures::deleteGestureTargetWidget()
{
}
@@ -1893,7 +1903,7 @@ void tst_Gestures::deleteGestureTargetItem()
items.insert(item2->objectName(), item2);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
if (propagateUpdateGesture)
@@ -1938,7 +1948,7 @@ void tst_Gestures::viewportCoordinates()
scene.addItem(item1);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
CustomEvent event;
@@ -1975,7 +1985,7 @@ void tst_Gestures::partialGesturePropagation()
scene.addItem(item4);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item1->ignoredUpdatedGestures << CustomGesture::GestureType;
@@ -2063,7 +2073,7 @@ void tst_Gestures::testQGestureRecognizerCleanup()
//QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom));
w->show();
- QVERIFY(waitForWindowExposed(w));
+ QVERIFY(QTest::qWaitForWindowExposed(w));
delete w;
}
@@ -2184,7 +2194,7 @@ void tst_Gestures::testReuseCanceledGestures()
gv->viewport()->grabGesture(tapGestureTypeId);
mw.show();
- QVERIFY(waitForWindowExposed(&mw));
+ QVERIFY(QTest::qWaitForWindowExposed(&mw));
QPoint targetPos(gv->mapFromScene(target->mapToScene(target->rect().center())));
targetPos = gv->viewport()->mapFromParent(targetPos);
@@ -2250,7 +2260,7 @@ void tst_Gestures::conflictingGesturesInGraphicsView()
scene.addItem(item2);
view.show();
- QVERIFY(waitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
@@ -2315,7 +2325,7 @@ void tst_Gestures::bug_13501_gesture_not_accepted()
NoConsumeWidgetBug13501 w;
w.grabGesture(Qt::TapGesture);
w.show();
- QVERIFY(waitForWindowExposed(&w));
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
//QTest::mousePress(&ignoreEvent, Qt::LeftButton);
QTouchDevice *device = QTest::createTouchDevice();
QTest::touchEvent(&w, device).press(0, QPoint(10, 10), &w);
diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
index 37521a64aa..e82327bbb1 100644
--- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
+++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
@@ -304,6 +304,7 @@ void tst_QFocusEvent::checkReason_focusWidget()
frame1.setLayout(&leftLayout);
frame2.setLayout(&rightLayout);
window1.show();
+ QVERIFY(QTest::qWaitForWindowActive(&window1));
edit1.setFocus();
QTRY_VERIFY(edit1.hasFocus());
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index f68cf5c59c..4f86e74117 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -122,6 +122,7 @@ private slots:
void testPageMetrics_data();
void testPageMetrics();
+ void reusePageMetrics();
#endif
private:
QString testFileName(const QString &prefix, const QString &suffix);
@@ -1955,6 +1956,50 @@ QString tst_QPrinter::testFileName(const QString &prefix, const QString &suffix)
return result;
}
+void tst_QPrinter::reusePageMetrics()
+{
+ QList<QPrinterInfo> availablePrinters = QPrinterInfo::availablePrinters();
+ if (availablePrinters.size() < 2)
+ QSKIP("Not enough printers to do this test with, need at least 2 setup");
+ QPrinter defaultP;
+ QPrinterInfo info(defaultP);
+ QString otherPrinterName;
+ for (QPrinterInfo i : qAsConst(availablePrinters)) {
+ if (i.printerName() != defaultP.printerName()) {
+ otherPrinterName = i.printerName();
+ break;
+ }
+ }
+ QPrinter otherP(QPrinterInfo::printerInfo(otherPrinterName));
+ QList<QPageSize> defaultPageSizes = info.supportedPageSizes();
+ QList<QPageSize> otherPageSizes = QPrinterInfo(otherP).supportedPageSizes();
+ QPageSize unavailableSizeToSet;
+ for (QPageSize s : qAsConst(defaultPageSizes)) {
+ bool found = false;
+ for (QPageSize os : qAsConst(otherPageSizes)) {
+ if (os.isEquivalentTo(s)) {
+ found = true;
+ break;
+ }
+ }
+ const QPageSize tmpSize(s.size(QPageSize::Point), QPageSize::Point);
+ if (!tmpSize.name().startsWith("Custom"))
+ found = true;
+ if (!found) {
+ unavailableSizeToSet = s;
+ break;
+ }
+ }
+ if (!unavailableSizeToSet.isValid())
+ QSKIP("Could not find a size that was not available on the non default printer. The test "
+ "requires this");
+ defaultP.setPageSize(unavailableSizeToSet);
+ defaultP.setPrinterName(otherP.printerName());
+ QVERIFY(defaultP.pageLayout().pageSize().isEquivalentTo(unavailableSizeToSet));
+ QVERIFY(defaultP.pageLayout().pageSize().name() != unavailableSizeToSet.name());
+ QCOMPARE(defaultP.pageLayout().pageSize().sizePoints(), unavailableSizeToSet.sizePoints());
+}
+
#endif // QT_CONFIG(printer)
QTEST_MAIN(tst_QPrinter)
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 23c8460133..c64310a715 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -2070,8 +2070,6 @@ void tst_QSqlQuery::prepare_bind_exec()
const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
const QString qtest_prepare(qTableName("qtest_prepare", __FILE__, db));
- if (dbType == QSqlDriver::Interbase && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb"))
- QSKIP("Can't transliterate extended unicode to ascii");
if (dbType == QSqlDriver::DB2)
QSKIP("Needs someone with more Unicode knowledge than I have to fix");
@@ -2347,6 +2345,16 @@ void tst_QSqlQuery::prepare_bind_exec()
QCOMPARE(q.value(0).toInt(), 107);
QCOMPARE(q.value(1).toString(), QString("name"));
QCOMPARE(q.value(2).toString(), QString("107"));
+
+ // Test just duplicated placeholders
+ QVERIFY(q.prepare("insert into " + qtest_prepare + " (id, name, name2) values (110, :name, :name)"));
+ q.bindValue(":name", "name");
+ QVERIFY_SQL(q, exec());
+ QVERIFY(q.exec("select * from " + qtest_prepare + " where id > 109 order by id"));
+ QVERIFY(q.next());
+ QCOMPARE(q.value(0).toInt(), 110);
+ QCOMPARE(q.value(1).toString(), QString("name"));
+ QCOMPARE(q.value(2).toString(), QString("name"));
} // end of SQLite scope
}
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 90f8457b7f..c3bdf3701f 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -494,9 +494,6 @@ void tst_QFiledialog::completer()
QAbstractItemModel *cModel = completer->completionModel();
QVERIFY(cModel);
- //wait a bit
- QTest::qWait(500);
-
// path C:\depot\qt\examples\dialogs\standarddialogs
// files
// [debug] [release] [tmp] dialog dialog main makefile makefile.debug makefile.release standarddialgos
@@ -509,7 +506,7 @@ void tst_QFiledialog::completer()
// \ -> \_viminfo
// c:\depot -> 'nothing'
// c:\depot\ -> C:\depot\devtools, C:\depot\dteske
- QCOMPARE(model->index(fd.directory().path()), model->index(startPath));
+ QTRY_COMPARE(model->index(fd.directory().path()), model->index(startPath));
if (input.isEmpty()) {
// Try to find a suitable directory under root that does not
@@ -1331,7 +1328,6 @@ void tst_QFiledialog::clearLineEdit()
// saving a file the text shouldn't be cleared
fd.setDirectory(QDir::home());
- QTest::qWait(1000);
#ifdef QT_KEYPAD_NAVIGATION
list->setEditFocus(true);
#endif
@@ -1342,8 +1338,7 @@ void tst_QFiledialog::clearLineEdit()
QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier);
#endif
- QTest::qWait(2000);
- QVERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
+ QTRY_VERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(!lineEdit->text().isEmpty());
// selecting a dir the text should be cleared so one can just hit ok
@@ -1351,7 +1346,6 @@ void tst_QFiledialog::clearLineEdit()
fd.setFileMode(QFileDialog::Directory);
fd.setDirectory(QDir::home());
- QTest::qWait(1000);
QTest::keyClick(list, Qt::Key_Down);
#ifndef Q_OS_MAC
QTest::keyClick(list, Qt::Key_Return);
@@ -1359,8 +1353,7 @@ void tst_QFiledialog::clearLineEdit()
QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier);
#endif
- QTest::qWait(2000);
- QVERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
+ QTRY_VERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(lineEdit->text().isEmpty());
//remove the dir
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index eafd4d7cea..fca1f17a4d 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -184,8 +184,7 @@ void tst_QFileDialog2::listRoot()
fd.show();
QCOMPARE(qt_test_isFetchedRoot(),false);
fd.setDirectory("");
- QTest::qWait(500);
- QCOMPARE(qt_test_isFetchedRoot(),true);
+ QTRY_COMPARE(qt_test_isFetchedRoot(),true);
}
#endif
@@ -231,9 +230,7 @@ void tst_QFileDialog2::deleteDirAndFiles()
delete t;
FriendlyQFileDialog fd;
fd.d_func()->removeDirectory(tempPath);
- QFileInfo info(tempPath);
- QTest::qWait(2000);
- QVERIFY(!info.exists());
+ QTRY_VERIFY(!QFileInfo::exists(tempPath));
}
#endif
@@ -551,22 +548,22 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog()
QFileDialog fd(0, "", QDir::currentPath(), 0);
fd.setProxyModel(new FilterDirModel(QDir::currentPath()));
fd.show();
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit");
- QTest::qWait(200);
+ QVERIFY(edit);
QTest::keyClick(edit, Qt::Key_T);
QTest::keyClick(edit, Qt::Key_S);
- QTest::qWait(200);
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") );
dialog->setFileMode(QFileDialog::ExistingFile);
dialog->show();
+ QVERIFY(QTest::qWaitForWindowActive(dialog));
QListView *list = dialog->findChild<QListView*>("listView");
- QTest::qWait(200);
+ QVERIFY(list);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
dialog->close();
fd.close();
@@ -603,21 +600,18 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior()
fd.setViewMode(QFileDialog::List);
fd.setDirectory(current.absolutePath());
fd.show();
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QListView *list = fd.findChild<QListView*>("listView");
- QTest::qWait(200);
+ QVERIFY(list);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
QTest::mouseClick(list->viewport(), Qt::LeftButton,0);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Backspace);
- QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
QCOMPARE(fd.isVisible(), true);
- QTest::qWait(200);
file.close();
file2.close();
file.remove();
@@ -734,11 +728,11 @@ void tst_QFileDialog2::task233037_selectingDirectory()
list->setEditFocus(true);
#endif
QTest::keyClick(list, Qt::Key_Down);
- QTest::qWait(100);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox);
QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
QVERIFY(button);
- QCOMPARE(button->isEnabled(), true);
+ QVERIFY(button->isEnabled());
current.rmdir("test");
}
@@ -766,10 +760,10 @@ void tst_QFileDialog2::task235069_hideOnEscape()
fd.setDirectory(current.absolutePath());
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.show();
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QWidget *child = fd.findChild<QWidget *>(childName);
QVERIFY(child);
child->setFocus();
- QTest::qWait(200);
QTest::keyClick(child, Qt::Key_Escape);
QCOMPARE(fd.isVisible(), false);
QCOMPARE(spyFinished.count(), 1); // QTBUG-7690
@@ -788,14 +782,13 @@ void tst_QFileDialog2::task236402_dontWatchDeletedDir()
fd.setDirectory(current.absolutePath());
fd.setAcceptMode( QFileDialog::AcceptSave);
fd.show();
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QListView *list = fd.findChild<QListView*>("listView");
+ QVERIFY(list);
list->setFocus();
- QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Backspace);
QTest::keyClick(list, Qt::Key_Down);
- QTest::qWait(200);
fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/");
QTest::qWait(1000);
}
@@ -810,16 +803,16 @@ void tst_QFileDialog2::task203703_returnProperSeparator()
fd.setViewMode(QFileDialog::List);
fd.setFileMode(QFileDialog::Directory);
fd.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QListView *list = fd.findChild<QListView*>("listView");
+ QVERIFY(list);
list->setFocus();
- QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Return);
- QTest::qWait(1000);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox);
QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel);
+ QVERIFY(button);
QTest::keyClick(button, Qt::Key_Return);
- QTest::qWait(500);
QString result = fd.selectedFiles().first();
QVERIFY(result.at(result.count() - 1) != '/');
QVERIFY(!result.contains('\\'));
@@ -846,47 +839,52 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
fd.setDirectory(current.absolutePath());
fd.setViewMode(QFileDialog::Detail);
fd.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QTreeView *tree = fd.findChild<QTreeView*>("treeView");
+ QVERIFY(tree);
tree->header()->setSortIndicator(3,Qt::DescendingOrder);
- QTest::qWait(200);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox);
QPushButton *button = buttonBox->button(QDialogButtonBox::Open);
+ QVERIFY(button);
QTest::mouseClick(button, Qt::LeftButton);
- QTest::qWait(500);
QFileDialog fd2;
fd2.setFileMode(QFileDialog::Directory);
fd2.restoreState(fd.saveState());
current.cd("aaaaaaaaaaaaaaaaaa");
fd2.setDirectory(current.absolutePath());
fd2.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&fd2));
QTreeView *tree2 = fd2.findChild<QTreeView*>("treeView");
+ QVERIFY(tree2);
tree2->setFocus();
QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath());
QDialogButtonBox *buttonBox2 = fd2.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox2);
QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open);
+ QVERIFY(button2);
fd2.selectFile("g");
QTest::mouseClick(button2, Qt::LeftButton);
- QTest::qWait(500);
QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QLatin1String("/g"));
QFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
fd3.restoreState(fd.saveState());
fd3.setFileMode(QFileDialog::Directory);
fd3.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&fd3));
QTreeView *tree3 = fd3.findChild<QTreeView*>("treeView");
+ QVERIFY(tree3);
tree3->setFocus();
QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath());
QDialogButtonBox *buttonBox3 = fd3.findChild<QDialogButtonBox*>("buttonBox");
+ QVERIFY(buttonBox3);
QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open);
+ QVERIFY(button3);
QTest::mouseClick(button3, Qt::LeftButton);
- QTest::qWait(500);
QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName());
current.cd("aaaaaaaaaaaaaaaaaa");
@@ -908,9 +906,8 @@ void tst_QFileDialog2::task239706_editableFilterCombo()
{
QFileDialog d;
d.setNameFilter("*.cpp *.h");
-
d.show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(&d));
QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
QComboBox *filterCombo = 0;
@@ -961,9 +958,10 @@ void tst_QFileDialog2::task251321_sideBarHiddenEntries()
urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath());
fd.setSidebarUrls(urls);
fd.show();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
+ QVERIFY(sidebar);
sidebar->setFocus();
sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath()));
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
@@ -1014,16 +1012,17 @@ void tst_QFileDialog2::task251341_sideBarRemoveEntries()
urls << QUrl::fromLocalFile("NotFound");
fd.setSidebarUrls(urls);
fd.show();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
+ QVERIFY(sidebar);
sidebar->setFocus();
//We enter in the first bookmark
sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
- QTest::qWait(250);
QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
+ QVERIFY(model);
//There is no file
QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0);
//Icon is not enabled QUrlModel::EnabledRole
@@ -1034,7 +1033,6 @@ void tst_QFileDialog2::task251341_sideBarRemoveEntries()
//We enter in the second bookmark which is invalid
sidebar->selectUrl(QUrl::fromLocalFile("NotFound"));
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
- QTest::qWait(250);
//We fallback to root because the entry in the bookmark is invalid
QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath())));
@@ -1086,7 +1084,7 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes()
fd.selectFile("new_file.txt");
fd.show();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
QVERIFY(lineEdit);
@@ -1130,7 +1128,7 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
fd.setOption(QFileDialog::HideNameFilterDetails, true);
fd.show();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
//Extensions are hidden
QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo");
@@ -1141,7 +1139,6 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
//We should have the full names
fd.setOption(QFileDialog::HideNameFilterDetails, false);
- QTest::qWait(250);
filters->setCurrentIndex(0);
QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)"));
filters->setCurrentIndex(1);
@@ -1155,14 +1152,12 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
fd.setOption(QFileDialog::HideNameFilterDetails, true);
filters->setCurrentIndex(0);
- QTest::qWait(500);
QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
filters->setCurrentIndex(1);
QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
fd.setOption(QFileDialog::HideNameFilterDetails, true);
filters->setCurrentIndex(0);
- QTest::qWait(500);
QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
filters->setCurrentIndex(1);
QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 40a7d56432..d8a680881a 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -176,15 +176,12 @@ void tst_QFileSystemModel::indexPath()
#if !defined(Q_OS_WIN)
int depth = QDir::currentPath().count('/');
model->setRootPath(QDir::currentPath());
- QTest::qWait(WAITTIME);
QString backPath;
for (int i = 0; i <= depth * 2 + 1; ++i) {
backPath += "../";
QModelIndex idx = model->index(backPath);
QVERIFY(i != depth - 1 ? idx.isValid() : !idx.isValid());
}
- QTest::qWait(WAITTIME * 3);
- qApp->processEvents();
#endif
}
@@ -296,9 +293,7 @@ void tst_QFileSystemModel::iconProvider()
QVERIFY(!documentPaths.isEmpty());
const QString documentPath = documentPaths.front();
myModel->setRootPath(documentPath);
- //Let's wait to populate the model
- QTest::qWait(250);
- //We change the provider, icons must me updated
+ //We change the provider, icons must be updated
CustomFileIconProvider *custom = new CustomFileIconProvider();
myModel->setIconProvider(custom);
@@ -421,7 +416,6 @@ void tst_QFileSystemModel::rowsInserted()
for (int i = 0; i < count; ++i)
files.append(QLatin1Char('c') + QString::number(i));
QVERIFY(createFiles(tmp, files, 5));
- TRY_WAIT(model->rowCount(root) == oldCount + count);
QTRY_COMPARE(model->rowCount(root), oldCount + count);
int totalRowsInserted = 0;
for (int i = 0; i < spy0.count(); ++i) {
@@ -467,7 +461,6 @@ void tst_QFileSystemModel::rowsRemoved()
QFETCH(int, count);
QFETCH(int, ascending);
model->sort(0, (Qt::SortOrder)ascending);
- QTest::qWait(WAITTIME);
QSignalSpy spy0(model, SIGNAL(rowsRemoved(QModelIndex,int,int)));
QSignalSpy spy1(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
@@ -477,8 +470,6 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::remove(tmp + '/' + model->index(i, 0, root).data().toString()));
}
for (int i = 0 ; i < 10; ++i) {
- QTest::qWait(WAITTIME);
- qApp->processEvents();
if (count != 0) {
if (i == 10 || spy0.count() != 0) {
QVERIFY(spy0.count() >= 1);
@@ -504,7 +495,6 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::exists(tmp + '/' + QString(".a")));
QVERIFY(QFile::remove(tmp + '/' + QString(".a")));
QVERIFY(QFile::remove(tmp + '/' + QString(".c")));
- QTest::qWait(WAITTIME);
if (count != 0) QVERIFY(spy0.count() >= 1); else QCOMPARE(spy0.count(), 0);
if (count != 0) QVERIFY(spy1.count() >= 1); else QCOMPARE(spy1.count(), 0);
@@ -517,10 +507,8 @@ void tst_QFileSystemModel::dataChanged_data()
void tst_QFileSystemModel::dataChanged()
{
- // This can't be tested right now sense we don't watch files, only directories
- return;
+ QSKIP("This can't be tested right now since we don't watch files, only directories.");
- /*
QString tmp = flatDirTestPath;
rowCount();
QModelIndex root = model->index(model->rootPath());
@@ -538,7 +526,6 @@ void tst_QFileSystemModel::dataChanged()
QTest::qWait(WAITTIME);
if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
- */
}
void tst_QFileSystemModel::filters_data()
@@ -796,7 +783,7 @@ void tst_QFileSystemModel::sort()
tree->setModel(myModel);
tree->show();
tree->resize(800, 800);
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(tree));
tree->header()->setSortIndicator(1,Qt::DescendingOrder);
tree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
QStringList dirsToOpen;
@@ -807,16 +794,15 @@ void tst_QFileSystemModel::sort()
for (int i = dirsToOpen.size() -1 ; i > 0 ; --i) {
QString path = dirsToOpen[i];
- QTest::qWait(500);
tree->expand(myModel->index(path, 0));
}
tree->expand(myModel->index(dirPath, 0));
- QTest::qWait(500);
QModelIndex parent = myModel->index(dirPath, 0);
QList<QString> expectedOrder;
expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + ".";
if (fileDialogMode) {
+ QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.count());
// File dialog Mode means sub trees are not sorted, only the current root.
// There's no way we can check that the sub tree is "not sorted"; just check if it
// has the same contents of the expected list
@@ -858,8 +844,8 @@ void tst_QFileSystemModel::mkdir()
QModelIndex idx = model->mkdir(tmpDir, "NewFoldermkdirtest4");
QVERIFY(idx.isValid());
int oldRow = idx.row();
- QTest::qWait(WAITTIME);
idx = model->index(newFolderPath);
+ QVERIFY(idx.isValid());
QVERIFY(model->remove(idx));
QVERIFY(!bestatic.exists());
QVERIFY(0 != idx.row());
@@ -981,7 +967,6 @@ void tst_QFileSystemModel::drives()
foreach(const QFileInfo& driveRoot, drives)
if (driveRoot.exists())
driveCount++;
- QTest::qWait(5000);
QTRY_COMPARE(model.rowCount(), driveCount);
}
@@ -989,7 +974,8 @@ void tst_QFileSystemModel::dirsBeforeFiles()
{
QDir dir(flatDirTestPath);
- for (int i = 0; i < 3; ++i) {
+ const int itemCount = 3;
+ for (int i = 0; i < itemCount; ++i) {
QLatin1Char c('a' + i);
dir.mkdir(c + QLatin1String("-dir"));
QFile file(flatDirTestPath + QLatin1Char('/') + c + QLatin1String("-file"));
@@ -998,7 +984,8 @@ void tst_QFileSystemModel::dirsBeforeFiles()
}
QModelIndex root = model->setRootPath(flatDirTestPath);
- QTest::qWait(1000); // allow model to be notified by the file system watcher
+ // Wait for model to be notified by the file system watcher
+ QTRY_COMPARE(model->rowCount(root), 2 * itemCount);
// ensure that no file occurs before a directory
for (int i = 0; i < model->rowCount(root); ++i) {
diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
index 00d640e55e..2ada4fedb6 100644
--- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
+++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
@@ -197,8 +197,7 @@ void tst_QProgressDialog::task198202()
dlg.setLabel(0);
QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setBar: Cannot set a null progress bar");
dlg.setBar(0);
- QTest::qWait(20);
- QCOMPARE(dlg.sizeHint().height(), futureHeight);
+ QTRY_COMPARE(dlg.sizeHint().height(), futureHeight);
}
void tst_QProgressDialog::QTBUG_31046()
diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
index a1cb729849..5b142048b5 100644
--- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -365,9 +365,8 @@ void tst_QGraphicsEffect::draw()
// Make sure we update the source when disabling/enabling the effect.
effect->setEnabled(false);
- QTest::qWait(50);
+ QTRY_COMPARE(item->numRepaints, 1);
QCOMPARE(effect->numRepaints, 0);
- QCOMPARE(item->numRepaints, 1);
effect->reset();
item->reset();
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index 9124ff0070..65480bf665 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -3066,8 +3066,6 @@ void tst_QGraphicsAnchorLayout1::testComplexCases()
widget->resize(size);
QCOMPARE(widget->size(), size);
-// QTest::qWait(500); // layouting is asynchronous..
-
// Validate
for (int i = 0; i < result.count(); ++i) {
const BasicLayoutTestResult item = result[i];
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 6924b78397..34646a9074 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -1826,7 +1826,7 @@ void tst_QGraphicsGridLayout::removeLayout()
QGraphicsView view(&scene);
view.show();
- QTest::qWait(20);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QRectF r1 = textEdit->geometry();
QRectF r2 = pushButton->geometry();
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 4f4a11a79c..6c1abaedb3 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -1689,7 +1689,6 @@ void tst_QGraphicsItem::selected_textItem()
QGraphicsView view(&scene);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(20);
QTRY_VERIFY(!text->isSelected());
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0,
@@ -1723,107 +1722,88 @@ void tst_QGraphicsItem::selected_multi()
QGraphicsView view(&scene);
view.show();
view.fitInView(scene.sceneRect());
- qApp->processEvents();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
- // Start clicking
- QTest::qWait(200);
-
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on item2
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos()));
- QTest::qWait(20);
QVERIFY(item2->isSelected());
QVERIFY(!item1->isSelected());
// Ctrl-click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item2->isSelected());
QVERIFY(item1->isSelected());
// Ctrl-click on item1 again
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item2->isSelected());
QVERIFY(!item1->isSelected());
// Ctrl-click on item2
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item2->scenePos()));
- QTest::qWait(20);
QVERIFY(!item2->isSelected());
QVERIFY(!item1->isSelected());
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on scene
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(0, 0));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Ctrl-click on scene
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(0, 0));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on scene
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(0, 0));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Press on item2
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos()));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(item2->isSelected());
// Release on item2
QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos()));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(item2->isSelected());
// Click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
// Ctrl-click on item1
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
// Ctrl-press on item1
QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
@@ -1831,14 +1811,12 @@ void tst_QGraphicsItem::selected_multi()
// Ctrl-move on item1
QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier);
QApplication::sendEvent(view.viewport(), &event);
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
}
// Release on item1
QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
@@ -1847,7 +1825,6 @@ void tst_QGraphicsItem::selected_multi()
// Ctrl-press on item1
QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(!item1->isSelected());
QVERIFY(!item2->isSelected());
@@ -1855,14 +1832,12 @@ void tst_QGraphicsItem::selected_multi()
// Ctrl-move on item1
QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier);
QApplication::sendEvent(view.viewport(), &event);
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
}
// Release on item1
QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos()));
- QTest::qWait(20);
QVERIFY(item1->isSelected());
QVERIFY(!item2->isSelected());
}
@@ -3383,9 +3358,8 @@ void tst_QGraphicsItem::childrenBoundingRect()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(30);
- QCOMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800));
+ QTRY_COMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800));
}
void tst_QGraphicsItem::childrenBoundingRectTransformed()
@@ -3576,7 +3550,6 @@ void tst_QGraphicsItem::group()
QCOMPARE(scene.items().size(), 4);
QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 3);
- QTest::qWait(25);
QRectF parent2SceneBoundingRect = parent2->sceneBoundingRect();
group->addToGroup(parent2);
@@ -3588,8 +3561,6 @@ void tst_QGraphicsItem::group()
QCOMPARE(scene.items().size(), 4);
QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 4);
- QTest::qWait(25);
-
QList<QGraphicsItem *> newItems;
for (int i = 0; i < 100; ++i) {
QGraphicsItem *item = scene.addRect(QRectF(-25, -25, 50, 50), QPen(Qt::black, 0),
@@ -3603,12 +3574,9 @@ void tst_QGraphicsItem::group()
view.fitInView(scene.itemsBoundingRect());
- int n = 0;
foreach (QGraphicsItem *item, newItems) {
group->addToGroup(item);
QCOMPARE(item->group(), group);
- if ((n++ % 100) == 0)
- QTest::qWait(10);
}
}
@@ -3798,7 +3766,6 @@ void tst_QGraphicsItem::handlesChildEvents()
QGraphicsView view(&scene);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(20);
// Pull out the items, closest item first
QList<QGraphicsItem *> items = scene.items(scene.itemsBoundingRect());
@@ -4011,7 +3978,6 @@ void tst_QGraphicsItem::filtersChildEvents()
QGraphicsView view(&scene);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(20);
QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
@@ -4137,7 +4103,6 @@ void tst_QGraphicsItem::ensureVisible()
}
item->ensureVisible(-100, -100, 25, 25);
- QTest::qWait(25);
for (int x = -100; x < 100; x += 25) {
for (int y = -100; y < 100; y += 25) {
@@ -4217,8 +4182,6 @@ void tst_QGraphicsItem::cursor()
QTest::mouseMove(&view, view.rect().center());
- QTest::qWait(25);
-
const Qt::CursorShape viewportShape = view.viewport()->cursor().shape();
{
@@ -5039,7 +5002,6 @@ void tst_QGraphicsItem::sceneEventFilter()
gv.setScene(anotherScene);
gv.show();
QVERIFY(QTest::qWaitForWindowExposed(&gv));
- QTest::qWait(25);
ti->installSceneEventFilter(ti2);
ti3->installSceneEventFilter(ti);
delete ti2;
@@ -5112,30 +5074,25 @@ void tst_QGraphicsItem::paint()
QGraphicsView view2(&scene2);
view2.show();
QVERIFY(QTest::qWaitForWindowExposed(&view2));
- QTest::qWait(25);
PaintTester tester2;
scene2.addItem(&tester2);
- qApp->processEvents();
//First show one paint
QTRY_COMPARE(tester2.painted, 1);
//nominal case, update call paint
tester2.update();
- qApp->processEvents();
QTRY_COMPARE(tester2.painted, 2);
//we remove the item from the scene, number of updates is still the same
tester2.update();
scene2.removeItem(&tester2);
- qApp->processEvents();
QTRY_COMPARE(tester2.painted, 2);
//We re-add the item, the number of paint should increase
scene2.addItem(&tester2);
tester2.update();
- qApp->processEvents();
QTRY_COMPARE(tester2.painted, 3);
}
@@ -6259,7 +6216,6 @@ void tst_QGraphicsItem::untransformable()
view.rotate(13);
view.shear(qreal(0.01), qreal(0.01));
view.translate(10, 10);
- QTest::qWait(25);
}
}
@@ -6298,7 +6254,6 @@ void tst_QGraphicsItem::contextMenuEventPropagation()
view.show();
view.resize(200, 200);
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(20);
QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10),
view.viewport()->mapToGlobal(QPoint(10, 10)));
@@ -6576,15 +6531,12 @@ void tst_QGraphicsItem::ensureUpdateOnTextItem()
QGraphicsView view(&scene);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(25);
TextItem *text1 = new TextItem(QLatin1String("123"));
scene.addItem(text1);
- qApp->processEvents();
QTRY_COMPARE(text1->updates,1);
//same bouding rect but we have to update
text1->setText(QLatin1String("321"));
- qApp->processEvents();
QTRY_COMPARE(text1->updates,2);
}
@@ -6862,7 +6814,6 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
child->setOpacity(0.0);
- QTest::qWait(10);
QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 1);
QCOMPARE(child->repaints, 0);
@@ -6871,7 +6822,6 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
child->setOpacity(1.0);
- QTest::qWait(10);
QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 1);
QCOMPARE(child->repaints, 1);
@@ -6880,7 +6830,6 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
parent->setOpacity(0.0);
- QTest::qWait(10);
QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 0);
QCOMPARE(child->repaints, 0);
@@ -6889,7 +6838,6 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
parent->setOpacity(1.0);
- QTest::qWait(10);
QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 1);
QCOMPARE(child->repaints, 1);
@@ -6899,7 +6847,6 @@ void tst_QGraphicsItem::opacity2()
RESET_REPAINT_COUNTERS
child->setOpacity(0.0);
- QTest::qWait(10);
QTRY_COMPARE(view.repaints, 1);
QCOMPARE(parent->repaints, 1);
QCOMPARE(child->repaints, 0);
@@ -6909,7 +6856,7 @@ void tst_QGraphicsItem::opacity2()
child->setOpacity(0.0); // Already 0.0; no change.
QTest::qWait(10);
- QTRY_COMPARE(view.repaints, 0);
+ QCOMPARE(view.repaints, 0);
QCOMPARE(parent->repaints, 0);
QCOMPARE(child->repaints, 0);
QCOMPARE(grandChild->repaints, 0);
@@ -6933,7 +6880,7 @@ void tst_QGraphicsItem::opacityZeroUpdates()
view.reset();
parent->setOpacity(0.0);
- QTest::qWait(20);
+ QTRY_COMPARE(view.repaints, 1);
// transforming items bounding rect to view coordinates
const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform())
@@ -7002,7 +6949,6 @@ void tst_QGraphicsItem::itemStacksBehindParent()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
QTRY_VERIFY(!paintedItems.isEmpty());
- QTest::qWait(100);
paintedItems.clear();
view.viewport()->update();
QApplication::processEvents();
@@ -7021,34 +6967,32 @@ void tst_QGraphicsItem::itemStacksBehindParent()
child11->setFlag(QGraphicsItem::ItemStacksBehindParent);
scene.update();
paintedItems.clear();
- QApplication::processEvents();
QTRY_COMPARE(scene.items(rect), (QList<QGraphicsItem *>()
<< grandChild121 << child12 << parent1
<< grandChild111 << child11
<< grandChild211 << child21
<< grandChild221 << child22 << parent2));
- QCOMPARE(paintedItems, QList<QGraphicsItem *>()
- << parent2 << child22 << grandChild221
- << child21 << grandChild211
- << child11 << grandChild111
- << parent1 << child12 << grandChild121);
+ QTRY_COMPARE(paintedItems, QList<QGraphicsItem *>()
+ << parent2 << child22 << grandChild221
+ << child21 << grandChild211
+ << child11 << grandChild111
+ << parent1 << child12 << grandChild121);
child12->setFlag(QGraphicsItem::ItemStacksBehindParent);
paintedItems.clear();
scene.update();
- QApplication::processEvents();
QTRY_COMPARE(scene.items(rect), (QList<QGraphicsItem *>()
<< parent1 << grandChild111 << child11
<< grandChild121 << child12
<< grandChild211 << child21
<< grandChild221 << child22 << parent2));
- QCOMPARE(paintedItems, QList<QGraphicsItem *>()
- << parent2 << child22 << grandChild221
- << child21 << grandChild211
- << child12 << grandChild121
- << child11 << grandChild111 << parent1);
+ QTRY_COMPARE(paintedItems, QList<QGraphicsItem *>()
+ << parent2 << child22 << grandChild221
+ << child21 << grandChild211
+ << child12 << grandChild121
+ << child11 << grandChild111 << parent1);
}
class ClippingAndTransformsScene : public QGraphicsScene
@@ -7100,7 +7044,6 @@ void tst_QGraphicsItem::nestedClipping()
view.setOptimizationFlag(QGraphicsView::IndirectPainting);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(25);
QList<QGraphicsItem *> expected;
expected << root << l1 << l2 << l3;
@@ -7293,16 +7236,13 @@ void tst_QGraphicsItem::tabChangesFocus()
QTRY_VERIFY(scene.isActive());
dial1->setFocus();
- QTest::qWait(15);
QTRY_VERIFY(dial1->hasFocus());
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(15);
QTRY_VERIFY(view->hasFocus());
QTRY_VERIFY(item->hasFocus());
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
- QTest::qWait(15);
if (tabChangesFocus) {
QTRY_VERIFY(!view->hasFocus());
@@ -7324,10 +7264,6 @@ void tst_QGraphicsItem::cacheMode()
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- // Increase the probability of window activation
- // not causing another repaint of test items.
- QTest::qWait(50);
-
EventTester *tester = new EventTester;
EventTester *testerChild = new EventTester;
testerChild->setParentItem(tester);
@@ -7336,7 +7272,6 @@ void tst_QGraphicsItem::cacheMode()
testerChild2->setFlag(QGraphicsItem::ItemIgnoresTransformations);
scene.addItem(tester);
- QTest::qWait(10);
for (int i = 0; i < 2; ++i) {
// No visual change.
@@ -7361,7 +7296,6 @@ void tst_QGraphicsItem::cacheMode()
tester->setPos(10, 10);
testerChild->setPos(10, 10);
testerChild2->setPos(10, 10);
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 2);
QCOMPARE(testerChild->repaints, 2);
QCOMPARE(testerChild2->repaints, 2);
@@ -7378,13 +7312,12 @@ void tst_QGraphicsItem::cacheMode()
// Translating does not result in a repaint.
tester->setTransform(QTransform::fromTranslate(10, 10), true);
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 2);
+ QCOMPARE(tester->repaints, 2);
QCOMPARE(testerChild->repaints, 2);
QCOMPARE(testerChild2->repaints, 2);
// Rotating results in a repaint.
tester->setTransform(QTransform().rotate(45), true);
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 3);
QCOMPARE(testerChild->repaints, 3);
QCOMPARE(testerChild2->repaints, 2);
@@ -7393,7 +7326,6 @@ void tst_QGraphicsItem::cacheMode()
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize
testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize
testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 4);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
@@ -7403,16 +7335,15 @@ void tst_QGraphicsItem::cacheMode()
testerChild->setTransform(QTransform().rotate(22), true);
testerChild2->setTransform(QTransform().rotate(22), true);
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 4);
- QTRY_COMPARE(testerChild->repaints, 4);
- QTRY_COMPARE(testerChild2->repaints, 3);
+ QCOMPARE(tester->repaints, 4);
+ QCOMPARE(testerChild->repaints, 4);
+ QCOMPARE(testerChild2->repaints, 3);
tester->resetTransform();
testerChild->resetTransform();
testerChild2->resetTransform();
// Explicit update causes a repaint.
tester->update(0, 0, 5, 5);
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 5);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
@@ -7420,14 +7351,13 @@ void tst_QGraphicsItem::cacheMode()
// Updating outside the item's bounds does not cause a repaint.
tester->update(10, 10, 5, 5);
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 5);
+ QCOMPARE(tester->repaints, 5);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
// Resizing an item should cause a repaint of that item. (because of
// autosize).
tester->setGeometry(QRectF(-15, -15, 30, 30));
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 6);
QCOMPARE(testerChild->repaints, 4);
QCOMPARE(testerChild2->repaints, 3);
@@ -7436,22 +7366,20 @@ void tst_QGraphicsItem::cacheMode()
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30));
testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30));
testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30));
- QTest::qWait(20);
QTRY_COMPARE(tester->repaints, 7);
QCOMPARE(testerChild->repaints, 5);
QCOMPARE(testerChild2->repaints, 4);
// Resizing the item should cause a repaint.
testerChild->setGeometry(QRectF(-15, -15, 30, 30));
- QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 7);
- QCOMPARE(testerChild->repaints, 6);
+ QTRY_COMPARE(testerChild->repaints, 6);
+ QCOMPARE(tester->repaints, 7);
QCOMPARE(testerChild2->repaints, 4);
// Scaling the view does not cause a repaint.
view.scale(0.7, 0.7);
QTest::qWait(25);
- QTRY_COMPARE(tester->repaints, 7);
+ QCOMPARE(tester->repaints, 7);
QCOMPARE(testerChild->repaints, 6);
QCOMPARE(testerChild2->repaints, 4);
@@ -7459,46 +7387,42 @@ void tst_QGraphicsItem::cacheMode()
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 8);
QCOMPARE(testerChild->repaints, 7);
QCOMPARE(testerChild2->repaints, 5);
// Scaling the view back should cause repaints for two of the items.
view.setTransform(QTransform());
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 9);
QCOMPARE(testerChild->repaints, 8);
QCOMPARE(testerChild2->repaints, 5);
// Rotating the base item (perspective) should repaint two items.
tester->setTransform(QTransform().rotate(10, Qt::XAxis));
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 10);
QCOMPARE(testerChild->repaints, 9);
QCOMPARE(testerChild2->repaints, 5);
- // Moving the middle item should case a repaint even if it's a move,
+ // Moving the middle item should cause a repaint even if it's a move,
// because the parent is rotated with a perspective.
testerChild->setPos(1, 1);
- QTest::qWait(25);
QTRY_COMPARE(tester->repaints, 11);
QTRY_COMPARE(testerChild->repaints, 10);
- QTRY_COMPARE(testerChild2->repaints, 5);
+ QCOMPARE(testerChild2->repaints, 5);
tester->resetTransform();
// Make a huge item
tester->setGeometry(QRectF(-4000, -4000, 8000, 8000));
QTRY_COMPARE(tester->repaints, 12);
QTRY_COMPARE(testerChild->repaints, 11);
- QTRY_COMPARE(testerChild2->repaints, 5);
+ QCOMPARE(testerChild2->repaints, 5);
// Move the large item - will cause a repaint as the
// cache is clipped.
tester->setPos(5, 0);
QTRY_COMPARE(tester->repaints, 13);
QTRY_COMPARE(testerChild->repaints, 11);
- QTRY_COMPARE(testerChild2->repaints, 5);
+ QCOMPARE(testerChild2->repaints, 5);
// Hiding and showing should invalidate the cache
tester->hide();
@@ -7518,66 +7442,56 @@ void tst_QGraphicsItem::cacheMode2()
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- // Increase the probability of window activation
- // not causing another repaint of test items.
- QTest::qWait(50);
-
EventTester *tester = new EventTester;
scene.addItem(tester);
- QTest::qWait(10);
QTRY_COMPARE(tester->repaints, 1);
// Switching from NoCache to NoCache (no repaint)
tester->setCacheMode(QGraphicsItem::NoCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 1);
+ QCOMPARE(tester->repaints, 1);
// Switching from NoCache to DeviceCoordinateCache (no repaint)
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 1);
+ QCOMPARE(tester->repaints, 1);
// Switching from DeviceCoordinateCache to DeviceCoordinateCache (no repaint)
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 1);
+ QCOMPARE(tester->repaints, 1);
// Switching from DeviceCoordinateCache to NoCache (no repaint)
tester->setCacheMode(QGraphicsItem::NoCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 1);
+ QCOMPARE(tester->repaints, 1);
// Switching from NoCache to ItemCoordinateCache (repaint)
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 2);
// Switching from ItemCoordinateCache to ItemCoordinateCache (no repaint)
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 2);
+ QCOMPARE(tester->repaints, 2);
// Switching from ItemCoordinateCache to ItemCoordinateCache with different size (repaint)
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(100, 100));
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 3);
// Switching from ItemCoordinateCache to NoCache (repaint)
tester->setCacheMode(QGraphicsItem::NoCache);
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 4);
// Switching from DeviceCoordinateCache to ItemCoordinateCache (repaint)
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
QTest::qWait(50);
- QTRY_COMPARE(tester->repaints, 4);
+ QCOMPARE(tester->repaints, 4);
tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 5);
// Switching from ItemCoordinateCache to DeviceCoordinateCache (repaint)
tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- QTest::qWait(50);
QTRY_COMPARE(tester->repaints, 6);
}
@@ -7595,7 +7509,6 @@ void tst_QGraphicsItem::updateCachedItemAfterMove()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(12);
QTRY_VERIFY(tester->repaints > 0);
tester->repaints = 0;
@@ -7607,8 +7520,7 @@ void tst_QGraphicsItem::updateCachedItemAfterMove()
// Move then update, should cause one repaint
tester->setPos(20, 0);
tester->update();
- QTest::qWait(12);
- QCOMPARE(tester->repaints, 1);
+ QTRY_COMPARE(tester->repaints, 1);
// Hiding the item doesn't cause a repaint
tester->hide();
@@ -7745,28 +7657,25 @@ void tst_QGraphicsItem::update()
EventTester *item = new EventTester;
scene.addItem(item);
- QTest::qWait(100); // Make sure all pending updates are processed.
+ QTRY_VERIFY(item->repaints > 0); // Wait for painting
item->repaints = 0;
item->update(); // Item marked as dirty
scene.update(); // Entire scene marked as dirty
- qApp->processEvents();
- QCOMPARE(item->repaints, 1);
+ QTRY_COMPARE(item->repaints, 1);
// Make sure the dirty state from the previous update is reset so that
// the item don't think it is already dirty and discards this update.
item->update();
- qApp->processEvents();
- QCOMPARE(item->repaints, 2);
+ QTRY_COMPARE(item->repaints, 2);
// Make sure a partial update doesn't cause a full update to be discarded.
view.reset();
item->repaints = 0;
item->update(QRectF(0, 0, 5, 5));
item->update();
- qApp->processEvents();
- QCOMPARE(item->repaints, 1);
- QCOMPARE(view.repaints, 1);
+ QTRY_COMPARE(item->repaints, 1);
+ QTRY_COMPARE(view.repaints, 1);
QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform())
.mapRect(item->boundingRect()).toAlignedRect();
QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2);
@@ -7828,13 +7737,11 @@ void tst_QGraphicsItem::update()
item->setPos(originalPos + QPoint(50, 50));
viewPrivate->updateAll();
QVERIFY(viewPrivate->fullUpdatePending);
- QTest::qWait(50);
+ QTRY_VERIFY(view.repaints > 1 && item->repaints > 1);
item->repaints = 0;
view.reset();
item->setPos(originalPos);
- QTest::qWait(50);
- qApp->processEvents();
- QCOMPARE(item->repaints, 1);
+ QTRY_COMPARE(item->repaints, 1);
QCOMPARE(view.repaints, 1);
COMPARE_REGIONS(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50));
@@ -7845,7 +7752,6 @@ void tst_QGraphicsItem::update()
item->setParentItem(parent);
item->setPos(400, 0);
scene.addItem(parent);
- QTest::qWait(50);
itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform())
.mapRect(item->boundingRect()).toAlignedRect();
expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2);
@@ -7987,6 +7893,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
{
+ ++repaints;
if (startTrack) {
//Doesn't use the extended style option so the exposed rect is the boundingRect
if (!(flags() & QGraphicsItem::ItemUsesExtendedStyleOption)) {
@@ -8001,6 +7908,7 @@ public:
QGraphicsRectItem::paint(painter, option, widget);
}
bool startTrack;
+ int repaints = 0;
};
void tst_QGraphicsItem::itemUsesExtendedStyleOption()
@@ -8023,17 +7931,21 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption()
rect->startTrack = false;
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
- QTest::qWait(60);
+ QTRY_VERIFY(rect->repaints > 0);
+ rect->repaints = 0;
rect->startTrack = true;
rect->update(10, 10, 10, 10);
- QTest::qWait(60);
+ QTRY_COMPARE(rect->repaints, 1);
+ rect->repaints = 0;
rect->startTrack = false;
rect->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
QVERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption));
- QTest::qWait(60);
+ QTRY_COMPARE(rect->repaints, 1);
+ rect->repaints = 0;
rect->startTrack = true;
rect->update(10, 10, 10, 10);
QTest::qWait(60);
+ // MyStyleOptionTester does not receive a paint event. Why not?
}
void tst_QGraphicsItem::itemSendsGeometryChanges()
@@ -8116,8 +8028,9 @@ void tst_QGraphicsItem::moveItem()
grandChild->repaints = 0; \
view.reset();
+ RESET_COUNTERS
scene.addItem(parent);
- QTest::qWait(100);
+ QTRY_COMPARE(view.repaints, 1);
RESET_COUNTERS
@@ -8195,15 +8108,13 @@ void tst_QGraphicsItem::moveLineItem()
// Make sure the calculated region is correct.
item->update();
- QTest::qWait(10);
QTRY_COMPARE(view.paintedRegion, expectedRegion);
view.reset();
// Old position: (50, 50)
item->setPos(50, 100);
expectedRegion += expectedRegion.translated(0, 50);
- QTest::qWait(10);
- QCOMPARE(view.paintedRegion, expectedRegion);
+ QTRY_COMPARE(view.paintedRegion, expectedRegion);
}
void tst_QGraphicsItem::sorting_data()
@@ -8251,7 +8162,7 @@ void tst_QGraphicsItem::sorting()
view.show();
qApp->setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- QTest::qWait(100);
+ QTRY_VERIFY(_paintedItems.count() > 0);
_paintedItems.clear();
@@ -8334,7 +8245,6 @@ void tst_QGraphicsItem::hitTestUntransformableItem()
item3->setPos(80, 80);
scene.addItem(item1);
- QTest::qWait(100);
QList<QGraphicsItem *> items = scene.items(QPointF(80, 80));
QCOMPARE(items.size(), 1);
@@ -8391,7 +8301,8 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem()
item3->brush = Qt::blue;
scene.addItem(item1);
- QTest::qWait(100);
+ QTRY_COMPARE(item2->repaints, 1);
+ QCOMPARE(item3->repaints, 1);
item1->repaints = 0;
item2->repaints = 0;
@@ -8401,10 +8312,9 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem()
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect;
shadow->setOffset(-20, -20);
item1->setGraphicsEffect(shadow);
- QTest::qWait(50);
// Make sure all visible items are repainted.
- QCOMPARE(item1->repaints, 1);
+ QTRY_COMPARE(item1->repaints, 1);
QCOMPARE(item2->repaints, 1);
QCOMPARE(item3->repaints, 1);
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 97f3eb4a60..f9b6fe3ebd 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -612,7 +612,6 @@ void tst_QGraphicsLinearLayout::insertStretch()
}
}
- //QTest::qWait(1000);
delete widget;
}
@@ -639,7 +638,6 @@ void tst_QGraphicsLinearLayout::invalidate()
layout.setContentsMargins(0, 0, 0, 0);
view.show();
widget->show();
- //QTest::qWait(1000);
QVERIFY(QTest::qWaitForWindowExposed(&view));
qApp->processEvents();
layout.layoutRequest = 0;
@@ -1218,7 +1216,6 @@ void tst_QGraphicsLinearLayout::testStretch()
//view->setSceneRect(-50, -50, 800, 800);
//view->show();
//QVERIFY(QTest::qWaitForWindowExposed(view));
- //QTest::qWait(5000);
QCOMPARE(form->geometry().size(), QSizeF(600,600));
QCOMPARE(w1->geometry(), QRectF(0, 0, 100, 100));
QCOMPARE(w2->geometry(), QRectF(400, 0, 200, 200));
@@ -1521,7 +1518,7 @@ void tst_QGraphicsLinearLayout::removeLayout()
QGraphicsView view(&scene);
view.show();
- QTest::qWait(20);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QRectF r1 = textEdit->geometry();
QRectF r2 = pushButton->geometry();
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 3b340d06ab..0071c39f49 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -3108,7 +3108,6 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems()
// Check that everyone loses focus when the widget is hidden.
widget.hide();
- QTest::qWait(15);
QTRY_VERIFY(!view->hasFocus());
QVERIFY(!view->viewport()->hasFocus());
QVERIFY(!scene.hasFocus());
@@ -4056,7 +4055,6 @@ void tst_QGraphicsScene::isActive()
QVERIFY(!scene2.hasFocus());
toplevel1.hide();
- QTest::qWait(50);
QTRY_VERIFY(!scene1.isActive());
QTRY_VERIFY(!scene2.isActive());
QVERIFY(!scene1.hasFocus());
@@ -4381,7 +4379,6 @@ void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts()
QVERIFY(QTest::qWaitForWindowExposed(view));
view->repaints = 0;
proxy->update(10, 10, 10, 10);
- QTest::qWait(50);
QTRY_VERIFY(view->repaints > 0);
QPixmap pix;
@@ -4427,7 +4424,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
QVERIFY(QTest::qWaitForWindowExposed(view));
view->repaints = 0;
rectItem->update(10, 10, 10, 10);
- QTest::qWait(50);
QTRY_VERIFY(view->repaints > 0);
QPixmap pix;
@@ -4469,7 +4465,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
QVERIFY(QTest::qWaitForWindowExposed(view));
view->repaints = 0;
rectItem->update(10, 10, 10, 10);
- QTest::qWait(50);
QTRY_VERIFY(view->repaints > 0);
QPixmap pix;
@@ -4510,7 +4505,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
QVERIFY(QTest::qWaitForWindowExposed(view));
view->repaints = 0;
rectItem->update(10, 10, 10, 10);
- QTest::qWait(50);
QTRY_VERIFY(view->repaints > 0);
QPixmap pix;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 10129eb10c..f52bbce53a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -507,10 +507,8 @@ void tst_QGraphicsView::setScene()
view.setScene(0);
- QTest::qWait(25);
-
- QVERIFY(!view.horizontalScrollBar()->isVisible());
- QVERIFY(!view.verticalScrollBar()->isVisible());
+ QTRY_VERIFY(!view.horizontalScrollBar()->isVisible());
+ QTRY_VERIFY(!view.verticalScrollBar()->isVisible());
QVERIFY(!view.horizontalScrollBar()->isHidden());
QVERIFY(!view.verticalScrollBar()->isHidden());
@@ -572,13 +570,12 @@ void tst_QGraphicsView::sceneRect_growing()
QGraphicsView view(&scene, &toplevel);
view.setFixedSize(200, 200);
toplevel.show();
+ QVERIFY(QTest::qWaitForWindowActive(&toplevel));
int size = 200;
scene.setSceneRect(-size, -size, size * 2, size * 2);
QCOMPARE(view.sceneRect(), scene.sceneRect());
- QTest::qWait(25);
-
QPointF topLeft = view.mapToScene(0, 0);
for (int i = 0; i < 5; ++i) {
@@ -641,14 +638,14 @@ void tst_QGraphicsView::viewport()
QVERIFY(view.viewport() != 0);
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QPointer<QWidget> widget = new QWidget;
view.setViewport(widget);
QCOMPARE(view.viewport(), (QWidget *)widget);
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.setViewport(0);
QVERIFY(widget.isNull());
@@ -656,7 +653,7 @@ void tst_QGraphicsView::viewport()
QVERIFY(view.viewport() != widget);
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
}
#ifndef QT_NO_OPENGL
@@ -888,8 +885,6 @@ void tst_QGraphicsView::dragMode_rubberBand()
// We don't use QRubberBand as of 4.3; the band is drawn internally.
QVERIFY(!view.findChild<QRubberBand *>());
- QTest::qWait(25);
-
{
// Move
QMouseEvent event(QEvent::MouseMove,
@@ -902,8 +897,6 @@ void tst_QGraphicsView::dragMode_rubberBand()
QCOMPARE(view.horizontalScrollBar()->value(), horizontalScrollBarValue);
QCOMPARE(view.verticalScrollBar()->value(), verticalScrollBarValue);
- QTest::qWait(25);
-
{
// Release
QMouseEvent event(QEvent::MouseButtonRelease,
@@ -919,8 +912,6 @@ void tst_QGraphicsView::dragMode_rubberBand()
QCOMPARE(view.viewport()->cursor().shape(), cursorShape);
#endif
- QTest::qWait(25);
-
if (view.scene())
QCOMPARE(scene.selectedItems().size(), 1);
@@ -1074,7 +1065,7 @@ void tst_QGraphicsView::backgroundBrush()
QCOMPARE(scene.backgroundBrush(), QBrush(Qt::blue));
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
scene.setBackgroundBrush(QBrush());
QCOMPARE(scene.backgroundBrush(), QBrush());
@@ -1096,7 +1087,7 @@ void tst_QGraphicsView::foregroundBrush()
QCOMPARE(scene.foregroundBrush(), QBrush(Qt::blue));
view.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
scene.setForegroundBrush(QBrush());
QCOMPARE(scene.foregroundBrush(), QBrush());
@@ -2052,7 +2043,7 @@ void tst_QGraphicsView::mapFromSceneRect()
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
topLevel.show();
- QTest::qWait(25);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QPolygon polygon;
polygon << QPoint(98, 98);
@@ -2459,7 +2450,6 @@ void tst_QGraphicsView::viewportUpdateMode()
// Issue two scene updates.
scene.update(QRectF(0, 0, 10, 10));
scene.update(QRectF(20, 0, 10, 10));
- QTest::qWait(50);
// The view gets two updates for the update scene updates.
QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
@@ -2565,8 +2555,7 @@ void tst_QGraphicsView::viewportUpdateMode2()
view.lastUpdateRegions.clear();
viewPrivate->processPendingUpdates();
- QTest::qWait(50);
- QCOMPARE(view.lastUpdateRegions.size(), 1);
+ QTRY_COMPARE(view.lastUpdateRegions.size(), 1);
// Note that we adjust by 2 for antialiasing.
QCOMPARE(view.lastUpdateRegions.at(0), QRegion(boundingRect.adjusted(-2, -2, 2, 2) & viewportRect));
#endif
@@ -2763,8 +2752,7 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
// Make sure the view is repainted; otherwise the tests below will fail.
view.viewport()->repaint();
- QTest::qWait(200);
- QVERIFY(view.painted);
+ QTRY_VERIFY(view.painted);
// Make sure the painter's world transform is preserved after drawItems.
QTransform expectedTransform = view.viewportTransform();
@@ -3676,7 +3664,6 @@ void tst_QGraphicsView::centerOnDirtyItem()
toplevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
- QTest::qWait(50);
QImage before(view.viewport()->size(), QImage::Format_ARGB32);
view.viewport()->render(&before);
@@ -3684,8 +3671,6 @@ void tst_QGraphicsView::centerOnDirtyItem()
item->setPos(20, 0);
view.centerOn(item);
- QTest::qWait(50);
-
QImage after(view.viewport()->size(), QImage::Format_ARGB32);
view.viewport()->render(&after);
@@ -4279,8 +4264,6 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape2()
QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect()));
#endif
- QTest::qWait(50);
-
view.lastUpdateRegions.clear();
view.painted = false;
@@ -4478,7 +4461,7 @@ void tst_QGraphicsView::indirectPainting()
view.setOptimizationFlag(QGraphicsView::IndirectPainting);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(100);
+ QTRY_VERIFY(scene.drawCount > 0);
scene.drawCount = 0;
item->setPos(20, 20);
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index da52a7ea27..231474c71c 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -1168,8 +1168,7 @@ void tst_QAbstractItemView::task221955_selectedEditor()
//We set the focus to the button, the index need to be selected
button->setFocus();
- QTest::qWait(100);
- QVERIFY(tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
+ QTRY_VERIFY(tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
tree.setCurrentIndex(tree.model()->index(1,0));
QVERIFY(! tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
@@ -1179,7 +1178,6 @@ void tst_QAbstractItemView::task221955_selectedEditor()
tree.setSelectionMode(QAbstractItemView::NoSelection);
tree.clearSelection();
QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty());
- QTest::qWait(10);
button->setFocus();
QTest::qWait(50);
QVERIFY(tree.selectionModel()->selectedIndexes().isEmpty());
@@ -1267,15 +1265,11 @@ void tst_QAbstractItemView::task257481_emptyEditor()
QCOMPARE(lineEditors.count(), 1);
QVERIFY(!lineEditors.first()->size().isEmpty());
- QTest::qWait(30);
-
treeView.edit(model.index(1,0));
lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
QCOMPARE(lineEditors.count(), 1);
QVERIFY(!lineEditors.first()->size().isEmpty());
- QTest::qWait(30);
-
treeView.edit(model.index(2,0));
lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
QCOMPARE(lineEditors.count(), 1);
@@ -1462,7 +1456,6 @@ void tst_QAbstractItemView::QTBUG6407_extendedSelection()
QCOMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum());
- QTest::qWait(20);
QModelIndex index49 = view.model()->index(49,0);
QPoint p = view.visualRect(index49).center();
@@ -1506,7 +1499,6 @@ void tst_QAbstractItemView::QTBUG6753_selectOnSelection()
QRect itemRect = table.visualRect(item);
QTest::mouseMove(table.viewport(), itemRect.center());
QTest::mouseClick(table.viewport(), Qt::LeftButton, Qt::NoModifier, itemRect.center());
- QTest::qWait(20);
QCOMPARE(table.selectedItems().count(), 1);
QCOMPARE(table.selectedItems().first(), table.item(item.row(), item.column()));
diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
index 38e6d95ba4..58b34e8aea 100644
--- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
+++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
@@ -703,7 +703,7 @@ void tst_QColumnView::moveGrip()
view.setCurrentIndex(home);
view.resize(640, 200);
topLevel.show();
- QTest::qWait(ANIMATION_DELAY);
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
int columnNum = view.createdColumns.count() - 2;
QVERIFY(columnNum >= 0);
@@ -934,7 +934,6 @@ void tst_QColumnView::parentCurrentIndex()
QVERIFY(second.isValid());
QVERIFY(third.isValid());
view.setCurrentIndex(third);
- QTest::qWait(ANIMATION_DELAY);
QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first);
QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second);
QTRY_COMPARE(view.createdColumns[2]->currentIndex(), third);
@@ -946,7 +945,6 @@ void tst_QColumnView::parentCurrentIndex()
QVERIFY(second.isValid());
QVERIFY(third.isValid());
view.setCurrentIndex(third);
- QTest::qWait(ANIMATION_DELAY);
QTRY_COMPARE(view.createdColumns[0]->currentIndex(), first);
QTRY_COMPARE(view.createdColumns[1]->currentIndex(), second);
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 74a2f7f2b6..fd83228c8b 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -240,8 +240,8 @@ private slots:
void testStreamWithHide();
void testStylePosition();
void stretchAndRestoreLastSection();
- void testMinMaxSectionSizeStretched();
- void testMinMaxSectionSizeNotStretched();
+ void testMinMaxSectionSize_data();
+ void testMinMaxSectionSize();
void sizeHintCrash();
protected:
@@ -2268,22 +2268,21 @@ void tst_QHeaderView::QTBUG6058_reset()
QHeaderView view(Qt::Vertical);
view.setModel(&proxy);
view.show();
- QTest::qWait(20);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
proxy.setSourceModel(&model1);
- QApplication::processEvents();
view.swapSections(0,2);
view.swapSections(1,4);
- QApplication::processEvents();
- QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 4 << 0 << 3 << 1 << 5) , 0);
+ QVector<int> expectedOrder{2, 4, 0, 3, 1, 5};
+ QTRY_COMPARE(checkHeaderViewOrder(&view, expectedOrder) , 0);
proxy.setSourceModel(&model2);
- QApplication::processEvents();
- QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 ) , 0);
+ expectedOrder = {2, 0, 1};
+ QTRY_COMPARE(checkHeaderViewOrder(&view, expectedOrder) , 0);
proxy.setSourceModel(&model1);
- QApplication::processEvents();
- QCOMPARE(checkHeaderViewOrder(&view, QVector<int>() << 2 << 0 << 1 << 3 << 4 << 5 ) , 0);
+ expectedOrder = {2, 0, 1, 3, 4, 5};
+ QTRY_COMPARE(checkHeaderViewOrder(&view, expectedOrder) , 0);
}
void tst_QHeaderView::QTBUG7833_sectionClicked()
@@ -3269,28 +3268,17 @@ void tst_QHeaderView::stretchAndRestoreLastSection()
QCOMPARE(header.sectionSize(9), someOtherSectionSize);
}
-void tst_QHeaderView::testMinMaxSectionSizeStretched()
+void tst_QHeaderView::testMinMaxSectionSize_data()
{
- testMinMaxSectionSize(true);
+ QTest::addColumn<bool>("stretchLastSection");
+ QTest::addRow("stretched") << true;
+ QTest::addRow("not stretched") << false;
}
-void tst_QHeaderView::testMinMaxSectionSizeNotStretched()
+void tst_QHeaderView::testMinMaxSectionSize()
{
- testMinMaxSectionSize(false);
-}
+ QFETCH(bool, stretchLastSection);
-static void waitFor(const std::function<bool()> &func)
-{
- for (int i = 0; i < 100; i++)
- {
- if (func())
- return;
- QTest::qWait(10);
- }
-}
-
-void tst_QHeaderView::testMinMaxSectionSize(bool stretchLastSection)
-{
QStandardItemModel m(5, 5);
QTableView tv;
tv.setModel(&m);
@@ -3326,8 +3314,7 @@ void tst_QHeaderView::testMinMaxSectionSize(bool stretchLastSection)
header.resizeSection(0, sectionSizeMax);
QCOMPARE(header.sectionSize(0), sectionSizeMax);
header.setMaximumSectionSize(defaultSectionSize);
- waitFor([this, &header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; });
- QCOMPARE(header.sectionSize(0), defaultSectionSize);
+ QTRY_COMPARE(header.sectionSize(0), defaultSectionSize);
// change section size on min change
header.setMinimumSectionSize(sectionSizeMin);
@@ -3335,8 +3322,7 @@ void tst_QHeaderView::testMinMaxSectionSize(bool stretchLastSection)
header.resizeSection(0, sectionSizeMin);
QCOMPARE(header.sectionSize(0), sectionSizeMin);
header.setMinimumSectionSize(defaultSectionSize);
- waitFor([this, &header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; });
- QCOMPARE(header.sectionSize(0), defaultSectionSize);
+ QTRY_COMPARE(header.sectionSize(0), defaultSectionSize);
}
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 802a04b4bf..a8f6906056 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -1276,7 +1276,7 @@ void tst_QItemDelegate::enterKey()
view.show();
QApplication::setActiveWindow(&view);
view.setFocus();
- QTest::qWait(30);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
struct TestDelegate : public QItemDelegate
{
@@ -1306,7 +1306,6 @@ void tst_QItemDelegate::enterKey()
QModelIndex index = model.index(0, 0);
view.setCurrentIndex(index); // the editor will only selectAll on the current index
view.edit(index);
- QTest::qWait(30);
QList<QWidget*> lineEditors = view.viewport()->findChildren<QWidget *>(QString::fromLatin1("TheEditor"));
QCOMPARE(lineEditors.count(), 1);
@@ -1315,7 +1314,6 @@ void tst_QItemDelegate::enterKey()
QCOMPARE(editor->hasFocus(), true);
QTest::keyClick(editor, Qt::Key(key));
- QApplication::processEvents();
if (expectedFocus) {
QVERIFY(!editor.isNull());
@@ -1335,11 +1333,10 @@ void tst_QItemDelegate::task257859_finalizeEdit()
view.show();
QApplication::setActiveWindow(&view);
view.setFocus();
- QTest::qWait(30);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QModelIndex index = model.index(0, 0);
view.edit(index);
- QTest::qWait(30);
QList<QLineEdit *> lineEditors = view.viewport()->findChildren<QLineEdit *>();
QCOMPARE(lineEditors.count(), 1);
@@ -1454,28 +1451,26 @@ void tst_QItemDelegate::testLineEditValidation()
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- QList<QLineEdit *> lineEditors;
QPointer<QLineEdit> editor;
QPersistentModelIndex index = model.indexFromItem(item);
view.setCurrentIndex(index);
view.edit(index);
- QTest::qWait(30);
- lineEditors = view.findChildren<QLineEdit *>(QStringLiteral("TheEditor"));
- QCOMPARE(lineEditors.count(), 1);
- editor = lineEditors.at(0);
+ const auto findEditors = [&]() {
+ return view.findChildren<QLineEdit *>(QStringLiteral("TheEditor"));
+ };
+ QCOMPARE(findEditors().count(), 1);
+ editor = findEditors().at(0);
editor->clear();
// first try to set a valid text
QTest::keyClicks(editor, QStringLiteral("foo,bar"));
- QTest::qWait(30);
// close the editor
QTest::keyClick(editor, Qt::Key(key));
- QTest::qWait(30);
- QVERIFY(editor.isNull());
+ QTRY_VERIFY(editor.isNull());
if (key != Qt::Key_Escape)
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("foo,bar"));
else
@@ -1484,20 +1479,16 @@ void tst_QItemDelegate::testLineEditValidation()
// now an invalid (but partially matching) text
view.setCurrentIndex(index);
view.edit(index);
- QTest::qWait(30);
- lineEditors = view.findChildren<QLineEdit *>(QStringLiteral("TheEditor"));
- QCOMPARE(lineEditors.count(), 1);
- editor = lineEditors.at(0);
+ QTRY_COMPARE(findEditors().count(), 1);
+ editor = findEditors().at(0);
editor->clear();
// edit
QTest::keyClicks(editor, QStringLiteral("foobar"));
- QTest::qWait(30);
// try to close the editor
QTest::keyClick(editor, Qt::Key(key));
- QTest::qWait(30);
if (key != Qt::Key_Escape) {
QVERIFY(!editor.isNull());
@@ -1505,33 +1496,29 @@ void tst_QItemDelegate::testLineEditValidation()
QCOMPARE(editor->text(), QStringLiteral("foobar"));
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("foo,bar"));
} else {
- QVERIFY(editor.isNull());
+ QTRY_VERIFY(editor.isNull());
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("abc,def"));
}
// reset the view to forcibly close the editor
view.reset();
- QTest::qWait(30);
+ QTRY_COMPARE(findEditors().count(), 0);
// set a valid text again
view.setCurrentIndex(index);
view.edit(index);
- QTest::qWait(30);
- lineEditors = view.findChildren<QLineEdit *>(QStringLiteral("TheEditor"));
- QCOMPARE(lineEditors.count(), 1);
- editor = lineEditors.at(0);
+ QTRY_COMPARE(findEditors().count(), 1);
+ editor = findEditors().at(0);
editor->clear();
// set a valid text
QTest::keyClicks(editor, QStringLiteral("gender,bender"));
- QTest::qWait(30);
// close the editor
QTest::keyClick(editor, Qt::Key(key));
- QTest::qWait(30);
- QVERIFY(editor.isNull());
+ QTRY_VERIFY(editor.isNull());
if (key != Qt::Key_Escape)
QCOMPARE(item->data(Qt::DisplayRole).toString(), QStringLiteral("gender,bender"));
else
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 1d8286b3cf..d0c9dae313 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -293,7 +293,7 @@ public:
void tst_QListView::cleanup()
{
- QVERIFY(QApplication::topLevelWidgets().isEmpty());
+ QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QListView::noDelegate()
@@ -779,7 +779,6 @@ void tst_QListView::hideFirstRow()
view.setRowHidden(0,true);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QTest::qWait(10);
}
static int modelIndexCount(const QAbstractItemView *view)
@@ -857,7 +856,6 @@ void tst_QListView::setCurrentIndex()
QCOMPARE(sb->value(), offset + 1);
++offset;
}
- //QTest::qWait(50);
}
--i; // item 20 does not exist
@@ -870,7 +868,6 @@ void tst_QListView::setCurrentIndex()
QCOMPARE(sb->value(), offset - 1);
--offset;
}
- //QTest::qWait(50);
}
}
}
@@ -1397,21 +1394,17 @@ void tst_QListView::scrollBarAsNeeded()
lv.setModel(&model);
lv.resize(size);
topLevel.show();
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
for (uint r = 0; r < sizeof(rowCounts)/sizeof(int); ++r) {
QStringList list;
- int i;
- for (i = 0; i < rowCounts[r]; ++i)
+ for (int i = 0; i < rowCounts[r]; ++i)
list << QLatin1String("Item ") + QString::number(i);
model.setStringList(list);
- QApplication::processEvents();
- QTest::qWait(50);
model.setStringList(generateList(QLatin1String("Item "), itemCount));
- QApplication::processEvents();
-
QTRY_COMPARE(lv.horizontalScrollBar()->isVisible(), horizontalScrollBarVisible);
QTRY_COMPARE(lv.verticalScrollBar()->isVisible(), verticalScrollBarVisible);
}
@@ -1577,14 +1570,14 @@ void tst_QListView::task228566_infiniteRelayout()
view.setFixedHeight(itemHeight * 12);
view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::qWait(100); //make sure the layout is done once
QSignalSpy spy(view.horizontalScrollBar(), SIGNAL(rangeChanged(int,int)));
- QTest::qWait(200);
//the layout should already have been done
//so there should be no change made to the scrollbar
- QCOMPARE(spy.count(), 0);
+ QVERIFY(!spy.wait(200));
}
void tst_QListView::task248430_crashWith0SizedItem()
@@ -1619,7 +1612,7 @@ void tst_QListView::task250446_scrollChanged()
QTRY_COMPARE(view.currentIndex(), index);
view.showNormal();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QTRY_COMPARE(view.verticalScrollBar()->value(), scrollValue);
QTRY_COMPARE(view.currentIndex(), index);
}
@@ -1709,19 +1702,14 @@ void tst_QListView::keyboardSearch()
qApp->setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
-// QCOMPARE(view.currentIndex() , model.index(0,0));
-
QTest::keyClick(&view, Qt::Key_K);
- QTest::qWait(10);
- QCOMPARE(view.currentIndex() , model.index(5,0)); //KAFEINE
+ QTRY_COMPARE(view.currentIndex() , model.index(5,0)); //KAFEINE
QTest::keyClick(&view, Qt::Key_O);
- QTest::qWait(10);
- QCOMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
+ QTRY_COMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
QTest::keyClick(&view, Qt::Key_N);
- QTest::qWait(10);
- QCOMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
+ QTRY_COMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
}
void tst_QListView::shiftSelectionWithNonUniformItemSizes()
@@ -1751,8 +1739,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
QCOMPARE(view.currentIndex(), index);
QTest::keyClick(&view, Qt::Key_Up, Qt::ShiftModifier);
- QTest::qWait(10);
- QCOMPARE(view.currentIndex(), model.index(1, 0));
+ QTRY_COMPARE(view.currentIndex(), model.index(1, 0));
QModelIndexList selected = view.selectionModel()->selectedIndexes();
QCOMPARE(selected.count(), 3);
@@ -1781,8 +1768,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
QCOMPARE(view.currentIndex(), index);
QTest::keyClick(&view, Qt::Key_Left, Qt::ShiftModifier);
- QTest::qWait(10);
- QCOMPARE(view.currentIndex(), model.index(1, 0));
+ QTRY_COMPARE(view.currentIndex(), model.index(1, 0));
QModelIndexList selected = view.selectionModel()->selectedIndexes();
QCOMPARE(selected.count(), 3);
@@ -1833,10 +1819,8 @@ void tst_QListView::task262152_setModelColumnNavigate()
QVERIFY(QTest::qWaitForWindowActive(&view));
QCOMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
QTest::keyClick(&view, Qt::Key_Down);
- QTest::qWait(30);
QTRY_COMPARE(view.currentIndex(), model.index(1,1));
QTest::keyClick(&view, Qt::Key_Down);
- QTest::qWait(30);
QTRY_COMPARE(view.currentIndex(), model.index(2,1));
}
@@ -1888,14 +1872,11 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenItems()
int nbVisibleItem = rowCount / 2 - bar->maximum();
bar->setValue(bar->maximum());
- QApplication::processEvents();
for (int i = rowCount; i > rowCount / 2; i--) {
view.setRowHidden(i, true);
}
- QApplication::processEvents();
- QTest::qWait(50);
+ QTRY_COMPARE(bar->maximum(), rowCount/4 - nbVisibleItem);
QCOMPARE(bar->value(), bar->maximum());
- QCOMPARE(bar->maximum(), rowCount/4 - nbVisibleItem);
}
void tst_QListView::taskQTBUG_633_changeModelData()
@@ -1911,10 +1892,12 @@ void tst_QListView::taskQTBUG_633_changeModelData()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
model.setData( model.index(1, 0), QLatin1String("long long text"));
- QTest::qWait(100); //leave time for relayouting the items
- QRect rectLongText = view.visualRect(model.index(1,0));
- QRect rect2 = view.visualRect(model.index(2,0));
- QVERIFY( ! rectLongText.intersects(rect2) );
+ const auto longTextDoesNotIntersectNextItem = [&]() {
+ QRect rectLongText = view.visualRect(model.index(1,0));
+ QRect rect2 = view.visualRect(model.index(2,0));
+ return !rectLongText.intersects(rect2);
+ };
+ QTRY_VERIFY(longTextDoesNotIntersectNextItem());
}
void tst_QListView::taskQTBUG_435_deselectOnViewportClick()
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index f7332a15f5..98b44fe8aa 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -1565,7 +1565,7 @@ void tst_QListWidget::task217070_scrollbarsAdjusted()
v.setResizeMode(QListView::Adjust);
v.setUniformItemSizes(true);
v.resize(160,100);
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowActive(&v));
QScrollBar *hbar = v.horizontalScrollBar();
QScrollBar *vbar = v.verticalScrollBar();
QVERIFY(hbar && vbar);
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 06c80bf8d2..8427b04be7 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -2781,15 +2781,14 @@ void tst_QTableView::scrollTo()
for (int c = 0; c < columnCount; ++c)
view.setColumnWidth(c, columnWidth);
- QTest::qWait(150); // ### needed to pass the test
view.horizontalScrollBar()->setValue(horizontalScroll);
view.verticalScrollBar()->setValue(verticalScroll);
QModelIndex index = model.index(row, column);
QVERIFY(index.isValid());
view.scrollTo(index, (QAbstractItemView::ScrollHint)scrollHint);
- QCOMPARE(view.verticalScrollBar()->value(), expectedVerticalScroll);
- QCOMPARE(view.horizontalScrollBar()->value(), expectedHorizontalScroll);
+ QTRY_COMPARE(view.verticalScrollBar()->value(), expectedVerticalScroll);
+ QTRY_COMPARE(view.horizontalScrollBar()->value(), expectedHorizontalScroll);
}
void tst_QTableView::indexAt_data()
@@ -2936,14 +2935,12 @@ void tst_QTableView::indexAt()
for (int c = 0; c < columnCount; ++c)
view.setColumnWidth(c, columnWidth);
- QTest::qWait(20);
view.horizontalScrollBar()->setValue(horizontalScroll);
view.verticalScrollBar()->setValue(verticalScroll);
- QTest::qWait(20);
QModelIndex index = view.indexAt(QPoint(x, y));
- QCOMPARE(index.row(), expectedRow);
- QCOMPARE(index.column(), expectedColumn);
+ QTRY_COMPARE(index.row(), expectedRow);
+ QTRY_COMPARE(index.column(), expectedColumn);
}
void tst_QTableView::span_data()
@@ -3261,7 +3258,7 @@ void tst_QTableView::spansAfterRowInsertion()
view.setModel(&model);
view.setSpan(3, 3, 3, 3);
view.show();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
// Insertion before the span only shifts the span.
view.model()->insertRows(0, 2);
@@ -3297,7 +3294,7 @@ void tst_QTableView::spansAfterColumnInsertion()
view.setModel(&model);
view.setSpan(3, 3, 3, 3);
view.show();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
// Insertion before the span only shifts the span.
view.model()->insertColumns(0, 2);
@@ -3345,7 +3342,7 @@ void tst_QTableView::spansAfterRowRemoval()
view.setSpan(span.top(), span.left(), span.height(), span.width());
view.show();
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
view.model()->removeRows(3, 3);
QList<QRect> expectedSpans;
@@ -3385,7 +3382,7 @@ void tst_QTableView::spansAfterColumnRemoval()
view.setSpan(span.left(), span.top(), span.width(), span.height());
view.show();
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
view.model()->removeColumns(3, 3);
QList<QRect> expectedSpans;
@@ -4083,7 +4080,6 @@ void tst_QTableView::task259308_scrollVerticalHeaderSwappedSections()
QTRY_COMPARE(tv.currentIndex().row(), newRow);
tv.setCurrentIndex(model.index(0, 0));
- QTest::qWait(60);
QTest::keyClick(&tv, Qt::Key_PageDown); // PageDown won't scroll when at the bottom
QTRY_COMPARE(tv.rowAt(tv.viewport()->height() - 1), tv.verticalHeader()->logicalIndex(model.rowCount() - 1));
}
@@ -4104,7 +4100,7 @@ void tst_QTableView::task191545_dragSelectRows()
table.setSelectionMode(QAbstractItemView::ExtendedSelection);
table.setMinimumSize(1000, 400);
table.show();
- QTest::qWait(200);
+ QVERIFY(QTest::qWaitForWindowActive(&table));
ValueSaver<Qt::KeyboardModifiers> saver(QApplicationPrivate::modifier_buttons);
QApplicationPrivate::modifier_buttons = Qt::ControlModifier;
@@ -4214,27 +4210,22 @@ void tst_QTableView::task234926_setHeaderSorting()
QTableView view;
view.setModel(&model);
// view.show();
- QTest::qWait(20);
- QCOMPARE(model.stringList(), data);
+ QTRY_COMPARE(model.stringList(), data);
view.setSortingEnabled(true);
view.sortByColumn(0, Qt::AscendingOrder);
- QApplication::processEvents();
- QCOMPARE(model.stringList() , sortedDataA);
+ QTRY_COMPARE(model.stringList() , sortedDataA);
view.horizontalHeader()->setSortIndicator(0, Qt::DescendingOrder);
- QApplication::processEvents();
- QCOMPARE(model.stringList() , sortedDataD);
+ QTRY_COMPARE(model.stringList() , sortedDataD);
QHeaderView *h = new QHeaderView(Qt::Horizontal);
h->setModel(&model);
view.setHorizontalHeader(h);
h->setSortIndicator(0, Qt::AscendingOrder);
- QApplication::processEvents();
- QCOMPARE(model.stringList() , sortedDataA);
+ QTRY_COMPARE(model.stringList() , sortedDataA);
h->setSortIndicator(0, Qt::DescendingOrder);
- QApplication::processEvents();
- QCOMPARE(model.stringList() , sortedDataD);
+ QTRY_COMPARE(model.stringList() , sortedDataD);
}
void tst_QTableView::taskQTBUG_5062_spansInconsistency()
@@ -4288,9 +4279,8 @@ void tst_QTableView::changeHeaderData()
QVERIFY(view.verticalHeader()->width() < textWidth);
model.setHeaderData(2, Qt::Vertical, text);
- QTest::qWait(100); //leave time for layout
- QVERIFY(view.verticalHeader()->width() > textWidth);
+ QTRY_VERIFY(view.verticalHeader()->width() > textWidth);
}
#if QT_CONFIG(wheelevent)
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 347d2a81e6..4c637573d0 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -3464,6 +3464,7 @@ void tst_QTreeView::addRowsWhileSectionsAreHidden()
QStandardItemModel *model = new QStandardItemModel(6, pass, &view);
view.setModel(model);
view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
int i;
for (i = 0; i < 3; ++i)
@@ -3487,12 +3488,15 @@ void tst_QTreeView::addRowsWhileSectionsAreHidden()
}
for (col = 0; col < pass; ++col)
view.setColumnHidden(col, false);
- QTest::qWait(250);
- for (i = 0; i < 6; ++i) {
- QRect rect = view.visualRect(model->index(i, 0));
- QCOMPARE(rect.isValid(), true);
- }
+ auto allVisualRectsValid = [](QTreeView *view, QStandardItemModel *model) {
+ for (int i = 0; i < 6; ++i) {
+ if (!view->visualRect(model->index(i, 0)).isValid())
+ return false;
+ }
+ return true;
+ };
+ QTRY_VERIFY(allVisualRectsValid(&view, model));
delete model;
}
@@ -3515,11 +3519,9 @@ void tst_QTreeView::task216717_updateChildren()
tree.refreshed = false;
QTreeWidgetItem *parent = new QTreeWidgetItem(QStringList() << "parent");
tree.addTopLevelItem(parent);
- QTest::qWait(10);
QTRY_VERIFY(tree.refreshed);
tree.refreshed = false;
parent->addChild(new QTreeWidgetItem(QStringList() << "child"));
- QTest::qWait(10);
QTRY_VERIFY(tree.refreshed);
}
@@ -3553,11 +3555,10 @@ void tst_QTreeView::task220298_selectColumns()
Model model;
view.setModel(&model);
view.show();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0,
view.visualRect(view.model()->index(1, 1)).center());
- QTest::qWait(50);
- QVERIFY(view.selectedIndexes().contains(view.model()->index(1, 2)));
+ QTRY_VERIFY(view.selectedIndexes().contains(view.model()->index(1, 2)));
QVERIFY(view.selectedIndexes().contains(view.model()->index(1, 1)));
QVERIFY(view.selectedIndexes().contains(view.model()->index(1, 0)));
}
@@ -3575,15 +3576,14 @@ void tst_QTreeView::task224091_appendColumns()
qApp->setActiveWindow(topLevel);
QVERIFY(QTest::qWaitForWindowActive(topLevel));
+ QVERIFY(!treeView->verticalScrollBar()->isVisible());
+
QList<QStandardItem *> projlist;
for (int k = 0; k < 10; ++k)
projlist.append(new QStandardItem(QLatin1String("Top Level ") + QString::number(k)));
model->appendColumn(projlist);
model->invisibleRootItem()->appendRow(new QStandardItem("end"));
- QTest::qWait(50);
- qApp->processEvents();
-
QTRY_VERIFY(treeView->verticalScrollBar()->isVisible());
delete topLevel;
@@ -3741,11 +3741,10 @@ void tst_QTreeView::task238873_avoidAutoReopening()
view.setModel(&model);
view.show();
view.expandAll();
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.visualRect(child.index()).center());
- QTest::qWait(20);
- QCOMPARE(view.currentIndex(), child.index());
+ QTRY_COMPARE(view.currentIndex(), child.index());
view.setExpanded(item1.index(), false);
@@ -3810,7 +3809,6 @@ void tst_QTreeView::task246536_scrollbarsNotWorking()
QTest::qWait(100);
o.count = 0;
tree.verticalScrollBar()->setValue(50);
- QTest::qWait(100);
QTRY_VERIFY(o.count > 0);
}
@@ -3826,7 +3824,7 @@ void tst_QTreeView::task250683_wrongSectionSize()
treeView.setColumnHidden(3, true);
treeView.show();
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(&treeView));
QCOMPARE(treeView.header()->sectionSize(0) + treeView.header()->sectionSize(1), treeView.viewport()->width());
}
@@ -3863,7 +3861,6 @@ void tst_QTreeView::task239271_addRowsWithFirstColumnHidden()
QStandardItem sub1("sub1"), sub11("sub11");
root0.appendRow(QList<QStandardItem*>() << &sub1 << &sub11);
- QTest::qWait(20);
//items in the 2nd column should have been painted
QTRY_VERIFY(!delegate.paintedIndexes.isEmpty());
QVERIFY(delegate.paintedIndexes.contains(sub00.index()));
@@ -3976,7 +3973,6 @@ void tst_QTreeView::doubleClickedWithSpans()
//end the previous edition
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p);
- QTest::qWait(150);
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, p);
QTest::mouseDClick(view.viewport(), Qt::LeftButton, 0, p);
QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, p);
@@ -4041,7 +4037,6 @@ void tst_QTreeView::taskQTBUG_9216_setSizeAndUniformRowHeightsWrongRepaint()
view.painted = 0;
view.doCompare = true;
model.setData(model.index(0, 0), QVariant(QSize(50, 50)), Qt::SizeHintRole);
- QTest::qWait(100);
QTRY_VERIFY(view.painted > 0);
}
@@ -4249,7 +4244,6 @@ void tst_QTreeView::taskQTBUG_11466_keyboardNavigationRegression()
QVERIFY(QTest::qWaitForWindowExposed(&treeView));
QTest::keyPress(treeView.viewport(), Qt::Key_Down);
- QTest::qWait(10);
QTRY_COMPARE(treeView.currentIndex(), treeView.selectionModel()->selection().indexes().first());
}
@@ -4269,8 +4263,7 @@ void tst_QTreeView::taskQTBUG_13567_removeLastItemRegression()
view.setCurrentIndex(model.index(199, 0));
model.removeLastRow();
- QTest::qWait(10);
- QCOMPARE(view.currentIndex(), model.index(198, 0));
+ QTRY_COMPARE(view.currentIndex(), model.index(198, 0));
CHECK_VISIBLE(198, 0);
}
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index d0e6407283..321e4bcd0e 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -2026,7 +2026,6 @@ void tst_QTreeWidget::setHeaderItem()
headerItem->setText(0, "0");
headerItem->setText(1, "1");
testWidget->setHeaderItem(headerItem);
- QTest::qWait(100);
QCOMPARE(testWidget->headerItem(), headerItem);
QCOMPARE(headerItem->treeWidget(), static_cast<QTreeWidget *>(testWidget));
@@ -2981,7 +2980,7 @@ void tst_QTreeWidget::task191552_rtl()
item->setCheckState(0, Qt::Checked);
QCOMPARE(item->checkState(0), Qt::Checked);
tw.show();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowActive(&tw));
QStyleOptionViewItem opt;
opt.initFrom(&tw);
opt.rect = tw.visualItemRect(item);
@@ -2991,7 +2990,6 @@ void tst_QTreeWidget::task191552_rtl()
opt.widget = &tw;
const QRect checkRect = tw.style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, &tw);
QTest::mouseClick(tw.viewport(), Qt::LeftButton, Qt::NoModifier, checkRect.center());
- QTest::qWait(200);
QCOMPARE(item->checkState(0), Qt::Unchecked);
qApp->setLayoutDirection(oldDir);
@@ -3088,7 +3086,7 @@ void tst_QTreeWidget::task253109_itemHeight()
QTreeWidget treeWidget;
treeWidget.setColumnCount(1);
treeWidget.show();
- QTest::qWait(200);
+ QVERIFY(QTest::qWaitForWindowActive(&treeWidget));
QTreeWidgetItem item(&treeWidget);
class MyWidget : public QWidget
@@ -3097,9 +3095,7 @@ void tst_QTreeWidget::task253109_itemHeight()
} w;
treeWidget.setItemWidget(&item, 0, &w);
- QTest::qWait(200);
- QCOMPARE(w.geometry(), treeWidget.visualItemRect(&item));
-
+ QTRY_COMPARE(w.geometry(), treeWidget.visualItemRect(&item));
}
void tst_QTreeWidget::task206367_duplication()
@@ -3306,16 +3302,15 @@ void tst_QTreeWidget::setTextUpdate()
treeWidget.setItemDelegate(&delegate);
treeWidget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&treeWidget));
QStringList strList;
strList << "variable1" << "0";
QTreeWidgetItem *item = new QTreeWidgetItem(strList);
treeWidget.insertTopLevelItem(0, item);
- QTest::qWait(50);
QTRY_VERIFY(delegate.numPaints > 0);
delegate.numPaints = 0;
item->setText(1, "42");
- QApplication::processEvents();
QTRY_VERIFY(delegate.numPaints > 0);
}
@@ -3356,34 +3351,30 @@ void tst_QTreeWidget::setChildIndicatorPolicy()
treeWidget.setItemDelegate(&delegate);
treeWidget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&treeWidget));
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList("Hello"));
treeWidget.insertTopLevelItem(0, item);
- QTest::qWait(50);
QTRY_VERIFY(delegate.numPaints > 0);
delegate.numPaints = 0;
delegate.expectChildren = true;
item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
- QApplication::processEvents();
QTRY_COMPARE(delegate.numPaints, 1);
delegate.numPaints = 0;
delegate.expectChildren = false;
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
- QApplication::processEvents();
QTRY_COMPARE(delegate.numPaints, 1);
delegate.numPaints = 0;
delegate.expectChildren = true;
new QTreeWidgetItem(item);
- QApplication::processEvents();
QTRY_COMPARE(delegate.numPaints, 1);
delegate.numPaints = 0;
delegate.expectChildren = false;
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
- QApplication::processEvents();
QTRY_COMPARE(delegate.numPaints, 1);
}
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index ddf9ccb416..3d68e42baf 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -67,6 +67,7 @@ private slots:
void keysequence(); // QTBUG-53381
void disableShortcutsWithBlockedWidgets_data();
void disableShortcutsWithBlockedWidgets();
+ void shortcutFromKeyEvent(); // QTBUG-48325
private:
int m_lastEventType;
@@ -509,5 +510,41 @@ void tst_QAction::disableShortcutsWithBlockedWidgets()
QCOMPARE(spy.count(), 0);
}
+class ShortcutOverrideWidget : public QWidget
+{
+public:
+ ShortcutOverrideWidget(QWidget *parent = 0) : QWidget(parent), shortcutOverrideCount(0) {}
+ int shortcutOverrideCount;
+protected:
+ bool event(QEvent *e)
+ {
+ if (e->type() == QEvent::ShortcutOverride)
+ ++shortcutOverrideCount;
+ return QWidget::event(e);
+ }
+};
+
+// Test that a key press event sent with sendEvent() still gets handled as a possible
+// ShortcutOverride event first before passing it on as a normal KeyEvent.
+void tst_QAction::shortcutFromKeyEvent()
+{
+ ShortcutOverrideWidget testWidget;
+ QAction action;
+ action.setShortcut(Qt::Key_1);
+ testWidget.addAction(&action);
+ testWidget.show();
+ QSignalSpy spy(&action, &QAction::triggered);
+ QVERIFY(spy.isValid());
+ QVERIFY(QTest::qWaitForWindowActive(&testWidget));
+ QCOMPARE(testWidget.shortcutOverrideCount, 0);
+
+ // Don't use the QTest::keyPress approach as this will take the
+ // shortcut route for us
+ QKeyEvent e(QEvent::KeyPress, Qt::Key_1, Qt::NoModifier);
+ QApplication::sendEvent(&testWidget, &e);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(testWidget.shortcutOverrideCount, 1);
+}
+
QTEST_MAIN(tst_QAction)
#include "tst_qaction.moc"
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index c70ac0309f..5301dababc 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -288,7 +288,6 @@ void tst_QApplication::alert()
widget2.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QVERIFY(QTest::qWaitForWindowExposed(&widget2));
- QTest::qWait(100);
app.alert(&widget, -1);
app.alert(&widget, 250);
widget2.activateWindow();
@@ -1711,6 +1710,7 @@ void tst_QApplication::focusOut()
le2->setStyleSheet("background: #fee");
le2->move(100, 100);
w.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
QTest::qWait(2000);
le2->setFocus();
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 2f1a305710..8314dbedf5 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -226,15 +226,13 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing()
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- int spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
- QCOMPARE(spacing, 6);
+ auto spacing = [&]() { return pb2->geometry().left() - pb1->geometry().right() - 1; };
+ QCOMPARE(spacing(), 6);
QScopedPointer<CustomLayoutStyle> style2(new CustomLayoutStyle());
style2->hspacing = 10;
window.setStyle(style2.data());
- QTest::qWait(100);
- spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
- QCOMPARE(spacing, 10);
+ QTRY_COMPARE(spacing(), 10);
}
void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 1ccda25339..162da61584 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -164,7 +164,7 @@ private slots:
void tst_QFormLayout::cleanup()
{
- QVERIFY(QApplication::topLevelWidgets().isEmpty());
+ QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QFormLayout::rowCount()
@@ -1188,7 +1188,6 @@ void tst_QFormLayout::layoutAlone()
w.setWindowTitle(QTest::currentTestFunction());
w.show();
layout.activate();
- QTest::qWait(500);
}
void tst_QFormLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 40a2319910..5e0327319b 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -1441,7 +1441,6 @@ void tst_QGridLayout::layoutSpacing()
QLayout *layout = widget->layout();
QVERIFY(layout);
- //QTest::qWait(2000);
for (int pi = 0; pi < expectedpositions.count(); ++pi) {
QLayoutItem *item = layout->itemAt(pi);
//qDebug() << item->widget()->pos();
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index ff35b0cdb1..b78287f84b 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -604,7 +604,7 @@ void tst_QShortcut::disabledItems()
{
clearAllShortcuts();
mainW->activateWindow();
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(mainW));
/* Testing Disabled Shortcuts
Qt::Key_M on slot1
diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
index 5be4846b3e..10712ea9ad 100644
--- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
+++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
@@ -103,7 +103,7 @@ void tst_QStackedLayout::init()
// make sure the tests work with focus follows mouse
QCursor::setPos(testWidget->geometry().center());
testWidget->activateWindow();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(testWidget));
}
void tst_QStackedLayout::cleanup()
@@ -251,24 +251,13 @@ void tst_QStackedLayout::removeWidget()
testLayout->addWidget(w2);
vbox->addLayout(testLayout);
top->setFocus();
- QTest::qWait(100);
top->activateWindow();
- QTest::qWait(100);
- int i =0;
- for (;;) {
- if (QApplication::focusWidget() == top)
- break;
- else if (i >= 5)
- QSKIP("Can't get focus");
- QTest::qWait(100);
- ++i;
- }
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(top));
+ QTRY_COMPARE(QApplication::focusWidget(), top);
// focus should stay at the 'top' widget
testLayout->removeWidget(w1);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(top));
+ QCOMPARE(QApplication::focusWidget(), top);
}
class LineEdit : public QLineEdit
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 02cdd1a895..6cebce26e8 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -20,6 +20,8 @@ osx
[setGeometry]
osx
[raise]
+# QTBUG-68175
+opensuse
osx
[resizeEvent]
osx
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 823a52ce70..47ffee1501 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -401,6 +401,8 @@ private slots:
void tabletTracking();
+ void closeEvent();
+
private:
bool ensureScreenSize(int width, int height);
@@ -10798,5 +10800,31 @@ void tst_QWidget::tabletTracking()
QTRY_COMPARE(widget.moveEventCount, 3);
}
+class CloseCountingWidget : public QWidget
+{
+public:
+ int closeCount = 0;
+ void closeEvent(QCloseEvent *ev) override;
+};
+
+void CloseCountingWidget::closeEvent(QCloseEvent *ev)
+{
+ ++closeCount;
+ ev->accept();
+}
+
+void tst_QWidget::closeEvent()
+{
+ CloseCountingWidget widget;
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ // Yes we call the close() function twice. This mimics the behavior of QTBUG-43344 where
+ // QApplication first closes all windows and then QCocoaApplication flushes window system
+ // events, triggering more close events.
+ widget.windowHandle()->close();
+ widget.windowHandle()->close();
+ QCOMPARE(widget.closeCount, 1);
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index a3e549aa50..c9c8e193b3 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -146,13 +146,7 @@ void tst_QWindowContainer::testExposeObscure()
container->hide();
- QElapsedTimer timer;
- timer.start();
- while (window->numberOfObscures == 0 && timer.elapsed() < 5000) {
- QTest::qWait(10);
- }
-
- QVERIFY(window->numberOfObscures > 0);
+ QTRY_VERIFY(window->numberOfObscures > 0);
}
@@ -345,11 +339,9 @@ void tst_QWindowContainer::testDockWidget()
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
QCOMPARE(window->parent(), mainWindow.window()->windowHandle());
- QTest::qWait(1000);
dock->setFloating(true);
QTRY_VERIFY(window->parent() != mainWindow.window()->windowHandle());
- QTest::qWait(1000);
dock->setFloating(false);
QTRY_COMPARE(window->parent(), mainWindow.window()->windowHandle());
}
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 7953077152..28a099de83 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -1136,7 +1136,7 @@ void tst_QStyleSheetStyle::minmaxSizes()
centerOnScreen(&tabWidget);
tabWidget.show();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowActive(&tabWidget));
//i allow 4px additional border from the native style (hence the -2, <=2)
QVERIFY(qAbs(page2->maximumSize().width() - 500 - 2) <= 2);
QVERIFY(qAbs(page2->minimumSize().width() - 250 - 2) <= 2);
@@ -1165,7 +1165,7 @@ void tst_QStyleSheetStyle::task206238_twice()
w.setStyleSheet("background: red;");
centerOnScreen(&w);
w.show();
- QTest::qWait(20);
+ QVERIFY(QTest::qWaitForWindowActive(&w));
QCOMPARE(BACKGROUND(w) , red);
QCOMPARE(BACKGROUND(*tw), red);
w.setStyleSheet("background: red;");
@@ -1366,8 +1366,7 @@ void tst_QStyleSheetStyle::proxyStyle()
layout->addWidget(pb5);
w->show();
-
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(w));
// Test for QTBUG-7198 - style sheet overrides custom element size
QStyleOptionViewItem opt;
@@ -1557,9 +1556,9 @@ void tst_QStyleSheetStyle::embeddedFonts()
box.addItems(QStringList() << "First" << "Second" << "Third");
box.setStyleSheet("QComboBox { font-size: 32px; }");
box.show();
+ QVERIFY(QTest::qWaitForWindowActive(&box));
embedded = box.findChild<QLineEdit *>();
QVERIFY(embedded);
- QTest::qWait(20);
QCOMPARE(box.font().pixelSize(), 32);
QCOMPARE(embedded->font().pixelSize(), 32);
}
@@ -1652,7 +1651,7 @@ void tst_QStyleSheetStyle::task188195_baseBackground()
tree.setStyleSheet( "QTreeView:disabled { background-color:#ab1251; }" );
tree.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 100));
tree.show();
- QTest::qWait(20);
+ QVERIFY(QTest::qWaitForWindowActive(&tree));
QImage image(tree.width(), tree.height(), QImage::Format_ARGB32);
tree.render(&image);
@@ -1673,7 +1672,7 @@ void tst_QStyleSheetStyle::task188195_baseBackground()
table.setStyleSheet( "QTableView {background-color: #ff0000}" );
table.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(300, 100));
table.show();
- QTest::qWait(20);
+ QVERIFY(QTest::qWaitForWindowActive(&table));
image = QImage(table.width(), table.height(), QImage::Format_ARGB32);
table.render(&image);
QVERIFY(testForColors(image, Qt::red, true));
diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
index bc7756d32f..e77faa1e75 100644
--- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
@@ -473,14 +473,9 @@ void tst_QAbstractButton::setShortcut()
QKeySequence seq( Qt::Key_A );
testWidget->setShortcut( seq );
QApplication::setActiveWindow(testWidget);
-
+ testWidget->activateWindow();
// must be active to get shortcuts
- for (int i = 0; !testWidget->isActiveWindow() && i < 100; ++i) {
- testWidget->activateWindow();
- QApplication::instance()->processEvents();
- QTest::qWait(100);
- }
- QVERIFY(testWidget->isActiveWindow());
+ QVERIFY(QTest::qWaitForWindowActive(testWidget));
QTest::keyClick( testWidget, 'A' );
QTest::qWait(300); // Animate click takes time
@@ -508,9 +503,7 @@ void tst_QAbstractButton::animateClick()
QVERIFY( testWidget->isDown() );
qApp->processEvents();
QVERIFY( testWidget->isDown() );
- QTest::qWait(200);
- qApp->processEvents();
- QVERIFY( !testWidget->isDown() );
+ QTRY_VERIFY( !testWidget->isDown() );
}
void tst_QAbstractButton::shortcutEvents()
@@ -614,7 +607,7 @@ void tst_QAbstractButton::keyNavigation()
widget.show();
qApp->setActiveWindow(&widget);
widget.activateWindow();
- QTest::qWait(30);
+ QVERIFY(QTest::qWaitForWindowActive(&widget));
buttons[1][1]->setFocus();
QTest::qWait(400);
diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
index 60efcddc60..372a467ada 100644
--- a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
+++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
@@ -346,6 +346,7 @@ void tst_QAbstractScrollArea::patternBackground()
widget.resize(600, 600);
scrollArea.setWidget(&widget);
topLevel.show();
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
QLinearGradient linearGrad(QPointF(250, 250), QPointF(300, 300));
linearGrad.setColorAt(0, Qt::yellow);
@@ -354,7 +355,6 @@ void tst_QAbstractScrollArea::patternBackground()
scrollArea.viewport()->setPalette(QPalette(Qt::black, bg, bg, bg, bg, bg, bg, bg, bg));
widget.setPalette(Qt::transparent);
- QTest::qWait(50);
QImage image(200, 200, QImage::Format_ARGB32);
scrollArea.render(&image);
@@ -366,7 +366,6 @@ void tst_QAbstractScrollArea::patternBackground()
QScrollBar *vbar = scrollArea.verticalScrollBar();
vbar->setValue(vbar->maximum());
- QTest::qWait(50);
scrollArea.render(&image);
QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
index 8e4a800a75..5c0f4b1536 100644
--- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
+++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
@@ -174,12 +174,10 @@ void tst_QCalendarWidget::buttonClickCheck()
QTest::mouseClick(button, Qt::LeftButton, Qt::NoModifier, button->rect().center(), 2);
QVERIFY(!button->isVisible());
QSpinBox *spinbox = object.findChild<QSpinBox *>("qt_calendar_yearedit");
- QTest::qWait(500);
QTest::keyClick(spinbox, '2');
QTest::keyClick(spinbox, '0');
QTest::keyClick(spinbox, '0');
QTest::keyClick(spinbox, '6');
- QTest::qWait(500);
QWidget *widget = object.findChild<QWidget *>("qt_calendar_calendarview");
QTest::mouseMove(widget);
QTest::mouseClick(widget, Qt::LeftButton);
@@ -305,7 +303,6 @@ void tst_QCalendarWidget::showPrevNext()
QCOMPARE(calWidget.monthShown(), expectedDate.month());
// QTBUG-4058
- QTest::qWait(20);
QToolButton *button = calWidget.findChild<QToolButton *>("qt_calendar_prevmonth");
QTest::mouseClick(button, Qt::LeftButton);
expectedDate = expectedDate.addMonths(-1);
diff --git a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
index c9699bfb81..0cbab5e17c 100644
--- a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
+++ b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
@@ -83,6 +83,7 @@ void tst_QCheckBox::initTestCase()
testWidget->setObjectName("testObject");
testWidget->resize( 200, 200 );
testWidget->show();
+ QVERIFY(QTest::qWaitForWindowActive(testWidget));
}
void tst_QCheckBox::cleanupTestCase()
@@ -240,13 +241,11 @@ void tst_QCheckBox::pressed()
QVERIFY( !testWidget->isChecked() );
QTest::keyPress( testWidget, Qt::Key_Space );
- QTest::qWait(100);
QVERIFY( press_count == 1 );
QVERIFY( release_count == 0 );
QVERIFY( !testWidget->isChecked() );
QTest::keyRelease( testWidget, Qt::Key_Space );
- QTest::qWait(100);
QVERIFY( press_count == 1 );
QVERIFY( release_count == 1 );
QVERIFY( testWidget->isChecked() );
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 0c229c9194..7c1deb8fff 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -1995,19 +1995,16 @@ void tst_QComboBox::flaggedItems()
QApplication::setActiveWindow(&comboBox);
comboBox.activateWindow();
comboBox.setFocus();
+ QVERIFY(QTest::qWaitForWindowActive(&comboBox));
QTRY_VERIFY(comboBox.isVisible());
QTRY_VERIFY(comboBox.hasFocus());
if (editable)
comboBox.lineEdit()->selectAll();
- QSignalSpy indexChangedInt(&comboBox, SIGNAL(currentIndexChanged(int)));
for (int i = 0; i < keyMovementList.count(); ++i) {
Qt::Key key = keyMovementList[i];
QTest::keyClick(&comboBox, key);
- if (indexChangedInt.count() != i + 1) {
- QTest::qWait(400);
- }
}
QCOMPARE(comboBox.currentIndex() , expectedIndex);
@@ -2447,7 +2444,7 @@ void tst_QComboBox::task220195_keyBoardSelection2()
combo.addItem( QLatin1String("foo3"));
combo.show();
QApplication::setActiveWindow(&combo);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo));
+ QVERIFY(QTest::qWaitForWindowActive(&combo));
combo.setCurrentIndex(-1);
QVERIFY(combo.currentText().isNull());
diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
index 667e348945..2e5d24cd26 100644
--- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
@@ -110,6 +110,7 @@ void tst_QCommandLinkButton::initTestCase()
testWidget->setObjectName("testWidget");
testWidget->resize( 200, 200 );
testWidget->show();
+ QVERIFY(QTest::qWaitForWindowActive(testWidget));
connect( testWidget, SIGNAL(clicked()), this, SLOT(onClicked()) );
connect( testWidget, SIGNAL(pressed()), this, SLOT(onPressed()) );
@@ -166,11 +167,11 @@ void tst_QCommandLinkButton::onReleased()
void tst_QCommandLinkButton::setAutoRepeat()
{
- // Give the last tests time to finish - i.e., wait for the window close
- // and deactivate to avoid a race condition here. We can't add this to the
- // end of the defaultAndAutoDefault test, since any failure in that test
- // will return out of that function.
- QTest::qWait( 1000 );
+ // Give the last tests time to finish - i.e., wait for the window close and
+ // deactivate to avoid a race condition here. We can't add this to the end
+ // of the defaultAndAutoDefault test, since any failure in that test will
+ // return out of that function.
+ QTest::qWait(1000);
// If this changes, this test must be completely revised.
QVERIFY( !testWidget->isCheckable() );
@@ -194,8 +195,6 @@ void tst_QCommandLinkButton::setAutoRepeat()
testWidget->setAutoRepeat( false );
QTest::keyPress( testWidget, Qt::Key_Space );
- QTest::qWait( 300 );
-
QVERIFY( testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QVERIFY( press_count == 1 );
@@ -206,18 +205,16 @@ void tst_QCommandLinkButton::setAutoRepeat()
resetCounters();
// check that the button is down if we press space while in autorepeat
- // we can't actually confirm how many times it is fired, more than 1 is enough.
testWidget->setDown( false );
testWidget->setAutoRepeat( true );
QTest::keyPress( testWidget, Qt::Key_Space );
- QTest::qWait(900);
+ QTRY_VERIFY(press_count > 10);
QVERIFY( testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QTest::keyRelease( testWidget, Qt::Key_Space );
QCOMPARE(press_count, release_count);
QCOMPARE(release_count, click_count);
- QVERIFY(press_count > 1);
// #### shouldn't I check here to see if multiple signals have been fired???
@@ -227,8 +224,6 @@ void tst_QCommandLinkButton::setAutoRepeat()
testWidget->setAutoRepeat( false );
QTest::keyPress( testWidget, Qt::Key_Enter );
- QTest::qWait( 300 );
-
QVERIFY( !testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QVERIFY( press_count == 0 );
@@ -241,7 +236,6 @@ void tst_QCommandLinkButton::setAutoRepeat()
testWidget->setDown( false );
testWidget->setAutoRepeat( true );
QTest::keyClick( testWidget, Qt::Key_Enter );
- QTest::qWait( 300 );
QVERIFY( !testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QVERIFY( press_count == 0 );
@@ -252,23 +246,19 @@ void tst_QCommandLinkButton::setAutoRepeat()
void tst_QCommandLinkButton::pressed()
{
QTest::keyPress( testWidget, ' ' );
-// QTest::qWait( 300 );
QCOMPARE( press_count, (uint)1 );
QCOMPARE( release_count, (uint)0 );
QTest::keyRelease( testWidget, ' ' );
-// QTest::qWait( 300 );
QCOMPARE( press_count, (uint)1 );
QCOMPARE( release_count, (uint)1 );
QTest::keyPress( testWidget,Qt::Key_Enter );
-// QTest::qWait( 300 );
QCOMPARE( press_count, (uint)1 );
QCOMPARE( release_count, (uint)1 );
testWidget->setAutoDefault(true);
QTest::keyPress( testWidget,Qt::Key_Enter );
-// QTest::qWait( 300 );
QCOMPARE( press_count, (uint)2 );
QCOMPARE( release_count, (uint)2 );
testWidget->setAutoDefault(false);
@@ -349,19 +339,7 @@ void tst_QCommandLinkButton::setAccel()
// The shortcut will not be activated unless the button is in a active
// window and has focus
testWidget->setFocus();
-
- // QWidget::isActiveWindow() can report window active before application
- // has handled the asynchronous activation event on platforms that have
- // implemented QPlatformWindow::isActive(), so process events to sync up.
- QApplication::instance()->processEvents();
-
- for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) {
- testWidget->activateWindow();
- QApplication::instance()->processEvents();
- QTest::qWait(100);
- }
-
- QVERIFY(testWidget->isActiveWindow());
+ QVERIFY(QTest::qWaitForWindowActive(testWidget));
QTest::keyClick( testWidget, 'A', Qt::AltModifier );
QTest::qWait( 500 );
@@ -449,8 +427,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
QVERIFY(dialog.isVisible());
QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
- QApplication::sendEvent(&dialog, &event);
+ QTest::keyClick(&dialog, Qt::Key_Return);
QVERIFY(!dialog.isVisible());
}
@@ -490,8 +467,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
QVERIFY(dialog.isVisible());
QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
- QApplication::sendEvent(&dialog, &event);
+ QTest::keyClick(&dialog, Qt::Key_Return);
QVERIFY(!dialog.isVisible());
}
@@ -506,8 +482,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
// No default button is set, and button2 is the first autoDefault button
// that is next in the tab order
QObject::connect(&button2, SIGNAL(clicked()), &dialog, SLOT(hide()));
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
- QApplication::sendEvent(&dialog, &event);
+ QTest::keyClick(&dialog, Qt::Key_Return);
QVERIFY(!dialog.isVisible());
// Reparenting
diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
index f127fd98f7..17b0e9ce5f 100644
--- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
+++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
@@ -838,10 +838,9 @@ void tst_QDialogButtonBox::task191642_default()
bb->addButton(QDialogButtonBox::Help);
dlg.show();
- QTest::qWait(10);
+ QVERIFY(QTest::qWaitForWindowActive(&dlg));
QVERIFY(def->isDefault());
QTest::keyPress( &dlg, Qt::Key_Enter );
- QTest::qWait(100);
QCOMPARE(clicked.count(), 1);
}
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index 1a1023208a..7d1e736f42 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -579,8 +579,7 @@ void tst_QDockWidget::visibilityChanged()
QCOMPARE(spy.count(), 0);
mw.addDockWidget(Qt::RightDockWidgetArea, &dw2);
- QTest::qWait(200);
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QCOMPARE(spy.at(0).at(0).toBool(), true);
}
@@ -672,8 +671,7 @@ void tst_QDockWidget::dockLocationChanged()
dw.setFloating(true);
QTest::qWait(100);
dw.setFloating(false);
- QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.count(), 1);
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
Qt::TopDockWidgetArea);
spy.clear();
@@ -936,8 +934,7 @@ void tst_QDockWidget::task248604_infiniteResize()
d.setContentsMargins(2, 2, 2, 2);
d.setMinimumSize(320, 240);
d.showNormal();
- QTest::qWait(400);
- QCOMPARE(d.size(), QSize(320, 240));
+ QTRY_COMPARE(d.size(), QSize(320, 240));
}
@@ -950,7 +947,7 @@ void tst_QDockWidget::task258459_visibilityChanged()
QSignalSpy spy1(&dock1, SIGNAL(visibilityChanged(bool)));
QSignalSpy spy2(&dock2, SIGNAL(visibilityChanged(bool)));
win.show();
- QTest::qWait(200);
+ QVERIFY(QTest::qWaitForWindowActive(&win));
QCOMPARE(spy1.count(), 1);
QCOMPARE(spy1.first().first().toBool(), false); //dock1 is invisible
QCOMPARE(spy2.count(), 1);
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
index 59ddd54194..d44cc40527 100644
--- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
+++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -164,6 +164,7 @@ void tst_QDoubleSpinBox::initTestCase()
testFocusWidget = new QWidget(0);
testFocusWidget->resize(200, 100);
testFocusWidget->show();
+ QVERIFY(QTest::qWaitForWindowActive(testFocusWidget));
}
void tst_QDoubleSpinBox::cleanupTestCase()
@@ -747,6 +748,7 @@ void tst_QDoubleSpinBox::setReadOnly()
QDoubleSpinBox spin(0);
spin.setValue(0.2);
spin.show();
+ QVERIFY(QTest::qWaitForWindowActive(&spin));
QCOMPARE(spin.value(), 0.2);
QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 1.2);
@@ -769,16 +771,14 @@ void tst_QDoubleSpinBox::editingFinished()
layout->addWidget(box2);
testFocusWidget->show();
- QApplication::setActiveWindow(testFocusWidget);
- QTest::qWait(10);
- QTRY_VERIFY(testFocusWidget->isActiveWindow());
+ testFocusWidget->activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(testFocusWidget));
box->setFocus();
QTRY_VERIFY(box->hasFocus());
QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished()));
- box->setFocus();
QTest::keyClick(box, Qt::Key_Up);
QTest::keyClick(box, Qt::Key_Up);
@@ -997,7 +997,7 @@ void tst_QDoubleSpinBox::task224497_fltMax()
dspin->setMinimum(3);
dspin->setMaximum(FLT_MAX);
dspin->show();
- QTest::qWait(1000);
+ QVERIFY(QTest::qWaitForWindowActive(dspin));
dspin->lineEdit()->selectAll();
QTest::keyClick(dspin->lineEdit(), Qt::Key_Delete);
QTest::keyClick(dspin->lineEdit(), Qt::Key_1);
diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
index 84071962bc..34862f6810 100644
--- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -398,7 +398,6 @@ void tst_QLabel::task226479_movieResize()
label.paintedRegion = QRegion();
movie->setFileName(QFINDTESTDATA("green.png"));
movie->start();
- QTest::qWait(50);
QTRY_COMPARE(label.paintedRegion , QRegion(label.rect()) );
}
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 0be8d319c2..17462a5f86 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -319,6 +319,7 @@ private:
void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = 0);
void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = 0);
bool unselectingWithLeftOrRightChangesCursorPosition();
+ void addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey);
QLineEdit *ensureTestWidget();
bool validInput;
@@ -724,7 +725,7 @@ void tst_QLineEdit::keypress_inputMask_data()
{
QTestEventList keys;
// inserting 'A1.2B'
- keys.addKeyClick(Qt::Key_Home);
+ addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_A);
keys.addKeyClick(Qt::Key_1);
keys.addKeyClick(Qt::Key_Period);
@@ -735,7 +736,7 @@ void tst_QLineEdit::keypress_inputMask_data()
{
QTestEventList keys;
// inserting 'A1.2B'
- keys.addKeyClick(Qt::Key_Home);
+ addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_0);
keys.addKeyClick(Qt::Key_Exclam);
keys.addKeyClick('P');
@@ -745,22 +746,24 @@ void tst_QLineEdit::keypress_inputMask_data()
{
QTestEventList keys;
// pressing delete
- keys.addKeyClick(Qt::Key_Home);
+ addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_Delete);
QTest::newRow("delete") << QString("000.000;_") << keys << QString(".") << QString("___.___");
}
{
QTestEventList keys;
// selecting all and delete
- keys.addKeyClick(Qt::Key_Home);
- keys.addKeyClick(Qt::Key_End, Qt::ShiftModifier);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
+ addKeySequenceStandardKey(keys, QKeySequence::SelectEndOfLine);
keys.addKeyClick(Qt::Key_Delete);
QTest::newRow("deleting all") << QString("000.000;_") << keys << QString(".") << QString("___.___");
}
{
QTestEventList keys;
// inserting '12.12' then two backspaces
- keys.addKeyClick(Qt::Key_Home);
+ addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_1);
keys.addKeyClick(Qt::Key_2);
keys.addKeyClick(Qt::Key_Period);
@@ -773,7 +776,7 @@ void tst_QLineEdit::keypress_inputMask_data()
{
QTestEventList keys;
// inserting '12ab'
- keys.addKeyClick(Qt::Key_Home);
+ addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine);
keys.addKeyClick(Qt::Key_1);
keys.addKeyClick(Qt::Key_2);
keys.addKeyClick(Qt::Key_A);
@@ -1971,6 +1974,13 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo
keys.addKeyClick(key, pressState);
}
+void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey key)
+{
+ QKeySequence keyseq = QKeySequence(key);
+ for (int i = 0; i < keyseq.count(); ++i)
+ keys.addKeyClick( Qt::Key( keyseq[i] & ~Qt::KeyboardModifierMask), Qt::KeyboardModifier(keyseq[i] & Qt::KeyboardModifierMask) );
+}
+
void tst_QLineEdit::cursorPosition()
{
QLineEdit *testWidget = ensureTestWidget();
@@ -3573,18 +3583,15 @@ void tst_QLineEdit::task174640_editingFinished()
QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished()));
le1->setFocus();
- QTest::qWait(20);
QTRY_VERIFY(le1->hasFocus());
QCOMPARE(editingFinishedSpy.count(), 0);
le2->setFocus();
- QTest::qWait(20);
QTRY_VERIFY(le2->hasFocus());
QCOMPARE(editingFinishedSpy.count(), 1);
editingFinishedSpy.clear();
le1->setFocus();
- QTest::qWait(20);
QTRY_VERIFY(le1->hasFocus());
QMenu *testMenu1 = new QMenu(le1);
@@ -3680,7 +3687,6 @@ void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged()
QVERIFY(QTest::qWaitForWindowExposed(&lineEdit)); // to be safe and avoid failing setFocus with window managers
lineEdit.setFocus();
QSignalSpy changedSpy(&lineEdit, SIGNAL(textChanged(QString)));
- QTest::qWait(200);
QTest::keyPress(&lineEdit, 'a');
QTest::keyPress(&lineEdit, 'b');
QTest::keyPress(&lineEdit, 'c');
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index 30dc1e6043..ae71663036 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -1745,17 +1745,15 @@ void tst_QMainWindow::setCursor()
QCOMPARE(cur.shape(), mw.cursor().shape());
mw.resize(200,200);
mw.show();
- QTest::qWait(50);
+ QVERIFY(QTest::qWaitForWindowActive(&mw));
QCOMPARE(cur.shape(), mw.cursor().shape());
QHoverEvent enterE(QEvent::HoverEnter, QPoint(10,10), QPoint());
mw.event(&enterE);
- QTest::qWait(50);
QCOMPARE(cur.shape(), mw.cursor().shape());
QHoverEvent leaveE(QEvent::HoverLeave, QPoint(), QPoint());
mw.event(&leaveE);
- QTest::qWait(50);
QCOMPARE(cur.shape(), mw.cursor().shape());
}
#endif
@@ -1844,7 +1842,7 @@ void tst_QMainWindow::dockWidgetSize()
mainWindow.addDockWidget(Qt::TopDockWidgetArea, &dock);
mainWindow.show();
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(&mainWindow));
if (mainWindow.size() == mainWindow.sizeHint()) {
QCOMPARE(widget.size(), widget.sizeHint());
QCOMPARE(dock.widget()->size(), dock.widget()->sizeHint());
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index c8a92f3751..ecad7267dd 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -1400,6 +1400,7 @@ void tst_QMdiArea::subWindowList()
QMdiArea workspace;
workspace.show();
qApp->setActiveWindow(&workspace);
+ QVERIFY(QTest::qWaitForWindowActive(&workspace));
QList<QMdiSubWindow *> activationOrder;
QVector<QMdiSubWindow *> windows;
@@ -1418,8 +1419,7 @@ void tst_QMdiArea::subWindowList()
windows[staysOnTop1]->setWindowFlags(windows[staysOnTop1]->windowFlags() | Qt::WindowStaysOnTopHint);
workspace.setActiveSubWindow(windows[activeSubWindow]);
- qApp->processEvents();
- QCOMPARE(workspace.activeSubWindow(), windows[activeSubWindow]);
+ QTRY_COMPARE(workspace.activeSubWindow(), windows[activeSubWindow]);
activationOrder.move(activationOrder.indexOf(windows[activeSubWindow]), windowCount - 1);
QList<QMdiSubWindow *> subWindows = workspace.subWindowList(windowOrder);
@@ -1441,13 +1441,11 @@ void tst_QMdiArea::subWindowList()
windows[staysOnTop2]->setWindowFlags(windows[staysOnTop2]->windowFlags() | Qt::WindowStaysOnTopHint);
workspace.setActiveSubWindow(windows[staysOnTop2]);
- qApp->processEvents();
- QCOMPARE(workspace.activeSubWindow(), windows[staysOnTop2]);
+ QTRY_COMPARE(workspace.activeSubWindow(), windows[staysOnTop2]);
activationOrder.move(activationOrder.indexOf(windows[staysOnTop2]), windowCount - 1);
workspace.setActiveSubWindow(windows[activeSubWindow]);
- qApp->processEvents();
- QCOMPARE(workspace.activeSubWindow(), windows[activeSubWindow]);
+ QTRY_COMPARE(workspace.activeSubWindow(), windows[activeSubWindow]);
activationOrder.move(activationOrder.indexOf(windows[activeSubWindow]), windowCount - 1);
QList<QMdiSubWindow *> widgets = workspace.subWindowList(windowOrder);
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index a9d8c48d63..360e0c93c4 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -963,8 +963,6 @@ void tst_QMdiSubWindow::setSystemMenu()
mainWindow.menuBar()->setNativeMenuBar(false);
mainWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
- QTest::qWait(60);
-
QTRY_VERIFY(subWindow->isVisible());
QPoint globalPopupPos;
@@ -972,7 +970,6 @@ void tst_QMdiSubWindow::setSystemMenu()
// Show system menu
QVERIFY(!qApp->activePopupWidget());
subWindow->showSystemMenu();
- QTest::qWait(25);
QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)),
(globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft())) );
@@ -997,7 +994,6 @@ void tst_QMdiSubWindow::setSystemMenu()
// Show the new system menu
QVERIFY(!qApp->activePopupWidget());
subWindow->showSystemMenu();
- QTest::qWait(25);
QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
@@ -1011,7 +1007,6 @@ void tst_QMdiSubWindow::setSystemMenu()
QWidget *menuLabel = subWindow->maximizedSystemMenuIconWidget();
QVERIFY(menuLabel);
subWindow->showSystemMenu();
- QTest::qWait(25);
QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)),
(globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height()))));
@@ -1027,7 +1022,6 @@ void tst_QMdiSubWindow::setSystemMenu()
QTest::qWait(150);
subWindow->showSystemMenu();
- QTest::qWait(250);
QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
// + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top())
globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topRight()) + QPoint(1, 0);
@@ -1044,7 +1038,6 @@ void tst_QMdiSubWindow::setSystemMenu()
menuLabel = subWindow->maximizedSystemMenuIconWidget();
QVERIFY(menuLabel);
subWindow->showSystemMenu();
- QTest::qWait(250);
QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
globalPopupPos = menuLabel->mapToGlobal(QPoint(menuLabel->width(), menuLabel->y() + menuLabel->height()));
globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0);
@@ -1648,8 +1641,6 @@ void tst_QMdiSubWindow::resizeTimer()
QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget);
mdiArea.show();
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
- QTest::qWait(300);
-
EventSpy timerEventSpy(subWindow, QEvent::Timer);
QCOMPARE(timerEventSpy.count(), 0);
@@ -1809,10 +1800,9 @@ void tst_QMdiSubWindow::closeOnDoubleClick()
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
subWindow->showSystemMenu();
- QTest::qWait(200);
- QPointer<QMenu> systemMenu = subWindow->systemMenu();
- QVERIFY(systemMenu);
+ QPointer<QMenu> systemMenu;
+ QTRY_VERIFY( (systemMenu = subWindow->systemMenu()) );
QVERIFY(systemMenu->isVisible());
const QRect actionGeometry = systemMenu->actionGeometry(systemMenu->actions().at(actionIndex));
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 28e8ba81d6..0dde385bdb 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -991,18 +991,14 @@ void tst_QMenu::task258920_mouseBorder()
#endif
menu.popup(center);
QVERIFY(QTest::qWaitForWindowExposed(&menu));
- QTest::qWait(100);
QRect actionRect = menu.actionGeometry(action);
const QPoint actionCenter = actionRect.center();
QTest::mouseMove(&menu, actionCenter - QPoint(-10, 0));
- QTest::qWait(30);
QTest::mouseMove(&menu, actionCenter);
- QTest::qWait(30);
QTest::mouseMove(&menu, actionCenter + QPoint(10, 0));
QTRY_COMPARE(action, menu.activeAction());
menu.painted = false;
QTest::mouseMove(&menu, QPoint(actionRect.center().x(), actionRect.bottom() + 1));
- QTest::qWait(30);
QTRY_COMPARE(static_cast<QAction*>(0), menu.activeAction());
QTRY_VERIFY(menu.painted);
}
@@ -1109,7 +1105,6 @@ void tst_QMenu::QTBUG7907_submenus_autoselect()
menu.show();
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) );
- QTest::qWait(500);
QVERIFY(!subset.isVisible());
}
@@ -1410,7 +1405,6 @@ void tst_QMenu::QTBUG_56917_wideMenuSize()
menu.addAction(longString);
QSize menuSizeHint = menu.sizeHint();
menu.popup(QPoint());
- QTest::qWait(100);
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QVERIFY(menu.isVisible());
QVERIFY(menu.height() <= menuSizeHint.height());
@@ -1428,7 +1422,6 @@ void tst_QMenu::QTBUG_56917_wideMenuScreenNumber()
QMenu menu;
menu.addAction(longString);
menu.popup(QApplication::desktop()->screen(i)->geometry().center());
- QTest::qWait(100);
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QVERIFY(menu.isVisible());
QCOMPARE(QApplication::desktop()->screenNumber(&menu), i);
diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
index 35209c2501..39989c6dbb 100644
--- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
+++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
@@ -163,12 +163,9 @@ void tst_QProgressBar::format()
bar.move(300, 300);
bar.show();
QVERIFY(QTest::qWaitForWindowExposed(&bar));
- QVERIFY(QTest::qWaitForWindowExposed(&bar));
- QTest::qWait(20);
bar.repainted = false;
bar.setFormat("%v of %m (%p%)");
- QTest::qWait(20);
QTRY_VERIFY(bar.repainted);
bar.repainted = false;
bar.setFormat("%v of %m (%p%)");
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index 2b54008de7..625f38d8ae 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -183,9 +183,7 @@ void tst_QPushButton::autoRepeat()
testWidget->setAutoRepeat( false );
QTest::keyPress( testWidget, Qt::Key_Space );
- QTest::qWait( 300 );
-
- QVERIFY( testWidget->isDown() );
+ QTRY_VERIFY( testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QVERIFY( press_count == 1 );
QVERIFY( release_count == 0 );
@@ -200,13 +198,12 @@ void tst_QPushButton::autoRepeat()
testWidget->setDown( false );
testWidget->setAutoRepeat( true );
QTest::keyPress( testWidget, Qt::Key_Space );
- QTest::qWait(900);
+ QTRY_VERIFY(press_count > 3);
QVERIFY( testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QTest::keyRelease( testWidget, Qt::Key_Space );
QCOMPARE(press_count, release_count);
QCOMPARE(release_count, click_count);
- QVERIFY(press_count > 1);
// #### shouldn't I check here to see if multiple signals have been fired???
@@ -241,23 +238,19 @@ void tst_QPushButton::autoRepeat()
void tst_QPushButton::pressed()
{
QTest::keyPress( testWidget, ' ' );
-// QTest::qWait( 300 );
QCOMPARE( press_count, (uint)1 );
QCOMPARE( release_count, (uint)0 );
QTest::keyRelease( testWidget, ' ' );
-// QTest::qWait( 300 );
QCOMPARE( press_count, (uint)1 );
QCOMPARE( release_count, (uint)1 );
QTest::keyPress( testWidget,Qt::Key_Enter );
-// QTest::qWait( 300 );
QCOMPARE( press_count, (uint)1 );
QCOMPARE( release_count, (uint)1 );
testWidget->setAutoDefault(true);
QTest::keyPress( testWidget,Qt::Key_Enter );
-// QTest::qWait( 300 );
QCOMPARE( press_count, (uint)2 );
QCOMPARE( release_count, (uint)2 );
testWidget->setAutoDefault(false);
@@ -340,14 +333,8 @@ void tst_QPushButton::setAccel()
// window and has focus
QApplication::setActiveWindow(testWidget);
testWidget->setFocus();
- for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) {
- testWidget->activateWindow();
- QApplication::instance()->processEvents();
- QTest::qWait(100);
- }
- QVERIFY(testWidget->isActiveWindow());
+ QVERIFY(QTest::qWaitForWindowActive(testWidget));
QTest::keyClick( testWidget, 'A', Qt::AltModifier );
- QTest::qWait( 50 );
QTRY_VERIFY( click_count == 1 );
QVERIFY( press_count == 1 );
QVERIFY( release_count == 1 );
@@ -576,10 +563,8 @@ void tst_QPushButton::sizeHint()
dialog->showNormal();
tabWidget->setCurrentWidget(tab2);
tabWidget->setCurrentWidget(tab1);
- QTest::qWait(100);
- QApplication::processEvents();
- QCOMPARE(button1_2->size(), button2_2->size());
+ QTRY_COMPARE(button1_2->size(), button2_2->size());
}
}
diff --git a/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp
index e3752df09e..a4edea23bc 100644
--- a/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp
+++ b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp
@@ -70,15 +70,13 @@ void tst_QRadioButton::task190739_focus()
widget.show();
widget.activateWindow();
- QApplication::setActiveWindow(&widget);
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(&widget));
QVERIFY(edit.hasFocus());
QVERIFY(!radio1.isChecked());
QTest::keyClick(&edit, Qt::Key_O, Qt::ControlModifier, 20);
- QTest::qWait(200);
- QVERIFY(radio1.isChecked());
+ QTRY_VERIFY(radio1.isChecked());
QVERIFY(edit.hasFocus());
QVERIFY(!radio1.hasFocus());
}
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 07a2fd859d..57816f9f70 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -852,12 +852,11 @@ void tst_QSpinBox::editingFinished()
testFocusWidget.hide();
QCOMPARE(editingFinishedSpy1.count(), 4);
QCOMPARE(editingFinishedSpy2.count(), 4);
- QTest::qWait(100);
//task203285
editingFinishedSpy1.clear();
testFocusWidget.show();
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(&testFocusWidget));
box->setKeyboardTracking(false);
qApp->setActiveWindow(&testFocusWidget);
testFocusWidget.activateWindow();
diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
index cad7bd69d7..77abf5e5a7 100644
--- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
@@ -287,7 +287,7 @@ void tst_QSplitter::saveAndRestoreStateOfNotYetShownSplitter()
QByteArray ba = spl->saveState();
spl->restoreState(ba);
spl->show();
- QTest::qWait(500);
+ QVERIFY(QTest::qWaitForWindowActive(spl));
QCOMPARE(l1->geometry().isValid(), true);
QCOMPARE(l2->geometry().isValid(), true);
@@ -607,8 +607,7 @@ void tst_QSplitter::testShowHide()
lay->addWidget(split);
widget.setLayout(lay);
topLevel.show();
-
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
widget.hide();
split->widget(0)->setHidden(hideWidget1);
@@ -976,14 +975,13 @@ void tst_QSplitter::task169702_sizes()
outerSplitter->setGeometry(100, 100, 500, 500);
topLevel.show();
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
- QTest::qWait(100);
testW->m_iFactor++;
testW->updateGeometry();
- QTest::qWait(500);
//Make sure the minimimSizeHint is respected
- QCOMPARE(testW->size().height(), testW->minimumSizeHint().height());
+ QTRY_COMPARE(testW->size().height(), testW->minimumSizeHint().height());
}
void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget_data()
@@ -1012,8 +1010,7 @@ void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget()
l->hide();
else
delete l;
- QTest::qWait(100);
- QVERIFY(s.sizes().at(0) > 0);
+ QTRY_VERIFY(s.sizes().at(0) > 0);
}
void tst_QSplitter::setLayout()
diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
index b5ffb90e42..cbf5196bb9 100644
--- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
@@ -549,7 +549,8 @@ void tst_QTabWidget::paintEventCount()
QCOMPARE(tw->currentIndex(), 0);
tw->show();
-
+ QVERIFY(QTest::qWaitForWindowExposed(tw));
+ // Wait for extra paint events that happen at least on macOS
QTest::qWait(1000);
// Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point.
diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
index 3525dcddd6..301801ed2e 100644
--- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
+++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
@@ -1038,11 +1038,9 @@ void tst_QToolBar::accel()
mw.show();
QApplication::setActiveWindow(&mw);
- QTest::qWait(100);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&mw));
+ QVERIFY(QTest::qWaitForWindowActive(&mw));
QTest::keyClick(&mw, Qt::Key_T, Qt::AltModifier);
- QTest::qWait(300);
QTRY_COMPARE(spy.count(), 1);
#ifdef Q_OS_MAC
@@ -1085,19 +1083,19 @@ void tst_QToolBar::task197996_visibility()
pAction->setVisible(true);
mw.show();
+ QVERIFY(QTest::qWaitForWindowActive(&mw));
QVERIFY(toolBar->widgetForAction(pAction)->isVisible());
toolBar->setVisible(false);
pAction->setVisible(false);
+ QVERIFY(!toolBar->widgetForAction(pAction)->isVisible());
+
toolBar->setVisible(true);
pAction->setVisible(true);
- QTest::qWait(100);
-
- QVERIFY(toolBar->widgetForAction(pAction)->isVisible());
-
+ QTRY_VERIFY(toolBar->widgetForAction(pAction)->isVisible());
}
QTEST_MAIN(tst_QToolBar)
diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
index 1775f03680..a7a62496e6 100644
--- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
+++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
@@ -141,8 +141,7 @@ void tst_QToolButton::triggered()
timer->start();
QTimer::singleShot(10000, &mainWidget, SLOT(close())); // Emergency bail-out
toolButton->showMenu();
- QTest::qWait(20);
- QCOMPARE(spy.count(),2);
+ QTRY_COMPARE(spy.count(),2);
QCOMPARE(qvariant_cast<QAction *>(spy.at(1).at(0)), one);
}
diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp
index 3f7b33ee7a..83089e684c 100644
--- a/tests/manual/dialogs/main.cpp
+++ b/tests/manual/dialogs/main.cpp
@@ -33,10 +33,13 @@
#include "wizardpanel.h"
#include "messageboxpanel.h"
+#include <QLibraryInfo>
+#include <QDialogButtonBox>
#include <QMainWindow>
#include <QApplication>
#include <QMenuBar>
#include <QTabWidget>
+#include <QFormLayout>
#include <QMenu>
#include <QAction>
#include <QKeySequence>
@@ -44,10 +47,40 @@
// Test for dialogs, allowing to play with all dialog options for implementing native dialogs.
// Compiles with Qt 4.8 and Qt 5.
+class AboutDialog : public QDialog
+{
+public:
+ explicit AboutDialog(QWidget *parent = 0);
+};
+
+AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
+{
+ setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
+ QFormLayout *mainLayout = new QFormLayout(this);
+#if QT_VERSION >= 0x050600
+ mainLayout->addRow(new QLabel(QLibraryInfo::build()));
+#else
+ mainLayout->addRow(new QLabel(QLatin1String("Qt ") + QLatin1String(QT_VERSION_STR )));
+#endif
+ mainLayout->addRow("Style:", new QLabel(qApp->style()->objectName()));
+#if QT_VERSION >= 0x050600
+ mainLayout->addRow("DPR:", new QLabel(QString::number(qApp->devicePixelRatio())));
+#endif
+ const QString resolution = QString::number(logicalDpiX()) + QLatin1Char(',')
+ + QString::number(logicalDpiY()) + QLatin1String("dpi");
+ mainLayout->addRow("Resolution:", new QLabel(resolution));
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal);
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ mainLayout->addRow(buttonBox);
+}
+
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
+
+public slots:
+ void aboutDialog();
};
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
@@ -66,6 +99,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
action->setShortcut(QKeySequence(QKeySequence::Paste));
action = editMenu->addAction(tr("Select All"));
action->setShortcut(QKeySequence(QKeySequence::SelectAll));
+ QMenu *aboutMenu = menuBar()->addMenu(tr("&About"));
+ QAction *aboutAction = aboutMenu->addAction(tr("About..."), this, SLOT(aboutDialog()));
+ aboutAction->setShortcut(Qt::Key_F1);
QTabWidget *tabWidget = new QTabWidget;
tabWidget->addTab(new FileDialogPanel, tr("QFileDialog"));
tabWidget->addTab(new ColorDialogPanel, tr("QColorDialog"));
@@ -78,6 +114,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
setCentralWidget(tabWidget);
}
+void MainWindow::aboutDialog()
+{
+ AboutDialog dialog(this);
+ dialog.setWindowTitle(tr("About Dialogs"));
+ dialog.exec();
+}
+
int main(int argc, char *argv[])
{
#if QT_VERSION >= 0x050700
diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp
index d3c6079c7d..a244230a22 100644
--- a/tests/manual/touch/main.cpp
+++ b/tests/manual/touch/main.cpp
@@ -34,6 +34,7 @@
#include <QAction>
#include <QMainWindow>
#include <QSplitter>
+#include <QStatusBar>
#include <QToolBar>
#include <QVector>
#include <QCommandLineOption>
@@ -43,12 +44,15 @@
#include <QPainterPath>
#include <QPaintEvent>
#include <QScreen>
+#include <QWindow>
#include <QSharedPointer>
#include <QDebug>
#include <QTextStream>
-bool optIgnoreTouch = false;
-QVector<Qt::GestureType> optGestures;
+static bool optIgnoreTouch = false;
+static QVector<Qt::GestureType> optGestures;
+
+static QWidgetList mainWindows;
static inline void drawEllipse(const QPointF &center, qreal hDiameter, qreal vDiameter, const QColor &color, QPainter &painter)
{
@@ -191,6 +195,7 @@ typedef QSharedPointer<Gesture> GesturePtr;
typedef QVector<GesturePtr> GesturePtrs;
typedef QVector<QEvent::Type> EventTypeVector;
+static EventTypeVector eventTypes;
class EventFilter : public QObject {
Q_OBJECT
@@ -206,6 +211,8 @@ private:
const EventTypeVector m_types;
};
+static EventFilter *globalEventFilter = nullptr;
+
bool EventFilter::eventFilter(QObject *o, QEvent *e)
{
static int n = 0;
@@ -275,10 +282,10 @@ class TouchTestWidget : public QWidget {
Q_OBJECT
Q_PROPERTY(bool drawPoints READ drawPoints WRITE setDrawPoints)
public:
- explicit TouchTestWidget(QWidget *parent = 0) : QWidget(parent), m_drawPoints(true)
+ explicit TouchTestWidget(QWidget *parent = nullptr) : QWidget(parent), m_drawPoints(true)
{
setAttribute(Qt::WA_AcceptTouchEvents);
- foreach (Qt::GestureType t, optGestures)
+ for (Qt::GestureType t : optGestures)
grabGesture(t);
}
@@ -337,10 +344,11 @@ bool TouchTestWidget::event(QEvent *event)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
if (m_drawPoints) {
- foreach (const QTouchEvent::TouchPoint &p, static_cast<const QTouchEvent *>(event)->touchPoints())
+ for (const QTouchEvent::TouchPoint &p : static_cast<const QTouchEvent *>(event)->touchPoints())
m_points.append(Point(p.pos(), TouchPoint, Qt::MouseEventNotSynthesized, p.ellipseDiameters()));
update();
}
+ Q_FALLTHROUGH();
case QEvent::TouchEnd:
if (optIgnoreTouch)
event->ignore();
@@ -358,7 +366,8 @@ bool TouchTestWidget::event(QEvent *event)
void TouchTestWidget::handleGestureEvent(QGestureEvent *gestureEvent)
{
- foreach (QGesture *gesture, gestureEvent->gestures()) {
+ const auto gestures = gestureEvent->gestures();
+ for (QGesture *gesture : gestures) {
if (optGestures.contains(gesture->gestureType())) {
switch (gesture->state()) {
case Qt::NoGesture:
@@ -389,7 +398,7 @@ void TouchTestWidget::paintEvent(QPaintEvent *)
const QRectF geom = QRectF(QPointF(0, 0), QSizeF(size()));
painter.fillRect(geom, Qt::white);
painter.drawRect(QRectF(geom.topLeft(), geom.bottomRight() - QPointF(1, 1)));
- foreach (const Point &point, m_points) {
+ for (const Point &point : qAsConst(m_points)) {
if (geom.contains(point.pos)) {
if (point.type == MouseRelease)
drawEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter);
@@ -397,56 +406,94 @@ void TouchTestWidget::paintEvent(QPaintEvent *)
fillEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter);
}
}
- foreach (const GesturePtr &gp, m_gestures)
+ for (const GesturePtr &gp : qAsConst(m_gestures))
gp->draw(geom, painter);
}
class MainWindow : public QMainWindow
{
Q_OBJECT
-public:
MainWindow();
+public:
+ static MainWindow *createMainWindow();
+
QWidget *touchWidget() const { return m_touchWidget; }
+ void setVisible(bool visible) override;
+
public slots:
void appendToLog(const QString &text) { m_logTextEdit->appendPlainText(text); }
void dumpTouchDevices();
private:
+ void updateScreenLabel();
+ void newWindow() { MainWindow::createMainWindow(); }
+
TouchTestWidget *m_touchWidget;
QPlainTextEdit *m_logTextEdit;
+ QLabel *m_screenLabel;
};
+MainWindow *MainWindow::createMainWindow()
+{
+ MainWindow *result = new MainWindow;
+ const QSize screenSize = QGuiApplication::primaryScreen()->availableGeometry().size();
+ result->resize(screenSize / 2);
+ const QSize sizeDiff = screenSize - result->size();
+ const QPoint pos = QPoint(sizeDiff.width() / 2, sizeDiff.height() / 2)
+ + mainWindows.size() * QPoint(30, 10);
+ result->move(pos);
+ result->show();
+
+ EventFilter *eventFilter = globalEventFilter;
+ if (!eventFilter) {
+ eventFilter = new EventFilter(eventTypes, result->touchWidget());
+ result->touchWidget()->installEventFilter(eventFilter);
+ }
+ QObject::connect(eventFilter, &EventFilter::eventReceived, result, &MainWindow::appendToLog);
+
+ mainWindows.append(result);
+ return result;
+}
+
MainWindow::MainWindow()
: m_touchWidget(new TouchTestWidget)
, m_logTextEdit(new QPlainTextEdit)
+ , m_screenLabel(new QLabel)
{
- setWindowTitle(QStringLiteral("Touch Event Tester ") + QT_VERSION_STR);
+ QString title;
+ QTextStream(&title) << "Touch Event Tester " << QT_VERSION_STR << ' '
+ << qApp->platformName() << " #" << (mainWindows.size() + 1);
+ setWindowTitle(title);
setObjectName("MainWin");
QToolBar *toolBar = new QToolBar(this);
addToolBar(Qt::TopToolBarArea, toolBar);
QMenu *fileMenu = menuBar()->addMenu("File");
+ QAction *newWindowAction = fileMenu->addAction(QStringLiteral("New Window"), this, &MainWindow::newWindow);
+ newWindowAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
+ toolBar->addAction(newWindowAction);
+ fileMenu->addSeparator();
QAction *dumpDeviceAction = fileMenu->addAction(QStringLiteral("Dump devices"));
dumpDeviceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
- connect(dumpDeviceAction, SIGNAL(triggered()), this, SLOT(dumpTouchDevices()));
+ connect(dumpDeviceAction, &QAction::triggered, this, &MainWindow::dumpTouchDevices);
toolBar->addAction(dumpDeviceAction);
QAction *clearLogAction = fileMenu->addAction(QStringLiteral("Clear Log"));
clearLogAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
- connect(clearLogAction, SIGNAL(triggered()), m_logTextEdit, SLOT(clear()));
+ connect(clearLogAction, &QAction::triggered, m_logTextEdit, &QPlainTextEdit::clear);
toolBar->addAction(clearLogAction);
QAction *toggleDrawPointAction = fileMenu->addAction(QStringLiteral("Draw Points"));
toggleDrawPointAction->setCheckable(true);
toggleDrawPointAction->setChecked(m_touchWidget->drawPoints());
- connect(toggleDrawPointAction, SIGNAL(toggled(bool)), m_touchWidget, SLOT(setDrawPoints(bool)));
+ connect(toggleDrawPointAction, &QAction::toggled, m_touchWidget, &TouchTestWidget::setDrawPoints);
toolBar->addAction(toggleDrawPointAction);
QAction *clearPointAction = fileMenu->addAction(QStringLiteral("Clear Points"));
clearPointAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
- connect(clearPointAction, SIGNAL(triggered()), m_touchWidget, SLOT(clearPoints()));
+ connect(clearPointAction, &QAction::triggered, m_touchWidget, &TouchTestWidget::clearPoints);
toolBar->addAction(clearPointAction);
QAction *quitAction = fileMenu->addAction(QStringLiteral("Quit"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
- connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
toolBar->addAction(quitAction);
QSplitter *mainSplitter = new QSplitter(Qt::Vertical, this);
@@ -459,9 +506,32 @@ MainWindow::MainWindow()
mainSplitter->addWidget(m_logTextEdit);
setCentralWidget(mainSplitter);
+ statusBar()->addPermanentWidget(m_screenLabel);
+
dumpTouchDevices();
}
+void MainWindow::setVisible(bool visible)
+{
+ QMainWindow::setVisible(visible);
+ connect(windowHandle(), &QWindow::screenChanged, this, &MainWindow::updateScreenLabel);
+ updateScreenLabel();
+}
+
+void MainWindow::updateScreenLabel()
+{
+ QString text;
+ QTextStream str(&text);
+ const QScreen *screen = windowHandle()->screen();
+ const QRect geometry = screen->geometry();
+ const qreal dpr = screen->devicePixelRatio();
+ str << '"' << screen->name() << "\" " << geometry.width() << 'x' << geometry.height()
+ << forcesign << geometry.x() << geometry.y() << noforcesign;
+ if (!qFuzzyCompare(dpr, qreal(1)))
+ str << ", dpr=" << dpr;
+ m_screenLabel->setText(text);
+}
+
void MainWindow::dumpTouchDevices()
{
QString message;
@@ -520,14 +590,6 @@ int main(int argc, char *argv[])
if (parser.isSet(swipeGestureOption))
optGestures.append(Qt::SwipeGesture);
- MainWindow w;
- const QSize screenSize = QGuiApplication::primaryScreen()->availableGeometry().size();
- w.resize(screenSize / 2);
- const QSize sizeDiff = screenSize - w.size();
- w.move(sizeDiff.width() / 2, sizeDiff.height() / 2);
- w.show();
-
- EventTypeVector eventTypes;
if (!parser.isSet(noMouseLogOption))
eventTypes << QEvent::MouseButtonPress << QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick;
if (parser.isSet(mouseMoveOption))
@@ -536,14 +598,16 @@ int main(int argc, char *argv[])
eventTypes << QEvent::TouchBegin << QEvent::TouchUpdate << QEvent::TouchEnd;
if (!optGestures.isEmpty())
eventTypes << QEvent::Gesture << QEvent::GestureOverride;
- QObject *filterTarget = parser.isSet(globalFilterOption)
- ? static_cast<QObject *>(&a)
- : static_cast<QObject *>(w.touchWidget());
- EventFilter *filter = new EventFilter(eventTypes, filterTarget);
- filterTarget->installEventFilter(filter);
- QObject::connect(filter, SIGNAL(eventReceived(QString)), &w, SLOT(appendToLog(QString)));
-
- return a.exec();
+ if (parser.isSet(globalFilterOption)) {
+ globalEventFilter = new EventFilter(eventTypes, &a);
+ a.installEventFilter(globalEventFilter);
+ }
+
+ MainWindow::createMainWindow();
+
+ const int exitCode = a.exec();
+ qDeleteAll(mainWindows);
+ return exitCode;
}
#include "main.moc"
diff --git a/tests/shared/emulationdetector.h b/tests/shared/emulationdetector.h
index cca11be695..ac584f121b 100644
--- a/tests/shared/emulationdetector.h
+++ b/tests/shared/emulationdetector.h
@@ -29,9 +29,13 @@
#ifndef EMULATIONDETECTOR_H
#define EMULATIONDETECTOR_H
+#include <QtCore/qglobal.h>
+
#if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM)
#define SHOULD_CHECK_ARM_ON_X86
+#include <QFileInfo>
+
#if QT_CONFIG(process) && QT_CONFIG(regularexpression)
#include <QProcess>
#include <QRegularExpression>