summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/global/externalsites/external-resources.qdoc2
-rw-r--r--examples/network/torrent/connectionmanager.cpp2
-rw-r--r--examples/opengl/qopenglwindow/background_renderer.cpp2
-rw-r--r--examples/widgets/painting/pathstroke/pathstroke.cpp2
-rw-r--r--mkspecs/common/clang.conf2
-rw-r--r--mkspecs/common/mac.conf1
-rw-r--r--mkspecs/common/winrt_winphone/manifests/10.0/AppxManifest.xml.in2
-rw-r--r--mkspecs/features/file_copies.prf3
-rw-r--r--mkspecs/features/qt.prf2
-rw-r--r--mkspecs/features/qt_common.prf6
-rw-r--r--mkspecs/features/qt_docs_targets.prf2
-rw-r--r--mkspecs/features/qt_functions.prf5
-rw-r--r--mkspecs/features/resources.prf2
-rw-r--r--mkspecs/netbsd-g++/qmake.conf3
-rw-r--r--mkspecs/openbsd-g++/qmake.conf17
-rw-r--r--qmake/library/qmakebuiltins.cpp13
-rw-r--r--qmake/library/qmakeevaluator.cpp186
-rw-r--r--qmake/library/qmakeevaluator.h19
-rw-r--r--qmake/library/qmakeparser.cpp15
-rw-r--r--qmake/project.cpp9
-rw-r--r--qmake/project.h2
-rw-r--r--src/angle/README.qt2
-rw-r--r--src/angle/src/common/common.pri2
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in15
-rw-r--r--src/corelib/arch/qatomic_cxx11.h187
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp12
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp5
-rw-r--r--src/corelib/global/qlogging.cpp10
-rw-r--r--src/corelib/io/qdatastream.h75
-rw-r--r--src/corelib/io/qdir.cpp2
-rw-r--r--src/corelib/io/qfileselector.cpp2
-rw-r--r--src/corelib/io/qlockfile_unix.cpp6
-rw-r--r--src/corelib/io/qsettings.cpp109
-rw-r--r--src/corelib/io/qsettings_winrt.cpp2
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp44
-rw-r--r--src/corelib/io/qurl.cpp14
-rw-r--r--src/corelib/io/qurlidna.cpp2
-rw-r--r--src/corelib/json/qjsondocument.cpp12
-rw-r--r--src/corelib/kernel/qcore_unix_p.h4
-rw-r--r--src/corelib/kernel/qeventloop.cpp6
-rw-r--r--src/corelib/kernel/qmetaobject.cpp2
-rw-r--r--src/corelib/thread/qreadwritelock.cpp6
-rw-r--r--src/corelib/tools/qdatetime.cpp18
-rw-r--r--src/corelib/tools/qstring.cpp111
-rw-r--r--src/corelib/tools/qstring.h4
-rw-r--r--src/corelib/tools/qstringbuilder.h2
-rw-r--r--src/corelib/tools/qtimezoneprivate_icu.cpp2
-rw-r--r--src/corelib/tools/qtimezoneprivate_mac.mm3
-rw-r--r--src/gui/accessible/qaccessible.cpp4
-rw-r--r--src/gui/accessible/qaccessiblecache.cpp9
-rw-r--r--src/gui/accessible/qaccessiblecache_p.h2
-rw-r--r--src/gui/image/qicon.cpp4
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp13
-rw-r--r--src/gui/kernel/qguiapplication.cpp47
-rw-r--r--src/gui/kernel/qplatformintegrationfactory.cpp2
-rw-r--r--src/gui/kernel/qplatformthemefactory.cpp2
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp5
-rw-r--r--src/gui/text/qfontengine_ft.cpp36
-rw-r--r--src/gui/text/qfontengine_ft_p.h4
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp2
-rw-r--r--src/gui/text/qtexthtmlparser.cpp12
-rw-r--r--src/gui/text/qtextimagehandler.cpp2
-rw-r--r--src/network/access/qftp.cpp6
-rw-r--r--src/network/access/qnetworkaccessftpbackend.cpp9
-rw-r--r--src/network/kernel/qauthenticator.cpp2
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp5
-rw-r--r--src/network/ssl/qsslsocket.cpp10
-rw-r--r--src/network/ssl/qsslsocket_mac.cpp22
-rw-r--r--src/platformsupport/clipboard/qmacmime.mm4
-rw-r--r--src/platformsupport/dbustray/qdbustrayicon.cpp4
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm3
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm9
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h15
-rw-r--r--src/platformsupport/input/tslib/qtslib.cpp2
-rw-r--r--src/platformsupport/services/genericunix/qgenericunixservices.cpp4
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp14
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux_p.h1
-rw-r--r--src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.h6
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm17
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm8
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm24
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm3
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp2
-rw-r--r--src/plugins/platforms/minimal/minimal.pro2
-rw-r--r--src/plugins/platforms/qnx/qqnxrasterwindow.cpp9
-rw-r--r--src/plugins/platforms/qnx/qqnxwindow.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp31
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp9
-rw-r--r--src/plugins/platforms/windows/qwindowsservices.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp51
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.h5
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp7
-rw-r--r--src/plugins/platforms/winrt/qwinrtclipboard.cpp2
-rw-r--r--src/plugins/platforms/winrt/qwinrtdrag.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp15
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.cpp9
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp3
-rw-r--r--src/testlib/qtest.h34
-rw-r--r--src/testlib/qtest_gui.h34
-rw-r--r--src/testlib/qtestcase.cpp2
-rw-r--r--src/tools/moc/preprocessor.cpp8
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.cpp3
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp84
-rw-r--r--src/widgets/accessible/qaccessiblewidgets.cpp12
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp10
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp60
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp6
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp20
-rw-r--r--src/widgets/itemviews/qdirmodel.cpp4
-rw-r--r--src/widgets/itemviews/qlistview.cpp6
-rw-r--r--src/widgets/itemviews/qtreeview.cpp8
-rw-r--r--src/widgets/kernel/qformlayout.cpp21
-rw-r--r--src/widgets/kernel/qwidget.cpp2
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp4
-rw-r--r--src/widgets/styles/qcommonstyle.cpp11
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm2
-rw-r--r--src/widgets/styles/qstyle.cpp2
-rw-r--r--src/widgets/util/qcompleter.cpp4
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp3
-rw-r--r--src/widgets/widgets/qcombobox.cpp4
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp40
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp2
-rw-r--r--src/widgets/widgets/qdockwidget.cpp3
-rw-r--r--src/widgets/widgets/qfontcombobox.cpp2
-rw-r--r--src/widgets/widgets/qmainwindow.cpp16
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp7
-rw-r--r--src/widgets/widgets/qspinbox.cpp5
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp4
-rw-r--r--src/winmain/qtmain_winrt.cpp2
-rw-r--r--src/xml/sax/qxml.cpp2
-rw-r--r--tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp77
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp162
-rw-r--r--tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp16
-rw-r--r--tests/auto/corelib/tools/qpair/tst_qpair.cpp30
-rw-r--r--tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp8
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp69
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp6
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp6
-rw-r--r--tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp25
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.lightxml77
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.teamcity66
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.txt68
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xml77
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xunitxml10
-rwxr-xr-xtests/auto/testlib/selftests/generate_expected_output.py1
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp9
-rw-r--r--tests/auto/tools/qmakelib/evaltest.cpp111
-rw-r--r--tests/auto/tools/qmakelib/parsertest.cpp7
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp19
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp25
-rw-r--r--tests/manual/diaglib/diaglib.pri10
-rw-r--r--tools/configure/configureapp.cpp2
161 files changed, 1821 insertions, 946 deletions
diff --git a/doc/global/externalsites/external-resources.qdoc b/doc/global/externalsites/external-resources.qdoc
index 46ce8b6fd3..b231bb1f4a 100644
--- a/doc/global/externalsites/external-resources.qdoc
+++ b/doc/global/externalsites/external-resources.qdoc
@@ -174,7 +174,7 @@
*/
/*!
- \externalpage http://code.google.com/p/angleproject/
+ \externalpage https://chromium.googlesource.com/angle/angle/+/master/README.md
\title ANGLE
*/
diff --git a/examples/network/torrent/connectionmanager.cpp b/examples/network/torrent/connectionmanager.cpp
index acab59b0e3..87b7a16e28 100644
--- a/examples/network/torrent/connectionmanager.cpp
+++ b/examples/network/torrent/connectionmanager.cpp
@@ -88,7 +88,7 @@ QByteArray ConnectionManager::clientId() const
// Generate peer id
qint64 startupTime = QDateTime::currentSecsSinceEpoch();
- id += QString::asprintf("-QT%04x-", (QT_VERSION % 0xffff00) >> 8).toLatin1();
+ id += QString::asprintf("-QT%04x-", QT_VERSION >> 8).toLatin1();
id += QByteArray::number(startupTime, 10);
id += QByteArray(20 - id.size(), '-');
}
diff --git a/examples/opengl/qopenglwindow/background_renderer.cpp b/examples/opengl/qopenglwindow/background_renderer.cpp
index 296044a35a..d57198444e 100644
--- a/examples/opengl/qopenglwindow/background_renderer.cpp
+++ b/examples/opengl/qopenglwindow/background_renderer.cpp
@@ -180,7 +180,7 @@ void FragmentToy::draw(const QSize &windowSize)
m_program->enableAttributeArray("vertexCoord");
m_vertex_buffer.release();
- m_program->setUniformValue("currentTime", (uint) QDateTime::currentDateTime().toMSecsSinceEpoch());
+ m_program->setUniformValue("currentTime", (uint) QDateTime::currentMSecsSinceEpoch());
m_program->setUniformValue("windowSize", windowSize);
QOpenGLContext::currentContext()->functions()->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp
index 185238c351..dc10457d27 100644
--- a/examples/widgets/painting/pathstroke/pathstroke.cpp
+++ b/examples/widgets/painting/pathstroke/pathstroke.cpp
@@ -494,7 +494,7 @@ void PathStrokeRenderer::initializePoints()
m_vectors.clear();
QMatrix m;
- qreal rot = 360 / count;
+ qreal rot = 360.0 / count;
QPointF center(width() / 2, height() / 2);
QMatrix vm;
vm.shear(2, -1);
diff --git a/mkspecs/common/clang.conf b/mkspecs/common/clang.conf
index ee9c1b8371..e003b947aa 100644
--- a/mkspecs/common/clang.conf
+++ b/mkspecs/common/clang.conf
@@ -40,5 +40,5 @@ QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
# Wrapper tools that understand .o/.a files with LLVM bytecode instead of machine code
QMAKE_AR_LTCG = llvm-ar cqs
-QMAKE_NM_LTCG = gcc-nm -P
+QMAKE_NM_LTCG = llvm-nm -P
QMAKE_RANLIB_LTCG = true # No need to run, since llvm-ar has "s"
diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf
index d24a1d665c..56b9574e19 100644
--- a/mkspecs/common/mac.conf
+++ b/mkspecs/common/mac.conf
@@ -35,6 +35,7 @@ QMAKE_LIBS_THREAD =
QMAKE_DSYMUTIL = dsymutil
QMAKE_STRIP = strip
+QMAKE_STRIPFLAGS_LIB += -S -x
QMAKE_AR = ar cq
QMAKE_RANLIB = ranlib -s
diff --git a/mkspecs/common/winrt_winphone/manifests/10.0/AppxManifest.xml.in b/mkspecs/common/winrt_winphone/manifests/10.0/AppxManifest.xml.in
index c25d7b77af..fc6bfcebcf 100644
--- a/mkspecs/common/winrt_winphone/manifests/10.0/AppxManifest.xml.in
+++ b/mkspecs/common/winrt_winphone/manifests/10.0/AppxManifest.xml.in
@@ -22,7 +22,7 @@
</Properties>
<Dependencies>
- <TargetDeviceFamily Name=\"Windows.Universal\" MinVersion=\"10.0.10240.0\" MaxVersionTested=\"10.0.10586.0\" />$${WINRT_MANIFEST.dependencies}
+ <TargetDeviceFamily Name=\"Windows.Universal\" MinVersion=\"10.0.10586.0\" MaxVersionTested=\"10.0.10586.0\" />$${WINRT_MANIFEST.dependencies}
</Dependencies>
<Resources>
diff --git a/mkspecs/features/file_copies.prf b/mkspecs/features/file_copies.prf
index 6df294212c..4ebf41c78f 100644
--- a/mkspecs/features/file_copies.prf
+++ b/mkspecs/features/file_copies.prf
@@ -1,8 +1,7 @@
isEmpty(COPIES): return()
contains(TEMPLATE, .*subdirs): error("COPIES does not work with TEMPLATE=subdirs")
-build_pass:build_all: \
- debug_and_release:debug {
+build_pass:build_all:!isEqual(BUILD_PASS, $$first(BUILDS)) {
# Avoid that multiple build passes race with each other.
# This will fail to copy anything if the user explicitly invokes
# only the non-primary build. This is unfixable, as at qmake time
diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf
index 10b20be0b0..8d96d18d06 100644
--- a/mkspecs/features/qt.prf
+++ b/mkspecs/features/qt.prf
@@ -156,7 +156,7 @@ for(ever) {
!isEmpty(var_sfx): break()
var_sfx = _PRIVATE
}
-!isEmpty(using_privates):!no_private_qt_headers_warning:if(!debug_and_release|!build_pass) {
+!isEmpty(using_privates):!no_private_qt_headers_warning:!build_pass {
message("This project is using private headers and will therefore be tied to this specific Qt module build version.")
message("Running this project against other versions of the Qt modules may crash at any arbitrary point.")
message("This is not a bug, but a result of using Qt internals. You have been warned!")
diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf
index 00a6aef51f..e50fdb767b 100644
--- a/mkspecs/features/qt_common.prf
+++ b/mkspecs/features/qt_common.prf
@@ -102,9 +102,9 @@ warnings_are_errors:warning_clean {
# Work-around for bug https://code.google.com/p/android/issues/detail?id=58135
android: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=literal-suffix
}
- } else:msvc {
- # enable for MSVC 2012, MSVC 2013
- equals(MSVC_VER, "11.0")|equals(MSVC_VER, "12.0"): QMAKE_CXXFLAGS_WARN_ON += -WX
+ } else:msvc:!intel_icl {
+ # enable for MSVC 2012, MSVC 2013, MSVC 2015
+ contains(MSVC_VER, "1[124].0"): QMAKE_CXXFLAGS_WARN_ON += -WX
}
unset(ver)
}
diff --git a/mkspecs/features/qt_docs_targets.prf b/mkspecs/features/qt_docs_targets.prf
index 1f9e2b0b47..9e96432462 100644
--- a/mkspecs/features/qt_docs_targets.prf
+++ b/mkspecs/features/qt_docs_targets.prf
@@ -30,7 +30,7 @@ contains(TEMPLATE, subdirs) {
for(inst, DOC_TARGETS): \
prepareRecursiveTarget($$inst)
} else {
- debug_and_release:!build_pass {
+ !isEmpty(BUILDS):!build_pass {
sub = $$first(BUILDS)
for(inst, DOC_TARGETS) {
$${inst}.CONFIG = recursive
diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
index 2ed1cd51de..6dd4a36b5e 100644
--- a/mkspecs/features/qt_functions.prf
+++ b/mkspecs/features/qt_functions.prf
@@ -259,7 +259,10 @@ defineReplace(pkgConfigExecutable) {
}
defineTest(packagesExist) {
- contains(QT_CONFIG, no-pkg-config):return(false)
+ contains(QT_CONFIG, no-pkg-config) {
+ warning("pkg-config disabled, can't check package existence")
+ return(false)
+ }
# this can't be done in global scope here because qt_functions is loaded
# before the .pro is parsed, so if the .pro set PKG_CONFIG, we wouldn't know it
diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf
index ec70f49ce1..21147e4a42 100644
--- a/mkspecs/features/resources.prf
+++ b/mkspecs/features/resources.prf
@@ -35,7 +35,7 @@ for(resource, RESOURCES) {
resource_file = $$RCC_DIR/qmake_$${resource}.qrc
- !debug_and_release|build_pass {
+ isEmpty(BUILDS)|build_pass {
# Collection of files, generate qrc file
prefix = $$eval($${resource}.prefix)
isEmpty(prefix): \
diff --git a/mkspecs/netbsd-g++/qmake.conf b/mkspecs/netbsd-g++/qmake.conf
index 31005d9134..a4b26837ce 100644
--- a/mkspecs/netbsd-g++/qmake.conf
+++ b/mkspecs/netbsd-g++/qmake.conf
@@ -17,6 +17,9 @@ QMAKE_LIBDIR_X11 = /usr/X11R7/lib
QMAKE_INCDIR_OPENGL = /usr/X11R7/include
QMAKE_LIBDIR_OPENGL = /usr/X11R7/lib
+# NetBSD requires rpath to be used for all lib dirs, see http://www.netbsd.org/docs/elf.html
+QMAKE_RPATHDIR += $$QMAKE_LIBDIR $$QMAKE_LIBDIR_X11
+
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
load(qt_config)
diff --git a/mkspecs/openbsd-g++/qmake.conf b/mkspecs/openbsd-g++/qmake.conf
index e7ac523486..6124d31439 100644
--- a/mkspecs/openbsd-g++/qmake.conf
+++ b/mkspecs/openbsd-g++/qmake.conf
@@ -17,9 +17,26 @@ QMAKE_LIBDIR_X11 = /usr/X11R6/lib
QMAKE_INCDIR_OPENGL = /usr/X11R6/include
QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib
+QMAKE_RPATHDIR += $$QMAKE_LIBDIR_X11
+
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
+# System compiler is gcc 4.2.1 up to OpenBSD 6.0.
+# For proper C++11 support, we need to use a newer gcc from ports/packages,
+# where compiler commands are renamed to egcc/eg++. Therefore, redefine
+# mkspecs/common/g++-base.conf compiler commands
+QMAKE_CC = egcc
+
+QMAKE_LINK_C = $$QMAKE_CC
+QMAKE_LINK_C_SHLIB = $$QMAKE_CC
+
+QMAKE_CXX = eg++
+
+QMAKE_LINK = $$QMAKE_CXX
+QMAKE_LINK_SHLIB = $$QMAKE_CXX
+
+
# Reset g++-unix.conf's NOUNDEF flags as OpenBSD libc can't handle environ
QMAKE_LFLAGS_NOUNDEF =
diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp
index 1d2b806a26..74d24aacf4 100644
--- a/qmake/library/qmakebuiltins.cpp
+++ b/qmake/library/qmakebuiltins.cpp
@@ -1131,7 +1131,11 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
QString rstr = QDir::cleanPath(
QDir(args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory())
.absoluteFilePath(args.at(0).toQString(m_tmp1)));
- ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0)));
+ ret << (rstr.isSharedWith(m_tmp1)
+ ? args.at(0)
+ : args.count() > 1 && rstr.isSharedWith(m_tmp2)
+ ? args.at(1)
+ : ProString(rstr).setSource(args.at(0)));
}
break;
case E_RELATIVE_PATH:
@@ -1305,7 +1309,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ReturnFalse;
case T_REQUIRES:
#ifdef PROEVALUATOR_FULL
- checkRequirements(args);
+ if (checkRequirements(args) == ReturnError)
+ return ReturnError;
#endif
return ReturnFalse; // Another qmake breakage
case T_EVAL: {
@@ -1327,8 +1332,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
evalError(fL1S("if(condition) requires one argument."));
return ReturnFalse;
}
- return returnBool(evaluateConditional(args.at(0).toQStringRef(),
- m_current.pro->fileName(), m_current.line));
+ return evaluateConditional(args.at(0).toQStringRef(),
+ m_current.pro->fileName(), m_current.line);
}
case T_CONFIG: {
if (args.count() < 1 || args.count() > 2) {
diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp
index b0def45447..9d7ed2099b 100644
--- a/qmake/library/qmakeevaluator.cpp
+++ b/qmake/library/qmakeevaluator.cpp
@@ -405,7 +405,7 @@ static ALWAYS_INLINE void addStrList(
}
}
-void QMakeEvaluator::evaluateExpression(
+QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateExpression(
const ushort *&tokPtr, ProStringList *ret, bool joined)
{
debugMsg(2, joined ? "evaluating joined expression" : "evaluating expression");
@@ -455,12 +455,15 @@ void QMakeEvaluator::evaluateExpression(
case TokFuncName: {
const ProKey &func = pro->getHashStr(tokPtr);
debugMsg(2, "function %s", dbgKey(func));
- addStrList(evaluateExpandFunction(func, tokPtr), tok, ret, pending, joined);
+ ProStringList val;
+ if (evaluateExpandFunction(func, tokPtr, &val) == ReturnError)
+ return ReturnError;
+ addStrList(val, tok, ret, pending, joined);
break; }
default:
debugMsg(2, "evaluated expression => %s", dbgStrList(*ret));
tokPtr--;
- return;
+ return ReturnTrue;
}
}
}
@@ -532,7 +535,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
case TokAppendUnique:
case TokRemove:
case TokReplace:
- visitProVariable(tok, curr, tokPtr);
+ ret = visitProVariable(tok, curr, tokPtr);
+ if (ret == ReturnError)
+ break;
curr.clear();
continue;
case TokBranch:
@@ -692,9 +697,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
continue;
default: {
const ushort *oTokPtr = --tokPtr;
- evaluateExpression(tokPtr, &curr, false);
- if (tokPtr != oTokPtr)
- continue;
+ ret = evaluateExpression(tokPtr, &curr, false);
+ if (ret == ReturnError || tokPtr != oTokPtr)
+ break;
}
Q_ASSERT_X(false, "visitProBlock", "unexpected item type");
continue;
@@ -727,7 +732,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop(
int index = 0;
ProKey variable;
ProStringList oldVarVal;
- ProString it_list = expandVariableReferences(exprPtr, 0, true).at(0);
+ ProStringList it_list_out;
+ if (expandVariableReferences(exprPtr, 0, &it_list_out, true) == ReturnError)
+ return ReturnError;
+ ProString it_list = it_list_out.at(0);
if (_variable.isEmpty()) {
if (it_list != statics.strever) {
evalError(fL1S("Invalid loop expression."));
@@ -826,7 +834,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop(
return ret;
}
-void QMakeEvaluator::visitProVariable(
+QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
ushort tok, const ProStringList &curr, const ushort *&tokPtr)
{
int sizeHint = *tokPtr++;
@@ -835,24 +843,26 @@ void QMakeEvaluator::visitProVariable(
skipExpression(tokPtr);
if (!m_cumulative || !curr.isEmpty())
evalError(fL1S("Left hand side of assignment must expand to exactly one word."));
- return;
+ return ReturnTrue;
}
const ProKey &varName = map(curr.first());
if (tok == TokReplace) { // ~=
// DEFINES ~= s/a/b/?[gqi]
- const ProStringList &varVal = expandVariableReferences(tokPtr, sizeHint, true);
+ ProStringList varVal;
+ if (expandVariableReferences(tokPtr, sizeHint, &varVal, true) == ReturnError)
+ return ReturnError;
const QString &val = varVal.at(0).toQString(m_tmp1);
if (val.length() < 4 || val.at(0) != QLatin1Char('s')) {
evalError(fL1S("The ~= operator can handle only the s/// function."));
- return;
+ return ReturnTrue;
}
QChar sep = val.at(1);
QStringList func = val.split(sep);
if (func.count() < 3 || func.count() > 4) {
evalError(fL1S("The s/// function expects 3 or 4 arguments."));
- return;
+ return ReturnTrue;
}
bool global = false, quote = false, case_sense = false;
@@ -873,7 +883,9 @@ void QMakeEvaluator::visitProVariable(
replaceInList(&valuesRef(varName), regexp, replace, global, m_tmp2);
debugMsg(2, "replaced %s with %s", dbgQStr(pattern), dbgQStr(replace));
} else {
- ProStringList varVal = expandVariableReferences(tokPtr, sizeHint);
+ ProStringList varVal;
+ if (expandVariableReferences(tokPtr, sizeHint, &varVal, false) == ReturnError)
+ return ReturnError;
switch (tok) {
default: // whatever - cannot happen
case TokAssign: // =
@@ -919,8 +931,10 @@ void QMakeEvaluator::visitProVariable(
}
#ifdef PROEVALUATOR_FULL
else if (varName == statics.strREQUIRES)
- checkRequirements(values(varName));
+ return checkRequirements(values(varName));
#endif
+
+ return ReturnTrue;
}
void QMakeEvaluator::setTemplate()
@@ -1612,18 +1626,18 @@ bool QMakeEvaluator::isActiveConfig(const QStringRef &config, bool regex)
return false;
}
-ProStringList QMakeEvaluator::expandVariableReferences(
- const ushort *&tokPtr, int sizeHint, bool joined)
+QMakeEvaluator::VisitReturn QMakeEvaluator::expandVariableReferences(
+ const ushort *&tokPtr, int sizeHint, ProStringList *ret, bool joined)
{
- ProStringList ret;
- ret.reserve(sizeHint);
+ ret->reserve(sizeHint);
forever {
- evaluateExpression(tokPtr, &ret, joined);
+ if (evaluateExpression(tokPtr, ret, joined) == ReturnError)
+ return ReturnError;
switch (*tokPtr) {
case TokValueTerminator:
case TokFuncTerminator:
tokPtr++;
- return ret;
+ return ReturnTrue;
case TokArgSeparator:
if (joined) {
tokPtr++;
@@ -1637,28 +1651,28 @@ ProStringList QMakeEvaluator::expandVariableReferences(
}
}
-QList<ProStringList> QMakeEvaluator::prepareFunctionArgs(const ushort *&tokPtr)
+QMakeEvaluator::VisitReturn QMakeEvaluator::prepareFunctionArgs(
+ const ushort *&tokPtr, QList<ProStringList> *ret)
{
- QList<ProStringList> args_list;
if (*tokPtr != TokFuncTerminator) {
for (;; tokPtr++) {
ProStringList arg;
- evaluateExpression(tokPtr, &arg, false);
- args_list << arg;
+ if (evaluateExpression(tokPtr, &arg, false) == ReturnError)
+ return ReturnError;
+ *ret << arg;
if (*tokPtr == TokFuncTerminator)
break;
Q_ASSERT(*tokPtr == TokArgSeparator);
}
}
tokPtr++;
- return args_list;
+ return ReturnTrue;
}
-ProStringList QMakeEvaluator::evaluateFunction(
- const ProFunctionDef &func, const QList<ProStringList> &argumentsList, VisitReturn *ok)
+QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFunction(
+ const ProFunctionDef &func, const QList<ProStringList> &argumentsList, ProStringList *ret)
{
VisitReturn vr;
- ProStringList ret;
if (m_valuemapStack.count() >= 100) {
evalError(fL1S("Ran into infinite recursion (depth > 100)."));
@@ -1677,25 +1691,22 @@ ProStringList QMakeEvaluator::evaluateFunction(
vr = visitProBlock(func.pro(), func.tokPtr());
if (vr == ReturnReturn)
vr = ReturnTrue;
- ret = m_returnValue;
+ if (vr == ReturnTrue)
+ *ret = m_returnValue;
m_returnValue.clear();
m_current = m_locationStack.pop();
m_valuemapStack.pop();
}
- if (ok)
- *ok = vr;
- if (vr == ReturnTrue)
- return ret;
- return ProStringList();
+ return vr;
}
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBoolFunction(
const ProFunctionDef &func, const QList<ProStringList> &argumentsList,
const ProString &function)
{
- VisitReturn vr;
- ProStringList ret = evaluateFunction(func, argumentsList, &vr);
+ ProStringList ret;
+ VisitReturn vr = evaluateFunction(func, argumentsList, &ret);
if (vr == ReturnTrue) {
if (ret.isEmpty())
return ReturnTrue;
@@ -1723,13 +1734,18 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
{
if (int func_t = statics.functions.value(func)) {
//why don't the builtin functions just use args_list? --Sam
- return evaluateBuiltinConditional(func_t, func, expandVariableReferences(tokPtr, 5, true));
+ ProStringList args;
+ if (expandVariableReferences(tokPtr, 5, &args, true) == ReturnError)
+ return ReturnError;
+ return evaluateBuiltinConditional(func_t, func, args);
}
QHash<ProKey, ProFunctionDef>::ConstIterator it =
m_functionDefs.testFunctions.constFind(func);
if (it != m_functionDefs.testFunctions.constEnd()) {
- const QList<ProStringList> args = prepareFunctionArgs(tokPtr);
+ QList<ProStringList> args;
+ if (prepareFunctionArgs(tokPtr, &args) == ReturnError)
+ return ReturnError;
traceMsg("calling %s(%s)", dbgKey(func), dbgStrListList(args));
return evaluateBoolFunction(*it, args, func);
}
@@ -1739,34 +1755,41 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
return ReturnFalse;
}
-ProStringList QMakeEvaluator::evaluateExpandFunction(
- const ProKey &func, const ushort *&tokPtr)
+QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateExpandFunction(
+ const ProKey &func, const ushort *&tokPtr, ProStringList *ret)
{
if (int func_t = statics.expands.value(func)) {
//why don't the builtin functions just use args_list? --Sam
- return evaluateBuiltinExpand(func_t, func, expandVariableReferences(tokPtr, 5, true));
+ ProStringList args;
+ if (expandVariableReferences(tokPtr, 5, &args, true) == ReturnError)
+ return ReturnError;
+ *ret = evaluateBuiltinExpand(func_t, func, args);
+ return ReturnTrue;
}
QHash<ProKey, ProFunctionDef>::ConstIterator it =
m_functionDefs.replaceFunctions.constFind(func);
if (it != m_functionDefs.replaceFunctions.constEnd()) {
- const QList<ProStringList> args = prepareFunctionArgs(tokPtr);
+ QList<ProStringList> args;
+ if (prepareFunctionArgs(tokPtr, &args) == ReturnError)
+ return ReturnError;
traceMsg("calling $$%s(%s)", dbgKey(func), dbgStrListList(args));
- return evaluateFunction(*it, args, 0);
+ return evaluateFunction(*it, args, ret);
}
skipExpression(tokPtr);
evalError(fL1S("'%1' is not a recognized replace function.").arg(func.toQString(m_tmp1)));
- return ProStringList();
+ return ReturnFalse;
}
-bool QMakeEvaluator::evaluateConditional(const QStringRef &cond, const QString &where, int line)
+QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional(
+ const QStringRef &cond, const QString &where, int line)
{
- bool ret = false;
+ VisitReturn ret = ReturnFalse;
ProFile *pro = m_parser->parsedProBlock(cond, where, line, QMakeParser::TestGrammar);
if (pro->isOk()) {
m_locationStack.push(m_current);
- ret = visitProBlock(pro, pro->tokPtr()) == ReturnTrue;
+ ret = visitProBlock(pro, pro->tokPtr());
m_current = m_locationStack.pop();
}
pro->deref();
@@ -1774,28 +1797,49 @@ bool QMakeEvaluator::evaluateConditional(const QStringRef &cond, const QString &
}
#ifdef PROEVALUATOR_FULL
-void QMakeEvaluator::checkRequirements(const ProStringList &deps)
+QMakeEvaluator::VisitReturn QMakeEvaluator::checkRequirements(const ProStringList &deps)
{
ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS"));
- for (const ProString &dep : deps)
- if (!evaluateConditional(dep.toQStringRef(), m_current.pro->fileName(), m_current.line))
+ for (const ProString &dep : deps) {
+ VisitReturn vr = evaluateConditional(dep.toQStringRef(), m_current.pro->fileName(), m_current.line);
+ if (vr == ReturnError)
+ return ReturnError;
+ if (vr != ReturnTrue)
failed << dep;
+ }
+ return ReturnTrue;
}
#endif
+static bool isFunctParam(const ProKey &variableName)
+{
+ const int len = variableName.size();
+ const QChar *data = variableName.constData();
+ for (int i = 0; i < len; i++) {
+ ushort c = data[i].unicode();
+ if (c < '0' || c > '9')
+ return false;
+ }
+ return true;
+}
+
ProValueMap *QMakeEvaluator::findValues(const ProKey &variableName, ProValueMap::Iterator *rit)
{
ProValueMapStack::Iterator vmi = m_valuemapStack.end();
- do {
+ for (bool first = true; ; first = false) {
--vmi;
ProValueMap::Iterator it = (*vmi).find(variableName);
if (it != (*vmi).end()) {
if (it->constBegin() == statics.fakeValue.constBegin())
- return 0;
+ break;
*rit = it;
return &(*vmi);
}
- } while (vmi != m_valuemapStack.begin());
+ if (vmi == m_valuemapStack.begin())
+ break;
+ if (first && isFunctParam(variableName))
+ break;
+ }
return 0;
}
@@ -1807,18 +1851,20 @@ ProStringList &QMakeEvaluator::valuesRef(const ProKey &variableName)
it->clear();
return *it;
}
- ProValueMapStack::Iterator vmi = m_valuemapStack.end();
- if (--vmi != m_valuemapStack.begin()) {
- do {
- --vmi;
- ProValueMap::ConstIterator it = (*vmi).constFind(variableName);
- if (it != (*vmi).constEnd()) {
- ProStringList &ret = m_valuemapStack.top()[variableName];
- if (it->constBegin() != statics.fakeValue.constBegin())
- ret = *it;
- return ret;
- }
- } while (vmi != m_valuemapStack.begin());
+ if (!isFunctParam(variableName)) {
+ ProValueMapStack::Iterator vmi = m_valuemapStack.end();
+ if (--vmi != m_valuemapStack.begin()) {
+ do {
+ --vmi;
+ ProValueMap::ConstIterator it = (*vmi).constFind(variableName);
+ if (it != (*vmi).constEnd()) {
+ ProStringList &ret = m_valuemapStack.top()[variableName];
+ if (it->constBegin() != statics.fakeValue.constBegin())
+ ret = *it;
+ return ret;
+ }
+ } while (vmi != m_valuemapStack.begin());
+ }
}
return m_valuemapStack.top()[variableName];
}
@@ -1826,7 +1872,7 @@ ProStringList &QMakeEvaluator::valuesRef(const ProKey &variableName)
ProStringList QMakeEvaluator::values(const ProKey &variableName) const
{
ProValueMapStack::ConstIterator vmi = m_valuemapStack.constEnd();
- do {
+ for (bool first = true; ; first = false) {
--vmi;
ProValueMap::ConstIterator it = (*vmi).constFind(variableName);
if (it != (*vmi).constEnd()) {
@@ -1834,7 +1880,11 @@ ProStringList QMakeEvaluator::values(const ProKey &variableName) const
break;
return *it;
}
- } while (vmi != m_valuemapStack.constBegin());
+ if (vmi == m_valuemapStack.constBegin())
+ break;
+ if (first && isFunctParam(variableName))
+ break;
+ }
return ProStringList();
}
diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h
index ab13b24645..eddabe39a0 100644
--- a/qmake/library/qmakeevaluator.h
+++ b/qmake/library/qmakeevaluator.h
@@ -148,7 +148,7 @@ public:
{ return b ? ReturnTrue : ReturnFalse; }
static ALWAYS_INLINE uint getBlockLen(const ushort *&tokPtr);
- void evaluateExpression(const ushort *&tokPtr, ProStringList *ret, bool joined);
+ VisitReturn evaluateExpression(const ushort *&tokPtr, ProStringList *ret, bool joined);
static ALWAYS_INLINE void skipStr(const ushort *&tokPtr);
static ALWAYS_INLINE void skipHashStr(const ushort *&tokPtr);
void skipExpression(const ushort *&tokPtr);
@@ -168,7 +168,7 @@ public:
VisitReturn visitProLoop(const ProKey &variable, const ushort *exprPtr,
const ushort *tokPtr);
void visitProFunctionDef(ushort tok, const ProKey &name, const ushort *tokPtr);
- void visitProVariable(ushort tok, const ProStringList &curr, const ushort *&tokPtr);
+ VisitReturn visitProVariable(ushort tok, const ProStringList &curr, const ushort *&tokPtr);
ALWAYS_INLINE const ProKey &map(const ProString &var) { return map(var.toKey()); }
const ProKey &map(const ProKey &var);
@@ -177,8 +177,7 @@ public:
void setTemplate();
ProStringList split_value_list(const QStringRef &vals, const ProFile *source = 0);
- ProStringList expandVariableReferences(const ProString &value, int *pos = 0, bool joined = false);
- ProStringList expandVariableReferences(const ushort *&tokPtr, int sizeHint = 0, bool joined = false);
+ VisitReturn expandVariableReferences(const ushort *&tokPtr, int sizeHint, ProStringList *ret, bool joined);
QString currentFileName() const;
QString currentDirectory() const;
@@ -203,22 +202,22 @@ public:
void deprecationWarning(const QString &msg) const
{ message(QMakeHandler::EvalWarnDeprecated, msg); }
- QList<ProStringList> prepareFunctionArgs(const ushort *&tokPtr);
- ProStringList evaluateFunction(const ProFunctionDef &func,
- const QList<ProStringList> &argumentsList, VisitReturn *ok);
+ VisitReturn prepareFunctionArgs(const ushort *&tokPtr, QList<ProStringList> *ret);
+ VisitReturn evaluateFunction(const ProFunctionDef &func,
+ const QList<ProStringList> &argumentsList, ProStringList *ret);
VisitReturn evaluateBoolFunction(const ProFunctionDef &func,
const QList<ProStringList> &argumentsList,
const ProString &function);
- ProStringList evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr);
+ VisitReturn evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr, ProStringList *ret);
VisitReturn evaluateConditionalFunction(const ProKey &function, const ushort *&tokPtr);
ProStringList evaluateBuiltinExpand(int func_t, const ProKey &function, const ProStringList &args);
VisitReturn evaluateBuiltinConditional(int func_t, const ProKey &function, const ProStringList &args);
- bool evaluateConditional(const QStringRef &cond, const QString &where, int line = -1);
+ VisitReturn evaluateConditional(const QStringRef &cond, const QString &where, int line = -1);
#ifdef PROEVALUATOR_FULL
- void checkRequirements(const ProStringList &deps);
+ VisitReturn checkRequirements(const ProStringList &deps);
#endif
void updateMkspecPaths();
diff --git a/qmake/library/qmakeparser.cpp b/qmake/library/qmakeparser.cpp
index 90bc64bd2b..7d645625a1 100644
--- a/qmake/library/qmakeparser.cpp
+++ b/qmake/library/qmakeparser.cpp
@@ -299,27 +299,30 @@ void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar
// Worst-case size calculations:
// - line marker adds 1 (2-nl) to 1st token of each line
// - empty assignment "A=":2 =>
- // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokAssign(1) + 0(1) +
+ // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokAssign(1) + size_hint(1) +
// TokValueTerminator(1) == 8 (9)
// - non-empty assignment "A=B C":5 =>
- // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokAssign(1) + 2(1) +
+ // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokAssign(1) + size_hint(1) +
// TokLiteral(1) + len(1) + "B"(1) +
// TokLiteral(1) + len(1) + "C"(1) + TokValueTerminator(1) == 14 (15)
// - variable expansion: "$$f":3 =>
// TokVariable(1) + hash(2) + len(1) + "f"(1) = 5
// - function expansion: "$$f()":5 =>
// TokFuncName(1) + hash(2) + len(1) + "f"(1) + TokFuncTerminator(1) = 6
+ // - test literal: "X":1 =>
+ // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokCondition(1) = 6 (7)
// - scope: "X:":2 =>
// TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokCondition(1) +
- // TokBranch(1) + len(2) + ... + len(2) + ... == 10
- // - test: "X():":4 =>
+ // TokBranch(1) + len(2) + ... + len(2) + ... == 11 (12)
+ // - test call: "X():":4 =>
// TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokTestCall(1) + TokFuncTerminator(1) +
- // TokBranch(1) + len(2) + ... + len(2) + ... == 11
+ // TokBranch(1) + len(2) + ... + len(2) + ... == 12 (13)
// - "for(A,B):":9 =>
// TokForLoop(1) + hash(2) + len(1) + "A"(1) +
// len(2) + TokLiteral(1) + len(1) + "B"(1) + TokValueTerminator(1) +
// len(2) + ... + TokTerminator(1) == 14 (15)
- tokBuff.reserve((in.size() + 1) * 5);
+ // One extra for possibly missing trailing newline.
+ tokBuff.reserve((in.size() + 1) * 7);
ushort *tokPtr = (ushort *)tokBuff.constData(); // Current writing position
// Expression precompiler buffer.
diff --git a/qmake/project.cpp b/qmake/project.cpp
index 28a6c72a46..2f8411d52f 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -105,9 +105,8 @@ QStringList QMakeProject::expand(const ProKey &func, const QList<ProStringList>
QHash<ProKey, ProFunctionDef>::ConstIterator it =
m_functionDefs.replaceFunctions.constFind(func);
if (it != m_functionDefs.replaceFunctions.constEnd()) {
- QMakeProject::VisitReturn vr;
- ProStringList ret = evaluateFunction(*it, args, &vr);
- if (vr == QMakeProject::ReturnError)
+ ProStringList ret;
+ if (evaluateFunction(*it, args, &ret) == QMakeProject::ReturnError)
exit(3);
return ret.toQStringList();
}
@@ -126,7 +125,9 @@ ProString QMakeProject::expand(const QString &expr, const QString &where, int li
m_current.pro = pro;
m_current.line = 0;
const ushort *tokPtr = pro->tokPtr();
- ProStringList result = expandVariableReferences(tokPtr, 1, true);
+ ProStringList result;
+ if (expandVariableReferences(tokPtr, 1, &result, true) == ReturnError)
+ exit(3);
if (!result.isEmpty())
ret = result.at(0);
}
diff --git a/qmake/project.h b/qmake/project.h
index 4986c7c82d..d7a5852bed 100644
--- a/qmake/project.h
+++ b/qmake/project.h
@@ -55,7 +55,7 @@ public:
ProString expand(const QString &v, const QString &file, int line);
QStringList expand(const ProKey &func, const QList<ProStringList> &args);
bool test(const QString &v, const QString &file, int line)
- { m_current.clear(); return evaluateConditional(QStringRef(&v), file, line); }
+ { m_current.clear(); return evaluateConditional(QStringRef(&v), file, line) == ReturnTrue; }
bool test(const ProKey &func, const QList<ProStringList> &args);
bool isSet(const ProKey &v) const { return m_valuemapStack.first().contains(v); }
diff --git a/src/angle/README.qt b/src/angle/README.qt
index ce5b6332bc..2d484a0280 100644
--- a/src/angle/README.qt
+++ b/src/angle/README.qt
@@ -1,6 +1,6 @@
This is the ANGLE project from:
-http://code.google.com/p/angleproject/
+https://chromium.googlesource.com/angle/angle/+/master/README.md
The upstream version used here can be found in:
diff --git a/src/angle/src/common/common.pri b/src/angle/src/common/common.pri
index 83cd1e8687..9eae06d410 100644
--- a/src/angle/src/common/common.pri
+++ b/src/angle/src/common/common.pri
@@ -21,7 +21,7 @@ lib_replace.CONFIG = path
QMAKE_PRL_INSTALL_REPLACE += lib_replace
# DirectX is included in the Windows 8 Kit, but everything else requires the DX SDK.
-winrt|if(msvc:!win32-msvc2005:!win32-msvc2008:!win32-msvc2010) {
+winrt|msvc {
FXC = fxc.exe
} else {
DX_DIR = $$(DXSDK_DIR)
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index f492148a50..a5ed8b2ea3 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -46,21 +46,6 @@ if (NOT TARGET Qt5::rcc)
)
endif()
-if (NOT TARGET Qt5::qdoc)
- add_executable(Qt5::qdoc IMPORTED)
-
-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
- set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qdoc$$CMAKE_BIN_SUFFIX\")
-!!ELSE
- set(imported_location \"$${CMAKE_BIN_DIR}qdoc$$CMAKE_BIN_SUFFIX\")
-!!ENDIF
- _qt5_Core_check_file_exists(${imported_location})
-
- set_target_properties(Qt5::qdoc PROPERTIES
- IMPORTED_LOCATION ${imported_location}
- )
-endif()
-
set(Qt5Core_QMAKE_EXECUTABLE Qt5::qmake)
set(Qt5Core_MOC_EXECUTABLE Qt5::moc)
set(Qt5Core_RCC_EXECUTABLE Qt5::rcc)
diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h
index bb49aae4fb..9658aca37c 100644
--- a/src/corelib/arch/qatomic_cxx11.h
+++ b/src/corelib/arch/qatomic_cxx11.h
@@ -53,44 +53,168 @@ QT_END_NAMESPACE
#pragma qt_sync_stop_processing
#endif
-#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
-#define Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE
-#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
-#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+/* Attempt to detect whether the atomic operations exist in hardware
+ * or whether they are emulated by way of a lock.
+ *
+ * C++11 29.4 [atomics.lockfree] p1 says
+ *
+ * The ATOMIC_..._LOCK_FREE macros indicate the lock-free property of the
+ * corresponding atomic types, with the signed and unsigned variants grouped
+ * together. The properties also apply to the corresponding (partial)
+ * specializations of the atomic template. A value of 0 indicates that the
+ * types are never lock-free. A value of 1 indicates that the types are
+ * sometimes lock-free. A value of 2 indicates that the types are always
+ * lock-free.
+ *
+ * We have a problem when the value is 1: we'd need to check at runtime, but
+ * QAtomicInteger requires a constexpr answer (defect introduced in Qt 5.0). So
+ * we'll err in the side of caution and say it isn't.
+ */
+
+// ### Qt 6: make non-constexpr (see above)
+template <int N> struct QAtomicTraits
+{ static Q_DECL_CONSTEXPR inline bool isLockFree() Q_DECL_NOTHROW; };
#define Q_ATOMIC_INT32_IS_SUPPORTED
-#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
-#define Q_ATOMIC_INT32_TEST_AND_SET_IS_SOMETIMES_NATIVE
-#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
-#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+#if ATOMIC_INT_LOCK_FREE == 2
+# define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT32_TEST_AND_SET_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<4>::isLockFree() Q_DECL_NOTHROW
+{ return true; }
+#elif ATOMIC_INT_LOCK_FREE == 1
+# define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT32_TEST_AND_SET_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<4>::isLockFree() Q_DECL_NOTHROW
+{ return false; }
+#else
+# define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT_TEST_AND_SET_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT_FETCH_AND_STORE_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT_FETCH_AND_ADD_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT32_TEST_AND_SET_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_NEVER_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<4>::isLockFree() Q_DECL_NOTHROW
+{ return false; }
+#endif
-#define Q_ATOMIC_POINTER_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
-#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE
-#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
-#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+#if ATOMIC_POINTER_LOCK_FREE == 2
+# define Q_ATOMIC_POINTER_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+#elif ATOMIC_POINTER_LOCK_FREE == 1
+# define Q_ATOMIC_POINTER_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+#else
+# define Q_ATOMIC_POINTER_REFERENCE_COUNTING_IS_NEVER_NATIVE
+# define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NEVER_NATIVE
+# define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NEVER_NATIVE
+# define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NEVER_NATIVE
+#endif
template<> struct QAtomicOpsSupport<1> { enum { IsSupported = 1 }; };
-template<> struct QAtomicOpsSupport<2> { enum { IsSupported = 1 }; };
-template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; };
-
#define Q_ATOMIC_INT8_IS_SUPPORTED
-#define Q_ATOMIC_INT8_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
-#define Q_ATOMIC_INT8_TEST_AND_SET_IS_ALWAYS_NATIVE
-#define Q_ATOMIC_INT8_FETCH_AND_STORE_IS_ALWAYS_NATIVE
-#define Q_ATOMIC_INT8_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+#if ATOMIC_CHAR_LOCK_FREE == 2
+# define Q_ATOMIC_INT8_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT8_TEST_AND_SET_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT8_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT8_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<1>::isLockFree() Q_DECL_NOTHROW
+{ return true; }
+#elif ATOMIC_CHAR_LOCK_FREE == 1
+# define Q_ATOMIC_INT8_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT8_TEST_AND_SET_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT8_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT8_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<1>::isLockFree() Q_DECL_NOTHROW
+{ return false; }
+#else
+# define Q_ATOMIC_INT8_REFERENCE_COUNTING_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT8_TEST_AND_SET_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT8_FETCH_AND_STORE_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT8_FETCH_AND_ADD_IS_NEVER_NATIVE
+template <> Q_DECL_CONSTEXPR bool QAtomicTraits<1>::isLockFree() Q_DECL_NOTHROW
+{ return false; }
+#endif
+
+template<> struct QAtomicOpsSupport<2> { enum { IsSupported = 1 }; };
#define Q_ATOMIC_INT16_IS_SUPPORTED
-#define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
-#define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE
-#define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE
-#define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+#if ATOMIC_SHORT_LOCK_FREE == 2
+# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<2>::isLockFree() Q_DECL_NOTHROW
+{ return false; }
+#elif ATOMIC_SHORT_LOCK_FREE == 1
+# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT16_TEST_AND_SET_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<2>::isLockFree() Q_DECL_NOTHROW
+{ return false; }
+#else
+# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT16_TEST_AND_SET_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_NEVER_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<2>::isLockFree() Q_DECL_NOTHROW
+{ return false; }
+#endif
#ifndef QT_NO_STD_ATOMIC64
+template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; };
# define Q_ATOMIC_INT64_IS_SUPPORTED
-# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
-# define Q_ATOMIC_INT64_TEST_AND_SET_IS_ALWAYS_NATIVE
-# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE
-# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+# if ATOMIC_LLONG_LOCK_FREE == 2
+# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<8>::isLockFree() Q_DECL_NOTHROW
+{ return true; }
+# elif ATOMIC_LLONG_LOCK_FREE == 1
+# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT16_TEST_AND_SET_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<8>::isLockFree() Q_DECL_NOTHROW
+{ return false; }
+# else
+# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT16_TEST_AND_SET_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_NEVER_NATIVE
+# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_NEVER_NATIVE
+
+template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<8>::isLockFree() Q_DECL_NOTHROW
+{ return false; }
+# endif
#endif
template <typename X> struct QAtomicOps
@@ -133,7 +257,7 @@ template <typename X> struct QAtomicOps
_q_value.store(newValue, std::memory_order_release);
}
- static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
+ static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return isTestAndSetNative(); }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T>
static inline bool ref(std::atomic<T> &_q_value)
@@ -147,7 +271,8 @@ template <typename X> struct QAtomicOps
return --_q_value != 0;
}
- static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
+ static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW
+ { return QAtomicTraits<sizeof(X)>::isLockFree(); }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T>
@@ -186,7 +311,7 @@ template <typename X> struct QAtomicOps
return tmp;
}
- static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; }
+ static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return isTestAndSetNative(); }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T>
@@ -213,7 +338,7 @@ template <typename X> struct QAtomicOps
return _q_value.exchange(newValue, std::memory_order_acq_rel);
}
- static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; }
+ static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return isTestAndSetNative(); }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; }
template <typename T> static inline
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 ae969ca269..1169ad5536 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -603,13 +603,13 @@ template<> class QTypeInfo<A> : public QTypeInfoMerger<A, B, C, D> {};
void overloadedFunction();
void overloadedFunction(int, QString);
};
- ... qOverload<>(&Foo:overloadedFunction)
- ... qOverload<int, QString>(&Foo:overloadedFunction)
+ ... qOverload<>(&Foo::overloadedFunction)
+ ... qOverload<int, QString>(&Foo::overloadedFunction)
//! [52]
//! [53]
- ... QOverload<>::of(&Foo:overloadedFunction)
- ... QOverload<int, QString>::of(&Foo:overloadedFunction)
+ ... QOverload<>::of(&Foo::overloadedFunction)
+ ... QOverload<int, QString>::of(&Foo::overloadedFunction)
//! [53]
//! [54]
@@ -617,8 +617,8 @@ template<> class QTypeInfo<A> : public QTypeInfoMerger<A, B, C, D> {};
void overloadedFunction(int, QString);
void overloadedFunction(int, QString) const;
};
- ... qConstOverload<>(&Foo:overloadedFunction)
- ... qNonConstOverload<int, QString>(&Foo:overloadedFunction)
+ ... qConstOverload<>(&Foo::overloadedFunction)
+ ... qNonConstOverload<int, QString>(&Foo::overloadedFunction)
//! [54]
//! [qlikely]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp
index 576aea1cf5..ca1ea21b02 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp
@@ -147,10 +147,7 @@ QVariant data = QVariant::fromValue(object);
//! [9]
-QList<int> intList;
-intList.push_back(7);
-intList.push_back(11);
-intList.push_back(42);
+QList<int> intList = {7, 11, 42};
QVariant variant = QVariant::fromValue(intList);
if (variant.canConvert<QVariantList>()) {
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 0fe095b8d3..3aee15051f 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1123,7 +1123,7 @@ void QMessagePattern::setPattern(const QString &pattern)
if (m.hasMatch()) {
int depth = m.capturedRef(1).toInt();
if (depth <= 0)
- error += QStringLiteral("QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n");
+ error += QLatin1String("QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n");
else
backtraceDepth = depth;
}
@@ -1135,7 +1135,7 @@ void QMessagePattern::setPattern(const QString &pattern)
backtraceParams.backtraceSeparator = backtraceSeparator;
backtraceArgs.append(backtraceParams);
#else
- error += QStringLiteral("QT_MESSAGE_PATTERN: %{backtrace} is not supported by this Qt build\n");
+ error += QLatin1String("QT_MESSAGE_PATTERN: %{backtrace} is not supported by this Qt build\n");
#endif
}
@@ -1156,7 +1156,7 @@ void QMessagePattern::setPattern(const QString &pattern)
else if (lexeme == QLatin1String(endifTokenC)) {
tokens[i] = endifTokenC;
if (!inIf && !nestedIfError)
- error += QStringLiteral("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n");
+ error += QLatin1String("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n");
inIf = false;
} else {
tokens[i] = emptyTokenC;
@@ -1172,9 +1172,9 @@ void QMessagePattern::setPattern(const QString &pattern)
}
}
if (nestedIfError)
- error += QStringLiteral("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n");
+ error += QLatin1String("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n");
else if (inIf)
- error += QStringLiteral("QT_MESSAGE_PATTERN: missing %{endif}\n");
+ error += QLatin1String("QT_MESSAGE_PATTERN: missing %{endif}\n");
if (!error.isEmpty()) {
#if defined(Q_OS_WINRT)
OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16()));
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index c7f8840a82..5956f9ac40 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -195,6 +195,29 @@ private:
int readBlock(char *data, int len);
};
+namespace QtPrivate {
+
+class StreamStateSaver
+{
+public:
+ inline StreamStateSaver(QDataStream *s) : stream(s), oldStatus(s->status())
+ {
+ stream->resetStatus();
+ }
+ inline ~StreamStateSaver()
+ {
+ if (oldStatus != QDataStream::Ok) {
+ stream->resetStatus();
+ stream->setStatus(oldStatus);
+ }
+ }
+
+private:
+ QDataStream *stream;
+ QDataStream::Status oldStatus;
+};
+
+} // QtPrivate namespace
/*****************************************************************************
QDataStream inline functions
@@ -239,6 +262,8 @@ inline QDataStream &QDataStream::operator<<(quint64 i)
template <typename T>
QDataStream& operator>>(QDataStream& s, QList<T>& l)
{
+ QtPrivate::StreamStateSaver stateSaver(&s);
+
l.clear();
quint32 c;
s >> c;
@@ -247,10 +272,13 @@ QDataStream& operator>>(QDataStream& s, QList<T>& l)
{
T t;
s >> t;
- l.append(t);
- if (s.atEnd())
+ if (s.status() != QDataStream::Ok) {
+ l.clear();
break;
+ }
+ l.append(t);
}
+
return s;
}
@@ -266,6 +294,8 @@ QDataStream& operator<<(QDataStream& s, const QList<T>& l)
template <typename T>
QDataStream& operator>>(QDataStream& s, QLinkedList<T>& l)
{
+ QtPrivate::StreamStateSaver stateSaver(&s);
+
l.clear();
quint32 c;
s >> c;
@@ -273,10 +303,13 @@ QDataStream& operator>>(QDataStream& s, QLinkedList<T>& l)
{
T t;
s >> t;
- l.append(t);
- if (s.atEnd())
+ if (s.status() != QDataStream::Ok) {
+ l.clear();
break;
+ }
+ l.append(t);
}
+
return s;
}
@@ -293,6 +326,8 @@ QDataStream& operator<<(QDataStream& s, const QLinkedList<T>& l)
template<typename T>
QDataStream& operator>>(QDataStream& s, QVector<T>& v)
{
+ QtPrivate::StreamStateSaver stateSaver(&s);
+
v.clear();
quint32 c;
s >> c;
@@ -300,8 +335,13 @@ QDataStream& operator>>(QDataStream& s, QVector<T>& v)
for(quint32 i = 0; i < c; ++i) {
T t;
s >> t;
+ if (s.status() != QDataStream::Ok) {
+ v.clear();
+ break;
+ }
v[i] = t;
}
+
return s;
}
@@ -317,16 +357,21 @@ QDataStream& operator<<(QDataStream& s, const QVector<T>& v)
template <typename T>
QDataStream &operator>>(QDataStream &in, QSet<T> &set)
{
+ QtPrivate::StreamStateSaver stateSaver(&in);
+
set.clear();
quint32 c;
in >> c;
for (quint32 i = 0; i < c; ++i) {
T t;
in >> t;
- set << t;
- if (in.atEnd())
+ if (in.status() != QDataStream::Ok) {
+ set.clear();
break;
+ }
+ set << t;
}
+
return in;
}
@@ -345,10 +390,9 @@ QDataStream& operator<<(QDataStream &out, const QSet<T> &set)
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QHash<Key, T> &hash)
{
- QDataStream::Status oldStatus = in.status();
- in.resetStatus();
- hash.clear();
+ QtPrivate::StreamStateSaver stateSaver(&in);
+ hash.clear();
quint32 n;
in >> n;
@@ -364,10 +408,6 @@ Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QHash<Key, T> &has
if (in.status() != QDataStream::Ok)
hash.clear();
- if (oldStatus != QDataStream::Ok) {
- in.resetStatus();
- in.setStatus(oldStatus);
- }
return in;
}
@@ -391,10 +431,9 @@ template <class aKey, class aT>
Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QMap<aKey, aT> &map)
#endif
{
- QDataStream::Status oldStatus = in.status();
- in.resetStatus();
- map.clear();
+ QtPrivate::StreamStateSaver stateSaver(&in);
+ map.clear();
quint32 n;
in >> n;
@@ -410,10 +449,6 @@ Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QMap<aKey, aT> &ma
}
if (in.status() != QDataStream::Ok)
map.clear();
- if (oldStatus != QDataStream::Ok) {
- in.resetStatus();
- in.setStatus(oldStatus);
- }
return in;
}
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 8197ea63e7..91953ebf26 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -694,7 +694,7 @@ QString QDir::filePath(const QString &fileName) const
{
const QDirPrivate* d = d_ptr.constData();
if (isAbsolutePath(fileName))
- return QString(fileName);
+ return fileName;
QString ret = d->dirEntry.filePath();
if (!fileName.isEmpty()) {
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index 63a15c9fac..920281cef7 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -388,7 +388,7 @@ QStringList QFileSelectorPrivate::platformSelectors()
# endif
QString productName = QSysInfo::productType();
# ifdef Q_OS_MACOS
- if (productName != QStringLiteral("osx"))
+ if (productName != QLatin1String("osx"))
ret << QStringLiteral("osx"); // compatibility
# endif
if (productName != QLatin1String("unknown"))
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index 79141d1e8f..924d2e7214 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -71,12 +71,12 @@
#elif defined(Q_OS_HAIKU)
# include <kernel/OS.h>
#elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT)
-# if !defined(Q_OS_NETBSD)
-# include <sys/user.h>
-# endif
# include <sys/cdefs.h>
# include <sys/param.h>
# include <sys/sysctl.h>
+# if !defined(Q_OS_NETBSD)
+# include <sys/user.h>
+# endif
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index ed3273eb2e..856108e417 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -248,8 +248,7 @@ QString QSettingsPrivate::actualKey(const QString &key) const
{
QString n = normalizedKey(key);
Q_ASSERT_X(!n.isEmpty(), "QSettings", "empty key");
- n.prepend(groupPrefix);
- return n;
+ return groupPrefix + n;
}
/*
@@ -324,10 +323,9 @@ void QSettingsPrivate::processChild(QStringRef key, ChildSpec spec, QStringList
void QSettingsPrivate::beginGroupOrArray(const QSettingsGroup &group)
{
groupStack.push(group);
- if (!group.name().isEmpty()) {
- groupPrefix += group.name();
- groupPrefix += QLatin1Char('/');
- }
+ const QString name = group.name();
+ if (!name.isEmpty())
+ groupPrefix += name + QLatin1Char('/');
}
/*
@@ -403,9 +401,9 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
case QVariant::ByteArray: {
QByteArray a = v.toByteArray();
- result = QLatin1String("@ByteArray(");
- result += QString::fromLatin1(a.constData(), a.size());
- result += QLatin1Char(')');
+ result = QLatin1String("@ByteArray(")
+ + QLatin1String(a.constData(), a.size())
+ + QLatin1Char(')');
break;
}
@@ -425,33 +423,17 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
#ifndef QT_NO_GEOM_VARIANT
case QVariant::Rect: {
QRect r = qvariant_cast<QRect>(v);
- result += QLatin1String("@Rect(");
- result += QString::number(r.x());
- result += QLatin1Char(' ');
- result += QString::number(r.y());
- result += QLatin1Char(' ');
- result += QString::number(r.width());
- result += QLatin1Char(' ');
- result += QString::number(r.height());
- result += QLatin1Char(')');
+ result = QString::asprintf("@Rect(%d %d %d %d)", r.x(), r.y(), r.width(), r.height());
break;
}
case QVariant::Size: {
QSize s = qvariant_cast<QSize>(v);
- result += QLatin1String("@Size(");
- result += QString::number(s.width());
- result += QLatin1Char(' ');
- result += QString::number(s.height());
- result += QLatin1Char(')');
+ result = QString::asprintf("@Size(%d %d)", s.width(), s.height());
break;
}
case QVariant::Point: {
QPoint p = qvariant_cast<QPoint>(v);
- result += QLatin1String("@Point(");
- result += QString::number(p.x());
- result += QLatin1Char(' ');
- result += QString::number(p.y());
- result += QLatin1Char(')');
+ result = QString::asprintf("@Point(%d %d)", p.x(), p.y());
break;
}
#endif // !QT_NO_GEOM_VARIANT
@@ -474,9 +456,9 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
s << v;
}
- result = QLatin1String(typeSpec);
- result += QString::fromLatin1(a.constData(), a.size());
- result += QLatin1Char(')');
+ result = QLatin1String(typeSpec)
+ + QLatin1String(a.constData(), a.size())
+ + QLatin1Char(')');
#else
Q_ASSERT(!"QSettings: Cannot save custom types without QDataStream support");
#endif
@@ -647,8 +629,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result,
&& ((ch >= '0' && ch <= '9')
|| (ch >= 'a' && ch <= 'f')
|| (ch >= 'A' && ch <= 'F'))) {
- result += "\\x";
- result += QByteArray::number(ch, 16);
+ result += "\\x" + QByteArray::number(ch, 16);
continue;
}
@@ -687,8 +668,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result,
break;
default:
if (ch <= 0x1F || (ch >= 0x7F && !useCodec)) {
- result += "\\x";
- result += QByteArray::number(ch, 16);
+ result += "\\x" + QByteArray::number(ch, 16);
escapeNextIfDigit = true;
#ifndef QT_NO_TEXTCODEC
} else if (useCodec) {
@@ -1038,10 +1018,33 @@ static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope)
return int((uint(format) << 1) | uint(scope == QSettings::SystemScope));
}
+#ifndef Q_OS_WIN
+static QString make_user_path()
+{
+ static Q_CONSTEXPR QChar sep = QLatin1Char('/');
+#ifndef QSETTINGS_USE_QSTANDARDPATHS
+ // Non XDG platforms (OS X, iOS, Android...) have used this code path erroneously
+ // for some time now. Moving away from that would require migrating existing settings.
+ QByteArray env = qgetenv("XDG_CONFIG_HOME");
+ if (env.isEmpty()) {
+ return QDir::homePath() + QLatin1String("/.config/");
+ } else if (env.startsWith('/')) {
+ return QFile::decodeName(env) + sep;
+ } else {
+ return QDir::homePath() + sep + QFile::decodeName(env) + sep;
+ }
+#else
+ // When using a proper XDG platform, use QStandardPaths rather than the above hand-written code;
+ // it makes the use of test mode from unit tests possible.
+ // Ideally all platforms should use this, but see above for the migration issue.
+ return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + sep;
+#endif
+}
+#endif // !Q_OS_WIN
+
static void initDefaultPaths(QMutexLocker *locker)
{
PathHash *pathHash = pathHashFunc();
- QString systemPath;
locker->unlock();
@@ -1050,8 +1053,7 @@ static void initDefaultPaths(QMutexLocker *locker)
avoid a dead-lock, we can't hold the global mutex while
calling it.
*/
- systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath);
- systemPath += QLatin1Char('/');
+ QString systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath) + QLatin1Char('/');
locker->relock();
if (pathHash->isEmpty()) {
@@ -1067,38 +1069,14 @@ static void initDefaultPaths(QMutexLocker *locker)
pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope),
windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator());
#else
-
-#ifndef QSETTINGS_USE_QSTANDARDPATHS
- // Non XDG platforms (OS X, iOS, Android...) have used this code path erroneously
- // for some time now. Moving away from that would require migrating existing settings.
- QString userPath;
- QByteArray env = qgetenv("XDG_CONFIG_HOME");
- if (env.isEmpty()) {
- userPath = QDir::homePath();
- userPath += QLatin1Char('/');
- userPath += QLatin1String(".config");
- } else if (env.startsWith('/')) {
- userPath = QFile::decodeName(env);
- } else {
- userPath = QDir::homePath();
- userPath += QLatin1Char('/');
- userPath += QFile::decodeName(env);
- }
-#else
- // When using a proper XDG platform, use QStandardPaths rather than the above hand-written code;
- // it makes the use of test mode from unit tests possible.
- // Ideally all platforms should use this, but see above for the migration issue.
- QString userPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
-#endif
- userPath += QLatin1Char('/');
-
+ const QString userPath = make_user_path();
pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath);
pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), systemPath);
#ifndef Q_OS_MAC
pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::UserScope), userPath);
pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::SystemScope), systemPath);
#endif
-#endif
+#endif // Q_OS_WIN
}
}
@@ -3486,8 +3464,7 @@ QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc r
return QSettings::InvalidFormat;
QConfFileCustomFormat info;
- info.extension = QLatin1Char('.');
- info.extension += extension;
+ info.extension = QLatin1Char('.') + extension;
info.readFunc = readFunc;
info.writeFunc = writeFunc;
info.caseSensitivity = caseSensitivity;
diff --git a/src/corelib/io/qsettings_winrt.cpp b/src/corelib/io/qsettings_winrt.cpp
index 0a87e7ce66..708287ce5e 100644
--- a/src/corelib/io/qsettings_winrt.cpp
+++ b/src/corelib/io/qsettings_winrt.cpp
@@ -92,7 +92,7 @@ static IApplicationDataContainer *subContainer(IApplicationDataContainer *parent
if (FAILED(hr))
return 0;
- while (SUCCEEDED(S_OK) && current) {
+ while (SUCCEEDED(hr) && current) {
ComPtr<ContainerItem> item;
hr = iterator->get_Current(&item);
if (FAILED(hr))
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 0daf041954..ae5c42ffd1 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com>
+** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -153,29 +154,41 @@ static bool isParentOf(const String &parent, const QString &dirName)
parent.size() == 1);
}
-static bool isPseudoFs(const QStorageIterator &it)
-{
+static bool shouldIncludeFs(const QStorageIterator &it)
+{
+ /*
+ * This function implements a heuristic algorithm to determine whether a
+ * given mount should be reported to the user. Our objective is to list
+ * only entries that the end-user would find useful.
+ *
+ * We therefore ignore:
+ * - mounted in /dev, /proc, /sys: special mounts
+ * (this will catch /sys/fs/cgroup, /proc/sys/fs/binfmt_misc, /dev/pts,
+ * some of which are tmpfs on Linux)
+ * - mounted in /var/run or /var/lock: most likely pseudofs
+ * (on earlier systemd versions, /var/run was a bind-mount of /run, so
+ * everything would be unnecessarily duplicated)
+ * - filesystem type is "rootfs": artifact of the root-pivot on some Linux
+ * initrd
+ * - if the filesystem total size is zero, it's a pseudo-fs (not checked here).
+ */
+
QString mountDir = it.rootPath();
if (isParentOf(QLatin1String("/dev"), mountDir)
|| isParentOf(QLatin1String("/proc"), mountDir)
|| isParentOf(QLatin1String("/sys"), mountDir)
|| isParentOf(QLatin1String("/var/run"), mountDir)
|| isParentOf(QLatin1String("/var/lock"), mountDir)) {
- return true;
+ return false;
}
- QByteArray type = it.fileSystemType();
- if (type == "tmpfs")
+#ifdef Q_OS_LINUX
+ if (it.fileSystemType() == "rootfs")
return false;
-#if defined(Q_OS_LINUX)
- if (type == "rootfs" || type == "rpc_pipefs")
- return true;
#endif
- if (!it.device().startsWith('/'))
- return true;
-
- return false;
+ // size checking in mountedVolumes()
+ return true;
}
#if defined(Q_OS_BSD4)
@@ -557,11 +570,14 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes()
QList<QStorageInfo> volumes;
while (it.next()) {
- if (isPseudoFs(it))
+ if (!shouldIncludeFs(it))
continue;
const QString mountDir = it.rootPath();
- volumes.append(QStorageInfo(mountDir));
+ QStorageInfo info(mountDir);
+ if (info.bytesTotal() == 0)
+ continue;
+ volumes.append(info);
}
return volumes;
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index e20a98fbf1..71a0228eeb 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -816,7 +816,7 @@ static const ushort * const fragmentInUrl = userNameInUrl + 6;
static inline void parseDecodedComponent(QString &data)
{
- data.replace(QLatin1Char('%'), QStringLiteral("%25"));
+ data.replace(QLatin1Char('%'), QLatin1String("%25"));
}
static inline QString
@@ -981,10 +981,12 @@ inline bool QUrlPrivate::setScheme(const QString &value, int len, bool doSetErro
needsLowercasing = i;
continue;
}
- if (p[i] >= '0' && p[i] <= '9' && i > 0)
- continue;
- if (p[i] == '+' || p[i] == '-' || p[i] == '.')
- continue;
+ if (i) {
+ if (p[i] >= '0' && p[i] <= '9')
+ continue;
+ if (p[i] == '+' || p[i] == '-' || p[i] == '.')
+ continue;
+ }
// found something else
// don't call setError needlessly:
@@ -1472,7 +1474,7 @@ QString QUrlPrivate::toLocalFile(QUrl::FormattingOptions options) const
// magic for shared drive on windows
if (!host.isEmpty()) {
- tmp = QStringLiteral("//") + host;
+ tmp = QLatin1String("//") + host;
#ifdef Q_OS_WIN // QTBUG-42346, WebDAV is visible as local file on Windows only.
if (scheme == webDavScheme())
tmp += webDavSslTag();
diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp
index 11b2280cd1..16bb924b17 100644
--- a/src/corelib/io/qurlidna.cpp
+++ b/src/corelib/io/qurlidna.cpp
@@ -2269,7 +2269,7 @@ Q_AUTOTEST_EXPORT void qt_punycodeEncoder(const QChar *s, int ucLength, QString
}
// prepend ACE prefix
- output->insert(outLen, QStringLiteral("xn--"));
+ output->insert(outLen, QLatin1String("xn--"));
return;
}
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index ee9aa49016..86fd63ead4 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -359,16 +359,14 @@ QByteArray QJsonDocument::toJson(JsonFormat format) const
#endif
/*!
- Parses a UTF-8 encoded JSON document and creates a QJsonDocument
+ Parses \a json as a UTF-8 encoded JSON document, and creates a QJsonDocument
from it.
- \a json contains the json document to be parsed.
+ Returns a valid (non-null) QJsonDocument if the parsing succeeds. If it fails,
+ the returned document will be null, and the optional \a error variable will contain
+ further details about the error.
- The optional \a error variable can be used to pass in a QJsonParseError data
- structure that will contain information about possible errors encountered during
- parsing.
-
- \sa toJson(), QJsonParseError
+ \sa toJson(), QJsonParseError, isNull()
*/
QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error)
{
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index 7ea7e90d94..c393609188 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -80,6 +80,10 @@
#include <errno.h>
#include <fcntl.h>
+#if !defined(QT_POSIX_IPC) && !defined(QT_NO_SHAREDMEMORY) && !defined(Q_OS_ANDROID)
+# include <sys/ipc.h>
+#endif
+
#if defined(Q_OS_VXWORKS)
# include <ioLib.h>
#endif
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index e960d355e1..e4b819d9d2 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -188,8 +188,10 @@ int QEventLoop::exec(ProcessEventsFlags flags)
{
if (exceptionCaught) {
qWarning("Qt has caught an exception thrown from an event handler. Throwing\n"
- "exceptions from an event handler is not supported in Qt. You must\n"
- "reimplement QApplication::notify() and catch all exceptions there.\n");
+ "exceptions from an event handler is not supported in Qt.\n"
+ "You must not let any exception whatsoever propagate through Qt code.\n"
+ "If that is not possible, in Qt 5 you must at least reimplement\n"
+ "QCoreApplication::notify() and catch all exceptions there.\n");
}
locker.relock();
QEventLoop *eventLoop = d->threadData->eventLoops.pop();
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index f5b879aea8..633fcfda91 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -1353,7 +1353,7 @@ static inline QByteArray findMethodCandidates(const QMetaObject *metaObject, con
for (int i = 0; i < metaObject->methodCount(); ++i) {
const QMetaMethod method = metaObject->method(i);
if (method.name() == memberByteArray)
- candidateMessage.append(" " + method.methodSignature() + '\n');
+ candidateMessage += " " + method.methodSignature() + '\n';
}
if (!candidateMessage.isEmpty()) {
candidateMessage.prepend("\nCandidates are:\n");
diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp
index 5665bf74f6..6302a3a515 100644
--- a/src/corelib/thread/qreadwritelock.cpp
+++ b/src/corelib/thread/qreadwritelock.cpp
@@ -244,6 +244,9 @@ bool QReadWriteLock::tryLockForRead(int timeout)
}
if (d == dummyLockedForWrite) {
+ if (!timeout)
+ return false;
+
// locked for write, assign a d_ptr and wait.
auto val = QReadWriteLockPrivate::allocate();
val->writerCount = 1;
@@ -345,6 +348,9 @@ bool QReadWriteLock::tryLockForWrite(int timeout)
}
if (isUncontendedLocked(d)) {
+ if (!timeout)
+ return false;
+
// locked for either read or write, assign a d_ptr and wait.
auto val = QReadWriteLockPrivate::allocate();
if (d == dummyLockedForWrite)
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index d6b90efb33..ee5ee5c362 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -3513,7 +3513,7 @@ qint64 QDateTime::toMSecsSinceEpoch() const
case Qt::TimeZone:
#ifdef QT_BOOTSTRAPPED
- break;
+ return 0;
#else
return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone);
#endif
@@ -3771,7 +3771,7 @@ QString QDateTime::toString(Qt::DateFormat format) const
.arg(tm.toString(Qt::TextDate))
.arg(dt.year());
if (timeSpec() != Qt::LocalTime) {
- buf += QStringLiteral(" GMT");
+ buf += QLatin1String(" GMT");
if (getSpec(d) == Qt::OffsetFromUTC)
buf += toOffsetString(Qt::TextDate, offsetFromUtc());
}
@@ -5019,7 +5019,12 @@ QDataStream &operator>>(QDataStream &in, QDate &date)
QDataStream &operator<<(QDataStream &out, const QTime &time)
{
- return out << quint32(time.mds);
+ if (out.version() >= QDataStream::Qt_4_0) {
+ return out << quint32(time.mds);
+ } else {
+ // Qt3 had no support for reading -1, QTime() was valid and serialized as 0
+ return out << quint32(time.isNull() ? 0 : time.mds);
+ }
}
/*!
@@ -5034,7 +5039,12 @@ QDataStream &operator>>(QDataStream &in, QTime &time)
{
quint32 ds;
in >> ds;
- time.mds = int(ds);
+ if (in.version() >= QDataStream::Qt_4_0) {
+ time.mds = int(ds);
+ } else {
+ // Qt3 would write 0 for a null time
+ time.mds = (ds == 0) ? QTime::NullTime : int(ds);
+ }
return in;
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 32f12bd092..a8e924b62d 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1786,17 +1786,12 @@ void QString::reallocData(uint alloc, bool grow)
}
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void QString::expand(int i)
{
- int sz = d->size;
- resize(qMax(i + 1, sz));
- if (d->size - 1 > sz) {
- ushort *n = d->data() + d->size - 1;
- ushort *e = d->data() + sz;
- while (n != e)
- * --n = ' ';
- }
+ resize(qMax(i + 1, d->size), QLatin1Char(' '));
}
+#endif
/*! \fn void QString::clear()
@@ -1982,7 +1977,10 @@ QString &QString::insert(int i, QLatin1String str)
return *this;
int len = str.size();
- expand(qMax(d->size, i) + len - 1);
+ if (Q_UNLIKELY(i > d->size))
+ resize(i + len, QLatin1Char(' '));
+ else
+ resize(d->size + len);
::memmove(d->data() + i + len, d->data() + i, (d->size - i - len) * sizeof(QChar));
qt_from_latin1(d->data() + i, s, uint(len));
@@ -2012,7 +2010,10 @@ QString& QString::insert(int i, const QChar *unicode, int size)
return *this;
}
- expand(qMax(d->size, i) + size - 1);
+ if (Q_UNLIKELY(i > d->size))
+ resize(i + size, QLatin1Char(' '));
+ else
+ resize(d->size + size);
::memmove(d->data() + i + size, d->data() + i, (d->size - i - size) * sizeof(QChar));
memcpy(d->data() + i, s, size * sizeof(QChar));
@@ -2032,7 +2033,10 @@ QString& QString::insert(int i, QChar ch)
i += d->size;
if (i < 0)
return *this;
- expand(qMax(i, d->size));
+ if (Q_UNLIKELY(i > d->size))
+ resize(i + 1, QLatin1Char(' '));
+ else
+ resize(d->size + 1);
::memmove(d->data() + i + 1, d->data() + i, (d->size - i - 1) * sizeof(QChar));
d->data()[i] = ch.unicode();
return *this;
@@ -2404,26 +2408,40 @@ QString &QString::replace(const QString &before, const QString &after, Qt::CaseS
return replace(before.constData(), before.size(), after.constData(), after.size(), cs);
}
+namespace { // helpers for replace and its helper:
+QChar *textCopy(const QChar *start, int len)
+{
+ const size_t size = len * sizeof(QChar);
+ QChar *const copy = static_cast<QChar *>(::malloc(size));
+ Q_CHECK_PTR(copy);
+ ::memcpy(copy, start, size);
+ return copy;
+}
+
+bool pointsIntoRange(const QChar *ptr, const ushort *base, int len)
+{
+ const QChar *const start = reinterpret_cast<const QChar *>(base);
+ return start <= ptr && ptr < start + len;
+}
+} // end namespace
+
/*!
\internal
*/
void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen)
{
- // copy *after in case it lies inside our own d->data() area
- // (which we could possibly invalidate via a realloc or corrupt via memcpy operations.)
- QChar *afterBuffer = const_cast<QChar *>(after);
- if (after >= reinterpret_cast<QChar *>(d->data()) && after < reinterpret_cast<QChar *>(d->data()) + d->size) {
- afterBuffer = static_cast<QChar *>(::malloc(alen*sizeof(QChar)));
- Q_CHECK_PTR(afterBuffer);
- ::memcpy(afterBuffer, after, alen*sizeof(QChar));
- }
+ // Copy after if it lies inside our own d->data() area (which we could
+ // possibly invalidate via a realloc or modify by replacement).
+ QChar *afterBuffer = 0;
+ if (pointsIntoRange(after, d->data(), d->size)) // Use copy in place of vulnerable original:
+ after = afterBuffer = textCopy(after, alen);
QT_TRY {
if (blen == alen) {
// replace in place
detach();
for (int i = 0; i < nIndices; ++i)
- memcpy(d->data() + indices[i], afterBuffer, alen * sizeof(QChar));
+ memcpy(d->data() + indices[i], after, alen * sizeof(QChar));
} else if (alen < blen) {
// replace from front
detach();
@@ -2439,7 +2457,7 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar
to += msize;
}
if (alen) {
- memcpy(d->data() + to, afterBuffer, alen*sizeof(QChar));
+ memcpy(d->data() + to, after, alen * sizeof(QChar));
to += alen;
}
movestart = indices[i] + blen;
@@ -2462,17 +2480,15 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar
int moveto = insertstart + alen;
memmove(d->data() + moveto, d->data() + movestart,
(moveend - movestart)*sizeof(QChar));
- memcpy(d->data() + insertstart, afterBuffer, alen*sizeof(QChar));
+ memcpy(d->data() + insertstart, after, alen * sizeof(QChar));
moveend = movestart-blen;
}
}
} QT_CATCH(const std::bad_alloc &) {
- if (afterBuffer != after)
- ::free(afterBuffer);
+ ::free(afterBuffer);
QT_RETHROW;
}
- if (afterBuffer != after)
- ::free(afterBuffer);
+ ::free(afterBuffer);
}
/*!
@@ -2501,31 +2517,48 @@ QString &QString::replace(const QChar *before, int blen,
return *this;
QStringMatcher matcher(before, blen, cs);
+ QChar *beforeBuffer = 0, *afterBuffer = 0;
int index = 0;
while (1) {
uint indices[1024];
uint pos = 0;
- while (pos < 1023) {
+ while (pos < 1024) {
index = matcher.indexIn(*this, index);
if (index == -1)
break;
indices[pos++] = index;
- index += blen;
- // avoid infinite loop
- if (!blen)
+ if (blen) // Step over before:
+ index += blen;
+ else // Only count one instance of empty between any two characters:
index++;
}
- if (!pos)
+ if (!pos) // Nothing to replace
break;
+ if (Q_UNLIKELY(index != -1)) {
+ /*
+ We're about to change data, that before and after might point
+ into, and we'll need that data for our next batch of indices.
+ */
+ if (!afterBuffer && pointsIntoRange(after, d->data(), d->size))
+ after = afterBuffer = textCopy(after, alen);
+
+ if (!beforeBuffer && pointsIntoRange(before, d->data(), d->size)) {
+ beforeBuffer = textCopy(before, blen);
+ matcher = QStringMatcher(beforeBuffer, blen, cs);
+ }
+ }
+
replace_helper(indices, pos, blen, after, alen);
- if (index == -1)
+ if (Q_LIKELY(index == -1)) // Nothing left to replace
break;
- // index has to be adjusted in case we get back into the loop above.
+ // The call to replace_helper just moved what index points at:
index += pos*(alen-blen);
}
+ ::free(afterBuffer);
+ ::free(beforeBuffer);
return *this;
}
@@ -2556,26 +2589,26 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs
uint indices[1024];
uint pos = 0;
if (cs == Qt::CaseSensitive) {
- while (pos < 1023 && index < d->size) {
+ while (pos < 1024 && index < d->size) {
if (d->data()[index] == cc)
indices[pos++] = index;
index++;
}
} else {
- while (pos < 1023 && index < d->size) {
+ while (pos < 1024 && index < d->size) {
if (QChar::toCaseFolded(d->data()[index]) == cc)
indices[pos++] = index;
index++;
}
}
- if (!pos)
+ if (!pos) // Nothing to replace
break;
replace_helper(indices, pos, 1, after.constData(), after.d->size);
- if (index == -1)
+ if (Q_LIKELY(index == -1)) // Nothing left to replace
break;
- // index has to be adjusted in case we get back into the loop above.
+ // The call to replace_helper just moved what index points at:
index += pos*(after.d->size - 1);
}
return *this;
@@ -5001,7 +5034,7 @@ void QString::truncate(int pos)
Removes \a n characters from the end of the string.
If \a n is greater than or equal to size(), the result is an
- empty string.
+ empty string; if \a n is negative, it is equivalent to passing zero.
Example:
\snippet qstring/main.cpp 15
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index ec959b50a0..a110c129de 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -821,7 +821,9 @@ private:
friend inline bool operator> (QChar, QLatin1String) Q_DECL_NOTHROW;
void reallocData(uint alloc, bool grow = false);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void expand(int i);
+#endif
QString multiArg(int numArgs, const QString **args) const;
static int compare_helper(const QChar *data1, int length1,
const QChar *data2, int length2,
@@ -1008,7 +1010,7 @@ public:
inline operator QChar() const
{ return i < s.d->size ? s.d->data()[i] : 0; }
inline QCharRef &operator=(QChar c)
- { if (i >= s.d->size) s.expand(i); else s.detach();
+ { if (i >= s.d->size) s.resize(i + 1, QLatin1Char(' ')); else s.detach();
s.d->data()[i] = c.unicode(); return *this; }
// An operator= for each QChar cast constructors
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 8ce98cbd71..b2832b5fbe 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -82,7 +82,7 @@ struct QStringBuilderCommon
T toLower() const { return resolved().toLower(); }
protected:
- const T resolved() const { return *static_cast<const Builder*>(this); }
+ T resolved() const { return *static_cast<const Builder*>(this); }
};
template<typename Builder, typename T>
diff --git a/src/corelib/tools/qtimezoneprivate_icu.cpp b/src/corelib/tools/qtimezoneprivate_icu.cpp
index a7036808db..c088fe7694 100644
--- a/src/corelib/tools/qtimezoneprivate_icu.cpp
+++ b/src/corelib/tools/qtimezoneprivate_icu.cpp
@@ -332,7 +332,7 @@ QString QIcuTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
{
// Return standard offset format name as ICU C api doesn't support it yet
if (nameType == QTimeZone::OffsetName) {
- const Data nowData = data(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch());
+ const Data nowData = data(QDateTime::currentMSecsSinceEpoch());
// We can't use transitions reliably to find out right dst offset
// Instead use dst offset api to try get it if needed
if (timeType == QTimeZone::DaylightTime)
diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm
index 3a665c2b00..77c04ac20c 100644
--- a/src/corelib/tools/qtimezoneprivate_mac.mm
+++ b/src/corelib/tools/qtimezoneprivate_mac.mm
@@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE
// Create the system default time zone
QMacTimeZonePrivate::QMacTimeZonePrivate()
+ : m_nstz(0)
{
init(systemTimeZoneId());
}
@@ -106,7 +107,7 @@ QString QMacTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
{
// TODO Mac doesn't support OffsetName yet so use standard offset name
if (nameType == QTimeZone::OffsetName) {
- const Data nowData = data(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch());
+ const Data nowData = data(QDateTime::currentMSecsSinceEpoch());
// TODO Cheat for now, assume if has dst the offset if 1 hour
if (timeType == QTimeZone::DaylightTime && hasDaylightTime())
return isoOffsetFormat(nowData.standardTimeOffset + 3600);
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 757543281c..e95315aea8 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -758,7 +758,7 @@ void QAccessible::deleteAccessibleInterface(Id id)
*/
QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
{
- Id id = QAccessibleCache::instance()->idToInterface.key(iface);
+ Id id = QAccessibleCache::instance()->idForInterface(iface);
if (!id)
id = registerAccessibleInterface(iface);
return id;
@@ -771,7 +771,7 @@ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
*/
QAccessibleInterface *QAccessible::accessibleInterface(Id id)
{
- return QAccessibleCache::instance()->idToInterface.value(id);
+ return QAccessibleCache::instance()->interfaceForId(id);
}
diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp
index 6fbe9b5582..43c4b15cb0 100644
--- a/src/gui/accessible/qaccessiblecache.cpp
+++ b/src/gui/accessible/qaccessiblecache.cpp
@@ -83,6 +83,11 @@ QAccessibleInterface *QAccessibleCache::interfaceForId(QAccessible::Id id) const
return idToInterface.value(id);
}
+QAccessible::Id QAccessibleCache::idForInterface(QAccessibleInterface *iface) const
+{
+ return interfaceToId.value(iface);
+}
+
QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *iface) const
{
Q_ASSERT(iface);
@@ -90,7 +95,7 @@ QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *
// object might be 0
Q_ASSERT(!objectToId.contains(object));
- Q_ASSERT_X(!idToInterface.values().contains(iface), "", "Accessible interface inserted into cache twice!");
+ Q_ASSERT_X(!interfaceToId.contains(iface), "", "Accessible interface inserted into cache twice!");
QAccessible::Id id = acquireId();
QObject *obj = iface->object();
@@ -100,6 +105,7 @@ QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *
connect(obj, &QObject::destroyed, this, &QAccessibleCache::objectDestroyed);
}
idToInterface.insert(id, iface);
+ interfaceToId.insert(iface, id);
return id;
}
@@ -115,6 +121,7 @@ void QAccessibleCache::objectDestroyed(QObject* obj)
void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj)
{
QAccessibleInterface *iface = idToInterface.take(id);
+ interfaceToId.take(iface);
if (!obj)
obj = iface->object();
if (obj)
diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h
index 5f62f43b6a..f054ee9678 100644
--- a/src/gui/accessible/qaccessiblecache_p.h
+++ b/src/gui/accessible/qaccessiblecache_p.h
@@ -70,6 +70,7 @@ class Q_GUI_EXPORT QAccessibleCache :public QObject
public:
static QAccessibleCache *instance();
QAccessibleInterface *interfaceForId(QAccessible::Id id) const;
+ QAccessible::Id idForInterface(QAccessibleInterface *iface) const;
QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const;
void deleteInterface(QAccessible::Id id, QObject *obj = 0);
@@ -85,6 +86,7 @@ private:
QAccessible::Id acquireId() const;
mutable QHash<QAccessible::Id, QAccessibleInterface *> idToInterface;
+ mutable QHash<QAccessibleInterface *, QAccessible::Id> interfaceToId;
mutable QHash<QObject *, QAccessible::Id> objectToId;
#ifdef Q_OS_MAC
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 0dec4b512d..c65ac7f92d 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1227,8 +1227,8 @@ bool QIcon::hasThemeIcon(const QString &name)
/*!
\since 5.6
- Indicate that this icon is a mask image, and hence can potentially
- be modified based on where it's displayed.
+ Indicate that this icon is a mask image(boolean \a isMask), and hence can
+ potentially be modified based on where it's displayed.
\sa isMask()
*/
void QIcon::setIsMask(bool isMask)
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index 3279880601..e965045524 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -1796,11 +1796,12 @@ QStandardItem *QStandardItem::takeChild(int row, int column)
QList<QStandardItem*> QStandardItem::takeRow(int row)
{
Q_D(QStandardItem);
+ QList<QStandardItem*> items;
if ((row < 0) || (row >= rowCount()))
- return QList<QStandardItem*>();
+ return items;
if (d->model)
d->model->d_func()->rowsAboutToBeRemoved(this, row, row);
- QList<QStandardItem*> items;
+
int index = d->childIndex(row, 0); // Will return -1 if there are no columns
if (index != -1) {
int col_count = d->columnCount();
@@ -1829,13 +1830,15 @@ QList<QStandardItem*> QStandardItem::takeRow(int row)
QList<QStandardItem*> QStandardItem::takeColumn(int column)
{
Q_D(QStandardItem);
+ QList<QStandardItem*> items;
if ((column < 0) || (column >= columnCount()))
- return QList<QStandardItem*>();
+ return items;
if (d->model)
d->model->d_func()->columnsAboutToBeRemoved(this, column, column);
- QList<QStandardItem*> items;
- for (int row = d->rowCount() - 1; row >= 0; --row) {
+ const int rowCount = d->rowCount();
+ items.reserve(rowCount);
+ for (int row = rowCount - 1; row >= 0; --row) {
int index = d->childIndex(row, column);
QStandardItem *ch = d->children.at(index);
if (ch)
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 7afeadcced..416c899270 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -3355,28 +3355,6 @@ bool QGuiApplication::isSavingSession() const
return d->is_saving_session;
}
-/*!
- \since 5.2
-
- Function that can be used to sync Qt state with the Window Systems state.
-
- This function will first empty Qts events by calling QCoreApplication::processEvents(),
- then the platform plugin will sync up with the windowsystem, and finally Qts events
- will be delived by another call to QCoreApplication::processEvents();
-
- This function is timeconsuming and its use is discouraged.
-*/
-void QGuiApplication::sync()
-{
- QCoreApplication::processEvents();
- if (QGuiApplicationPrivate::platform_integration
- && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) {
- QGuiApplicationPrivate::platform_integration->sync();
- QCoreApplication::processEvents();
- QWindowSystemInterface::flushWindowSystemEvents();
- }
-}
-
void QGuiApplicationPrivate::commitData()
{
Q_Q(QGuiApplication);
@@ -3402,6 +3380,28 @@ void QGuiApplicationPrivate::saveState()
#endif //QT_NO_SESSIONMANAGER
/*!
+ \since 5.2
+
+ Function that can be used to sync Qt state with the Window Systems state.
+
+ This function will first empty Qts events by calling QCoreApplication::processEvents(),
+ then the platform plugin will sync up with the windowsystem, and finally Qts events
+ will be delived by another call to QCoreApplication::processEvents();
+
+ This function is timeconsuming and its use is discouraged.
+*/
+void QGuiApplication::sync()
+{
+ QCoreApplication::processEvents();
+ if (QGuiApplicationPrivate::platform_integration
+ && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) {
+ QGuiApplicationPrivate::platform_integration->sync();
+ QCoreApplication::processEvents();
+ QWindowSystemInterface::flushWindowSystemEvents();
+ }
+}
+
+/*!
\property QGuiApplication::layoutDirection
\brief the default layout direction for this application
@@ -3647,7 +3647,8 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
void QGuiApplicationPrivate::notifyThemeChanged()
{
- if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet)) {
+ if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet) &&
+ !QCoreApplication::testAttribute(Qt::AA_SetPalette)) {
clearPalette();
initPalette();
}
diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp
index 566d025b28..1e04a673eb 100644
--- a/src/gui/kernel/qplatformintegrationfactory.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory.cpp
@@ -86,7 +86,7 @@ QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
QCoreApplication::addLibraryPath(platformPluginPath);
list = directLoader()->keyMap().values();
if (!list.isEmpty()) {
- const QString postFix = QStringLiteral(" (from ")
+ const QString postFix = QLatin1String(" (from ")
+ QDir::toNativeSeparators(platformPluginPath)
+ QLatin1Char(')');
const QStringList::iterator end = list.end();
diff --git a/src/gui/kernel/qplatformthemefactory.cpp b/src/gui/kernel/qplatformthemefactory.cpp
index 40ba844e57..223d7344e3 100644
--- a/src/gui/kernel/qplatformthemefactory.cpp
+++ b/src/gui/kernel/qplatformthemefactory.cpp
@@ -88,7 +88,7 @@ QStringList QPlatformThemeFactory::keys(const QString &platformPluginPath)
QCoreApplication::addLibraryPath(platformPluginPath);
list += directLoader()->keyMap().values();
if (!list.isEmpty()) {
- const QString postFix = QStringLiteral(" (from ")
+ const QString postFix = QLatin1String(" (from ")
+ QDir::toNativeSeparators(platformPluginPath)
+ QLatin1Char(')');
const QStringList::iterator end = list.end();
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index bcc17457d3..3e82d5a649 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -1284,6 +1284,7 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ
const char *ver = reinterpret_cast<const char *>(funcs->glGetString(GL_VERSION));
// Blacklist GPU chipsets that have problems with their BGRA support.
+#ifndef Q_OS_IOS
const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0
&& ::strstr(ver, "1.3") != 0) ||
(qstrcmp(renderer, "Mali-T760") == 0
@@ -1291,7 +1292,9 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ
(qstrcmp(renderer, "Mali-T720") == 0
&& ::strstr(ver, "3.1") != 0) ||
qstrcmp(renderer, "PowerVR SGX 554") == 0;
-
+#else
+ const bool blackListed = true;
+#endif
const bool supports_bgra = has_bgra_ext && !blackListed;
if (supports_bgra) {
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index e89522f5af..26ed81a091 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -259,7 +259,6 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id,
newFreetype->ref.store(1);
newFreetype->xsize = 0;
newFreetype->ysize = 0;
- newFreetype->scalableBitmapScaleFactor = 1;
newFreetype->matrix.xx = 0x10000;
newFreetype->matrix.yy = 0x10000;
newFreetype->matrix.xy = 0;
@@ -335,10 +334,11 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id)
}
-void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing)
+void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing, QFixed *scalableBitmapScaleFactor)
{
*ysize = qRound(fontDef.pixelSize * 64);
*xsize = *ysize * fontDef.stretch / 100;
+ *scalableBitmapScaleFactor = 1;
*outline_drawing = false;
if (!(face->face_flags & FT_FACE_FLAG_SCALABLE)) {
@@ -376,7 +376,7 @@ void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize,
// to make sure we can select the desired bitmap strike index
if (FT_Select_Size(face, best) == 0) {
if (isScalableBitmap())
- scalableBitmapScaleFactor = QFixed::fromReal((qreal)fontDef.pixelSize / face->available_sizes[best].height);
+ *scalableBitmapScaleFactor = QFixed::fromReal((qreal)fontDef.pixelSize / face->available_sizes[best].height);
*xsize = face->available_sizes[best].x_ppem;
*ysize = face->available_sizes[best].y_ppem;
} else {
@@ -729,7 +729,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
symbol = bool(fontDef.family.contains(QLatin1String("symbol"), Qt::CaseInsensitive));
}
- freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing);
+ freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing, &scalableBitmapScaleFactor);
FT_Face face = lockFace();
@@ -1294,24 +1294,24 @@ int QFontEngineFT::synthesized() const
QFixed QFontEngineFT::ascent() const
{
QFixed v = QFixed::fromFixed(metrics.ascender);
- if (freetype->scalableBitmapScaleFactor != 1)
- v *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ v *= scalableBitmapScaleFactor;
return v;
}
QFixed QFontEngineFT::descent() const
{
QFixed v = QFixed::fromFixed(-metrics.descender);
- if (freetype->scalableBitmapScaleFactor != 1)
- v *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ v *= scalableBitmapScaleFactor;
return v;
}
QFixed QFontEngineFT::leading() const
{
QFixed v = QFixed::fromFixed(metrics.height - metrics.ascender + metrics.descender);
- if (freetype->scalableBitmapScaleFactor != 1)
- v *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ v *= scalableBitmapScaleFactor;
return v;
}
@@ -1326,7 +1326,7 @@ QFixed QFontEngineFT::xHeight() const
return answer;
}
} else {
- return QFixed(freetype->face->size->metrics.y_ppem) * freetype->scalableBitmapScaleFactor;
+ return QFixed(freetype->face->size->metrics.y_ppem) * scalableBitmapScaleFactor;
}
return QFontEngine::xHeight();
}
@@ -1352,8 +1352,8 @@ QFixed QFontEngineFT::averageCharWidth() const
qreal QFontEngineFT::maxCharWidth() const
{
QFixed max_advance = QFixed::fromFixed(metrics.max_advance);
- if (freetype->scalableBitmapScaleFactor != 1)
- max_advance *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ max_advance *= scalableBitmapScaleFactor;
return max_advance.toReal();
}
@@ -1639,7 +1639,7 @@ bool QFontEngineFT::shouldUseDesignMetrics(QFontEngine::ShaperFlags flags) const
QFixed QFontEngineFT::scaledBitmapMetrics(QFixed m) const
{
- return m * freetype->scalableBitmapScaleFactor;
+ return m * scalableBitmapScaleFactor;
}
glyph_metrics_t QFontEngineFT::scaledBitmapMetrics(const glyph_metrics_t &m) const
@@ -1677,8 +1677,8 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlag
delete g;
}
- if (freetype->scalableBitmapScaleFactor != 1)
- glyphs->advances[i] *= freetype->scalableBitmapScaleFactor;
+ if (scalableBitmapScaleFactor != 1)
+ glyphs->advances[i] *= scalableBitmapScaleFactor;
}
if (face)
unlockFace();
@@ -1981,9 +1981,9 @@ QImage QFontEngineFT::bitmapForGlyph(glyph_t g, QFixed subPixelPosition, const Q
else if (defaultFormat == GlyphFormat::Format_Mono)
img = QImage(glyph->data, glyph->width, glyph->height, QImage::Format_Mono).copy();
- if (!img.isNull() && (!t.isIdentity() || freetype->scalableBitmapScaleFactor != 1)) {
+ if (!img.isNull() && (!t.isIdentity() || scalableBitmapScaleFactor != 1)) {
QTransform trans(t);
- const qreal scaleFactor = freetype->scalableBitmapScaleFactor.toReal();
+ const qreal scaleFactor = scalableBitmapScaleFactor.toReal();
trans.scale(scaleFactor, scaleFactor);
img = img.transformed(trans, Qt::SmoothTransformation);
}
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 3f4bf84753..3cdf0cda47 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -75,7 +75,7 @@ class QFontconfigDatabase;
class QFreetypeFace
{
public:
- void computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing);
+ void computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing, QFixed *scalableBitmapScaleFactor);
QFontEngine::Properties properties() const;
bool getSfntTable(uint tag, uchar *buffer, uint *length) const;
@@ -96,7 +96,6 @@ public:
FT_Face face;
int xsize; // 26.6
int ysize; // 26.6
- QFixed scalableBitmapScaleFactor;
FT_Matrix matrix;
FT_CharMap unicode_map;
FT_CharMap symbol_map;
@@ -340,6 +339,7 @@ private:
FT_Size_Metrics metrics;
mutable bool kerning_pairs_loaded;
+ QFixed scalableBitmapScaleFactor;
};
inline uint qHash(const QFontEngineFT::GlyphAndSubPixelPosition &g)
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index a1a562c839..5727b34e86 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -428,7 +428,7 @@ QTextHtmlImporter::QTextHtmlImporter(QTextDocument *_doc, const QString &_html,
QString html = _html;
const int startFragmentPos = html.indexOf(QLatin1String("<!--StartFragment-->"));
if (startFragmentPos != -1) {
- QString qt3RichTextHeader(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
+ const QLatin1String qt3RichTextHeader("<meta name=\"qrichtext\" content=\"1\" />");
// Hack for Qt3
const bool hasQtRichtextMetaTag = html.contains(qt3RichTextHeader);
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 103a208c26..7bca50325c 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1418,16 +1418,16 @@ static bool setFloatAttribute(qreal *destination, const QString &value)
return ok;
}
-static void setWidthAttribute(QTextLength *width, QString value)
+static void setWidthAttribute(QTextLength *width, const QString &valueStr)
{
bool ok = false;
- qreal realVal = value.toDouble(&ok);
+ qreal realVal = valueStr.toDouble(&ok);
if (ok) {
*width = QTextLength(QTextLength::FixedLength, realVal);
} else {
- value = value.trimmed();
+ QStringRef value = QStringRef(&valueStr).trimmed();
if (!value.isEmpty() && value.endsWith(QLatin1Char('%'))) {
- value.chop(1);
+ value.truncate(value.size() - 1);
realVal = value.toDouble(&ok);
if (ok)
*width = QTextLength(QTextLength::PercentageLength, realVal);
@@ -1438,9 +1438,7 @@ static void setWidthAttribute(QTextLength *width, QString value)
#ifndef QT_NO_CSSPARSER
void QTextHtmlParserNode::parseStyleAttribute(const QString &value, const QTextDocument *resourceProvider)
{
- QString css = value;
- css.prepend(QLatin1String("* {"));
- css.append(QLatin1Char('}'));
+ const QString css = QLatin1String("* {") + value + QLatin1Char('}');
QCss::Parser parser(css);
QCss::StyleSheet sheet;
parser.parse(&sheet, Qt::CaseInsensitive);
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index acd18994ad..18311ed161 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -111,7 +111,7 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, con
doc->addResource(QTextDocument::ImageResource, url, pm);
}
- if (name.contains(QStringLiteral("@2x")))
+ if (name.contains(QLatin1String("@2x")))
pm.setDevicePixelRatio(sourcePixelRatio);
return pm;
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index 19b519243c..7b6f830333 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -2034,7 +2034,7 @@ int QFtp::rename(const QString &oldname, const QString &newname)
*/
int QFtp::rawCommand(const QString &command)
{
- QString cmd = command.trimmed() + QLatin1String("\r\n");
+ const QString cmd = QStringRef(&command).trimmed() + QLatin1String("\r\n");
return d_func()->addCommand(new QFtpCommand(RawCommand, QStringList(cmd)));
}
@@ -2253,8 +2253,8 @@ void QFtpPrivate::_q_startNextCommand()
// Proxy support, replace the Login argument in place, then fall
// through.
if (c->command == QFtp::Login && !proxyHost.isEmpty()) {
- QString loginString = c->rawCmds.constFirst().trimmed();
- loginString += QLatin1Char('@') + host;
+ QString loginString;
+ loginString += QStringRef(&c->rawCmds.constFirst()).trimmed() + QLatin1Char('@') + host;
if (port && port != 21)
loginString += QLatin1Char(':') + QString::number(port);
loginString += QLatin1String("\r\n");
diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp
index 153a33f782..d242bdba82 100644
--- a/src/network/access/qnetworkaccessftpbackend.cpp
+++ b/src/network/access/qnetworkaccessftpbackend.cpp
@@ -306,8 +306,6 @@ void QNetworkAccessFtpBackend::ftpDone()
state = CheckingFeatures;
if (operation() == QNetworkAccessManager::GetOperation) {
// send help command to find out if server supports "SIZE" and "MDTM"
- QString command = url().path();
- command.prepend(QLatin1String("%1 "));
helpId = ftp->rawCommand(QLatin1String("HELP")); // get supported commands
} else {
ftpDone();
@@ -316,14 +314,13 @@ void QNetworkAccessFtpBackend::ftpDone()
state = Statting;
if (operation() == QNetworkAccessManager::GetOperation) {
// logged in successfully, send the stat requests (if supported)
- QString command = url().path();
- command.prepend(QLatin1String("%1 "));
+ const QString path = url().path();
if (supportsSize) {
ftp->rawCommand(QLatin1String("TYPE I"));
- sizeId = ftp->rawCommand(command.arg(QLatin1String("SIZE"))); // get size
+ sizeId = ftp->rawCommand(QLatin1String("SIZE ") + path); // get size
}
if (supportsMdtm)
- mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM"))); // get modified time
+ mdtmId = ftp->rawCommand(QLatin1String("MDTM ") + path); // get modified time
if (!supportsSize && !supportsMdtm)
ftpDone(); // no commands sent, move to the next state
} else {
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
index 469879c78b..107addae58 100644
--- a/src/network/kernel/qauthenticator.cpp
+++ b/src/network/kernel/qauthenticator.cpp
@@ -1277,7 +1277,7 @@ static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx,
time = QDateTime::currentSecsSinceEpoch() + 11644473600;
// represented as 100 nano seconds
- time = Q_UINT64_C(time * 10000000);
+ time = time * Q_UINT64_C(10000000);
ds << time;
}
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 7ef9d7f26b..fcb8a60c8f 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -902,10 +902,7 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
if (cmsgptr->cmsg_level == IPPROTO_IP && cmsgptr->cmsg_type == IP_RECVIF
&& cmsgptr->cmsg_len >= CMSG_LEN(sizeof(sockaddr_dl))) {
sockaddr_dl *sdl = reinterpret_cast<sockaddr_dl *>(CMSG_DATA(cmsgptr));
-# if defined(Q_OS_OPENBSD)
-# define LLINDEX(s) ((s)->sdl_index)
-# endif
- header->ifindex = LLINDEX(sdl);
+ header->ifindex = sdl->sdl_index;
}
# endif
#endif
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 580b0fbdde..2371dd7212 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -55,7 +55,8 @@
QSslSocket establishes a secure, encrypted TCP connection you can
use for transmitting encrypted data. It can operate in both client
and server mode, and it supports modern SSL protocols, including
- SSLv3 and TLSv1_0. By default, QSslSocket uses TLSv1_0, but you can
+ SSL 3 and TLS 1.2. By default, QSslSocket uses only SSL protocols
+ which are considered to be secure (QSsl::SecureProtocols), but you can
change the SSL protocol by calling setProtocol() as long as you do
it before the handshake has started.
@@ -2394,6 +2395,13 @@ void QSslSocketPrivate::_q_disconnectedSlot()
#endif
disconnected();
emit q->disconnected();
+
+ q->setLocalPort(0);
+ q->setLocalAddress(QHostAddress());
+ q->setPeerPort(0);
+ q->setPeerAddress(QHostAddress());
+ q->setPeerName(QString());
+ cachedSocketDescriptor = -1;
}
/*!
diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp
index 194acbeacc..438ea9a38e 100644
--- a/src/network/ssl/qsslsocket_mac.cpp
+++ b/src/network/ssl/qsslsocket_mac.cpp
@@ -321,7 +321,7 @@ long QSslSocketPrivate::sslLibraryVersionNumber()
QString QSslSocketPrivate::sslLibraryVersionString()
{
- return QStringLiteral("Secure Transport, ") + QSysInfo::prettyProductName();
+ return QLatin1String("Secure Transport, ") + QSysInfo::prettyProductName();
}
long QSslSocketPrivate::sslLibraryBuildVersionNumber()
@@ -436,7 +436,7 @@ void QSslSocketBackendPrivate::startClientEncryption()
// Error description/code were set, 'error' emitted
// by initSslContext, but OpenSSL socket also sets error
// emits a signal twice, so ...
- setErrorAndEmit(QAbstractSocket::SslInternalError, "Unable to init SSL Context");
+ setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("Unable to init SSL Context"));
return;
}
@@ -449,7 +449,7 @@ void QSslSocketBackendPrivate::startServerEncryption()
// Error description/code were set, 'error' emitted
// by initSslContext, but OpenSSL socket also sets error
// emits a signal twice, so ...
- setErrorAndEmit(QAbstractSocket::SslInternalError, "Unable to init SSL Context");
+ setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("Unable to init SSL Context"));
return;
}
@@ -470,7 +470,7 @@ void QSslSocketBackendPrivate::transmit()
if (connectionEncrypted && !writeBuffer.isEmpty()) {
qint64 totalBytesWritten = 0;
- while (writeBuffer.nextDataBlockSize() > 0) {
+ while (writeBuffer.nextDataBlockSize() > 0 && context) {
const size_t nextDataBlockSize = writeBuffer.nextDataBlockSize();
size_t writtenBytes = 0;
const OSStatus err = SSLWrite(context, writeBuffer.readPointer(), nextDataBlockSize, &writtenBytes);
@@ -505,7 +505,7 @@ void QSslSocketBackendPrivate::transmit()
if (connectionEncrypted) {
QVarLengthArray<char, 4096> data;
- while (true) {
+ while (context) {
size_t readBytes = 0;
data.resize(4096);
const OSStatus err = SSLRead(context, data.data(), data.size(), &readBytes);
@@ -780,7 +780,7 @@ bool QSslSocketBackendPrivate::initSslContext()
context.reset(qt_createSecureTransportContext(mode));
if (!context) {
- setErrorAndEmit(QAbstractSocket::SslInternalError, "SSLCreateContext failed");
+ setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("SSLCreateContext failed"));
return false;
}
@@ -808,7 +808,7 @@ bool QSslSocketBackendPrivate::initSslContext()
if (!setSessionProtocol()) {
destroySslContext();
- setErrorAndEmit(QAbstractSocket::SslInternalError, "Failed to set protocol version");
+ setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("Failed to set protocol version"));
return false;
}
@@ -1121,7 +1121,10 @@ bool QSslSocketBackendPrivate::verifyPeerTrust()
// report errors
if (!errors.isEmpty() && !canIgnoreVerify) {
sslErrors = errors;
- if (!checkSslErrors())
+ // checkSslErrors unconditionally emits sslErrors:
+ // a user's slot can abort/close/disconnect on this
+ // signal, so we also test the socket's state:
+ if (!checkSslErrors() || q->state() != QAbstractSocket::ConnectedState)
return false;
} else {
sslErrors.clear();
@@ -1219,8 +1222,7 @@ bool QSslSocketBackendPrivate::startHandshake()
// check protocol version ourselves, as Secure Transport does not enforce
// the requested min / max versions.
if (!verifySessionProtocol()) {
- setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError,
- "Protocol version mismatch");
+ setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError, QStringLiteral("Protocol version mismatch"));
plainSocket->disconnectFromHost();
return false;
}
diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm
index 02d1295b0f..d48da8da15 100644
--- a/src/platformsupport/clipboard/qmacmime.mm
+++ b/src/platformsupport/clipboard/qmacmime.mm
@@ -412,9 +412,7 @@ QVariant QMacPasteboardMimeUnicodeText::convertToMime(const QString &mimetype, Q
// I can only handle two types (system and unicode) so deal with them that way
QVariant ret;
if (flavor == QLatin1String("public.utf8-plain-text")) {
- ret = QString(QCFString(CFStringCreateWithBytes(kCFAllocatorDefault,
- reinterpret_cast<const UInt8 *>(firstData.constData()),
- firstData.size(), CFStringGetSystemEncoding(), false)));
+ ret = QString::fromUtf8(firstData);
} else if (flavor == QLatin1String("public.utf16-plain-text")) {
ret = QString(reinterpret_cast<const QChar *>(firstData.constData()),
firstData.size() / sizeof(QChar));
diff --git a/src/platformsupport/dbustray/qdbustrayicon.cpp b/src/platformsupport/dbustray/qdbustrayicon.cpp
index 724992f348..da368bf9b7 100644
--- a/src/platformsupport/dbustray/qdbustrayicon.cpp
+++ b/src/platformsupport/dbustray/qdbustrayicon.cpp
@@ -66,7 +66,7 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
static const QString KDEItemFormat = QStringLiteral("org.kde.StatusNotifierItem-%1-%2");
static const QString KDEWatcherService = QStringLiteral("org.kde.StatusNotifierWatcher");
-static const QString TempFileTemplate = QDir::tempPath() + QStringLiteral("/qt-trayicon-XXXXXX.png");
+static const QString TempFileTemplate = QDir::tempPath() + QLatin1String("/qt-trayicon-XXXXXX.png");
static const QString XdgNotificationService = QStringLiteral("org.freedesktop.Notifications");
static const QString XdgNotificationPath = QStringLiteral("/org/freedesktop/Notifications");
static const QString DefaultAction = QStringLiteral("default");
@@ -156,7 +156,7 @@ QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon)
QDBusConnection session = QDBusConnection::sessionBus();
uint pid = session.interface()->servicePid(KDEWatcherService).value();
QString processName = QLockFilePrivate::processNameByPid(pid);
- necessary = processName.endsWith(QStringLiteral("indicator-application-service"));
+ necessary = processName.endsWith(QLatin1String("indicator-application-service"));
necessity_checked = true;
}
if (!necessary)
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index 1a17f75488..5fec53d1ed 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -585,8 +585,7 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
fallbackList.append(familyNameFromPostScriptName(item));
}
- if (QCoreTextFontEngine::supportsColorGlyphs())
- fallbackList.append(QLatin1String("Apple Color Emoji"));
+ fallbackList.append(QLatin1String("Apple Color Emoji"));
// Since we are only returning a list of default fonts for the current language, we do not
// cover all unicode completely. This was especially an issue for some of the common script
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index 251ba2b9ac..a0047c0b7d 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -224,11 +224,9 @@ void QCoreTextFontEngine::init()
synthesisFlags = 0;
CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ctfont);
-#if defined(QT_PLATFORM_UIKIT) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- if (supportsColorGlyphs() && (traits & kCTFontColorGlyphsTrait))
+ if (traits & kCTFontColorGlyphsTrait)
glyphFormat = QFontEngine::Format_ARGB;
else
-#endif
glyphFormat = defaultGlyphFormat;
if (traits & kCTFontItalicTrait)
@@ -659,9 +657,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y);
CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1);
}
- }
-#if defined(QT_PLATFORM_UIKIT) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- else if (supportsColorGlyphs()) {
+ } else {
// CGContextSetTextMatrix does not work with color glyphs, so we use
// the CTM instead. This means we must translate the CTM as well, to
// set the glyph position, instead of using CGContextSetTextPosition.
@@ -672,7 +668,6 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
// glyphs in the Apple Color Emoji font, so we use CTFontDrawGlyphs instead.
CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx);
}
-#endif
CGContextRelease(ctx);
CGColorSpaceRelease(colorspace);
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
index 27289239c6..b7c9edc528 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
@@ -116,21 +116,6 @@ public:
QFontEngine::Properties properties() const Q_DECL_OVERRIDE;
- static bool supportsColorGlyphs()
- {
-#if defined(QT_PLATFORM_UIKIT)
- return true;
-#elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
- return &CTFontDrawGlyphs;
- #else
- return true;
- #endif
-#else
- return false;
-#endif
- }
-
static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length);
static QFont::Weight qtWeightFromCFWeight(float value);
diff --git a/src/platformsupport/input/tslib/qtslib.cpp b/src/platformsupport/input/tslib/qtslib.cpp
index ed21cc1cef..75ac3c50e0 100644
--- a/src/platformsupport/input/tslib/qtslib.cpp
+++ b/src/platformsupport/input/tslib/qtslib.cpp
@@ -64,7 +64,7 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key,
QByteArray device = qgetenv("TSLIB_TSDEVICE");
- if (specification.startsWith(QStringLiteral("/dev/")))
+ if (specification.startsWith(QLatin1String("/dev/")))
device = specification.toLocal8Bit();
if (device.isEmpty())
diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
index 727da3132a..5242f00193 100644
--- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
@@ -101,7 +101,7 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
if (desktop == QByteArray("KDE")) {
// Konqueror launcher
if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
- browser->append(QStringLiteral(" exec"));
+ browser->append(QLatin1String(" exec"));
return true;
}
} else if (desktop == QByteArray("GNOME")) {
@@ -121,7 +121,7 @@ static inline bool launch(const QString &launcher, const QUrl &url)
if (debug)
qDebug("Launching %s", qPrintable(command));
#if defined(QT_NO_PROCESS)
- const bool ok = ::system(qPrintable(command + QStringLiteral(" &")));
+ const bool ok = ::system(qPrintable(command + QLatin1String(" &")));
#else
const bool ok = QProcess::startDetached(command);
#endif
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index 5e5c931c2c..9abcd04063 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -170,7 +170,7 @@ QStringList QGenericUnixTheme::xdgIconThemePaths()
{
QStringList paths;
// Add home directory first in search path
- const QFileInfo homeIconDir(QDir::homePath() + QStringLiteral("/.icons"));
+ const QFileInfo homeIconDir(QDir::homePath() + QLatin1String("/.icons"));
if (homeIconDir.isDir())
paths.prepend(homeIconDir.absoluteFilePath());
@@ -247,8 +247,8 @@ public:
static QString kdeGlobals(const QString &kdeDir, int kdeVersion)
{
if (kdeVersion > 4)
- return kdeDir + QStringLiteral("/kdeglobals");
- return kdeDir + QStringLiteral("/share/config/kdeglobals");
+ return kdeDir + QLatin1String("/kdeglobals");
+ return kdeDir + QLatin1String("/share/config/kdeglobals");
}
void refresh();
@@ -559,22 +559,22 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
if (!kdeDirsVar.isEmpty())
kdeDirs += kdeDirsVar.split(QLatin1Char(':'), QString::SkipEmptyParts);
- const QString kdeVersionHomePath = QDir::homePath() + QStringLiteral("/.kde") + QLatin1String(kdeVersionBA);
+ const QString kdeVersionHomePath = QDir::homePath() + QLatin1String("/.kde") + QLatin1String(kdeVersionBA);
if (QFileInfo(kdeVersionHomePath).isDir())
kdeDirs += kdeVersionHomePath;
- const QString kdeHomePath = QDir::homePath() + QStringLiteral("/.kde");
+ const QString kdeHomePath = QDir::homePath() + QLatin1String("/.kde");
if (QFileInfo(kdeHomePath).isDir())
kdeDirs += kdeHomePath;
- const QString kdeRcPath = QStringLiteral("/etc/kde") + QLatin1String(kdeVersionBA) + QStringLiteral("rc");
+ const QString kdeRcPath = QLatin1String("/etc/kde") + QLatin1String(kdeVersionBA) + QLatin1String("rc");
if (QFileInfo(kdeRcPath).isReadable()) {
QSettings kdeSettings(kdeRcPath, QSettings::IniFormat);
kdeSettings.beginGroup(QStringLiteral("Directories-default"));
kdeDirs += kdeSettings.value(QStringLiteral("prefixes")).toStringList();
}
- const QString kdeVersionPrefix = QStringLiteral("/etc/kde") + QLatin1String(kdeVersionBA);
+ const QString kdeVersionPrefix = QLatin1String("/etc/kde") + QLatin1String(kdeVersionBA);
if (QFileInfo(kdeVersionPrefix).isDir())
kdeDirs += kdeVersionPrefix;
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h
index e773db9b20..0e774d50c3 100644
--- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h
+++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h
@@ -218,6 +218,7 @@ protected:
private:
QVariantMap properties();
QVariantMap propertiesMap;
+private Q_SLOTS:
void scanReply(QDBusPendingCallWatcher *call);
};
diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
index 52d14e5324..d507751d5e 100644
--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
@@ -278,7 +278,7 @@ QString TableGenerator::findComposeFile()
// check if user’s home directory has a file named .XCompose
if (cleanState()) {
- QString path = qgetenv("HOME") + QStringLiteral("/.XCompose");
+ QString path = qgetenv("HOME") + QLatin1String("/.XCompose");
if (QFile::exists(path))
return path;
}
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index f6a3b3943f..f02dad675e 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -457,6 +457,10 @@ QCocoaScreen *QCocoaIntegration::screenAtIndex(int index)
if (index >= mScreens.count())
updateScreens();
+ // It is possible that the screen got removed while updateScreens was called
+ // so we do a sanity check to be certain
+ if (index >= mScreens.count())
+ return 0;
return mScreens.at(index);
}
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h
index 7951a2ff70..6b80162e4d 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.h
+++ b/src/plugins/platforms/cocoa/qcocoamenu.h
@@ -93,6 +93,9 @@ public:
void setAttachedItem(NSMenuItem *item);
NSMenuItem *attachedItem() const;
+ bool isOpen() const;
+ void setIsOpen(bool isOpen);
+
private:
QCocoaMenuItem *itemOrNull(int index) const;
void insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem);
@@ -100,9 +103,10 @@ private:
QList<QCocoaMenuItem *> m_menuItems;
NSMenu *m_nativeMenu;
NSMenuItem *m_attachedItem;
+ quintptr m_tag;
bool m_enabled;
bool m_visible;
- quintptr m_tag;
+ bool m_isOpen;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index a388155c03..06ec2aa479 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -137,12 +137,14 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate);
- (void) menuWillOpen:(NSMenu*)m
{
Q_UNUSED(m);
+ m_menu->setIsOpen(true);
emit m_menu->aboutToShow();
}
- (void) menuDidClose:(NSMenu*)m
{
Q_UNUSED(m);
+ m_menu->setIsOpen(false);
// wrong, but it's the best we can do
emit m_menu->aboutToHide();
}
@@ -257,9 +259,10 @@ QT_BEGIN_NAMESPACE
QCocoaMenu::QCocoaMenu() :
m_attachedItem(0),
+ m_tag(0),
m_enabled(true),
m_visible(true),
- m_tag(0)
+ m_isOpen(false)
{
QMacAutoReleasePool pool;
@@ -330,6 +333,8 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem)
item->nsItem().target = m_nativeMenu.delegate;
if (!item->menu())
[item->nsItem() setAction:@selector(itemFired:)];
+ else if (isOpen() && item->nsItem()) // Someone's adding new items after aboutToShow() was emitted
+ item->menu()->setAttachedItem(item->nsItem());
if (item->isMerged())
return;
@@ -353,6 +358,16 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem)
item->setMenuParent(this);
}
+bool QCocoaMenu::isOpen() const
+{
+ return m_isOpen;
+}
+
+void QCocoaMenu::setIsOpen(bool isOpen)
+{
+ m_isOpen = isOpen;
+}
+
void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem)
{
QMacAutoReleasePool pool;
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index 86f6dda2e9..96b40259b4 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -179,9 +179,11 @@ void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
}
}
- NSMenuItem *nativeMenuItem = nativeItemForMenu(cocoaMenu);
- nativeMenuItem.title = cocoaMenu->nsMenu().title;
- nativeMenuItem.hidden = shouldHide;
+ if (NSMenuItem *attachedItem = cocoaMenu->attachedItem()) {
+ // Non-nil attached item means the item's submenu is set
+ attachedItem.title = cocoaMenu->nsMenu().title;
+ attachedItem.hidden = shouldHide;
+ }
}
NSMenuItem *QCocoaMenuBar::nativeItemForMenu(QCocoaMenu *menu) const
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 9e2fca23a1..831f1cfcf4 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -260,34 +260,14 @@ QPixmap QCocoaTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
}
if (iconType != 0) {
QPixmap pixmap;
- IconRef icon;
- IconRef overlayIcon = 0;
- if (iconType != kGenericApplicationIcon) {
- GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon);
- } else {
- FSRef fsRef;
- ProcessSerialNumber psn = { 0, kCurrentProcess };
- GetProcessBundleLocation(&psn, &fsRef);
- GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0);
- if (sp == MessageBoxCritical) {
- overlayIcon = icon;
- GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon);
- }
- }
+ IconRef icon = Q_NULLPTR;
+ GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon);
if (icon) {
pixmap = qt_mac_convert_iconref(icon, size.width(), size.height());
ReleaseIconRef(icon);
}
- if (overlayIcon) {
- QSizeF littleSize = size / 2;
- QPixmap overlayPix = qt_mac_convert_iconref(overlayIcon, littleSize.width(), littleSize.height());
- QPainter painter(&pixmap);
- painter.drawPixmap(littleSize.width(), littleSize.height(), overlayPix);
- ReleaseIconRef(overlayIcon);
- }
-
return pixmap;
}
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 7834c2991d..a72cbd010a 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -443,7 +443,8 @@ static bool _q_dontOverrideCtrlLMB = false;
NSUInteger screenIndex = [[NSScreen screens] indexOfObject:self.window.screen];
if (screenIndex != NSNotFound) {
QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex);
- QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen());
+ if (cocoaScreen)
+ QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen());
m_platformWindow->updateExposedGeometry();
}
}
diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
index c6aab9d86c..3848e99221 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
@@ -82,7 +82,7 @@ QStringList QEglFSDeviceIntegrationFactory::keys(const QString &pluginPath)
QCoreApplication::addLibraryPath(pluginPath);
list = directLoader()->keyMap().values();
if (!list.isEmpty()) {
- const QString postFix = QStringLiteral(" (from ")
+ const QString postFix = QLatin1String(" (from ")
+ QDir::toNativeSeparators(pluginPath)
+ QLatin1Char(')');
const QStringList::iterator end = list.end();
diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro
index bd6f2d8e6f..3aca27b555 100644
--- a/src/plugins/platforms/minimal/minimal.pro
+++ b/src/plugins/platforms/minimal/minimal.pro
@@ -11,7 +11,7 @@ HEADERS = qminimalintegration.h \
OTHER_FILES += minimal.json
CONFIG += qpa/genericunixfontdatabase
-darwin: DEFINES += QT_NO_FONTCONFIG
+win32|darwin: DEFINES += QT_NO_FONTCONFIG
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin
diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
index b075690e3d..7f11de228e 100644
--- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
@@ -178,7 +178,7 @@ void QQnxRasterWindow::adjustBufferSize()
{
// When having a raster window we don't need any buffers, since
// Qt will draw to the parent TLW backing store.
- const QSize windowSize = window()->parent() ? QSize(1,1) : window()->size();
+ const QSize windowSize = window()->parent() ? QSize(0,0) : window()->size();
if (windowSize != bufferSize())
setBufferSize(windowSize);
}
@@ -194,6 +194,13 @@ void QQnxRasterWindow::resetBuffers()
m_currentBufferIndex = -1;
m_previousDirty = QRegion();
m_scrolled = QRegion();
+ if (window()->parent() && bufferSize() == QSize(1,1)) {
+ // If we have a parent then we're not really rendering. But if we don't render we'll
+ // be invisible and any children won't show up. This should be harmless since we're
+ // rendering into a 1x1 window that has transparency set to discard.
+ renderBuffer();
+ post(QRegion(0,0,1,1));
+ }
}
void QQnxRasterWindow::blitPreviousToCurrent(const QRegion &region, int dx, int dy, bool flush)
diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp
index e04f16db92..f4e6ca9804 100644
--- a/src/plugins/platforms/qnx/qqnxwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxwindow.cpp
@@ -386,7 +386,12 @@ void QQnxWindow::setBufferSize(const QSize &size)
// Set the transparency. According to QNX technical support, setting the window
// transparency property should always be done *after* creating the window
// buffers in order to guarantee the property is paid attention to.
- if (window()->requestedFormat().alphaBufferSize() == 0) {
+ if (size.isEmpty()) {
+ // We can't create 0x0 buffers and instead make them 1x1. But to allow these windows to
+ // still be 'visible' (thus allowing their children to be visible), we need to allow
+ // them to be posted but still not show up.
+ val[0] = SCREEN_TRANSPARENCY_DISCARD;
+ } else if (window()->requestedFormat().alphaBufferSize() == 0) {
// To avoid overhead in the composition manager, disable blending
// when the underlying window buffer doesn't have an alpha channel.
val[0] = SCREEN_TRANSPARENCY_NONE;
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index ef0962c2ff..3a683bd7a0 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -47,6 +47,7 @@
#include "qwindowsmime.h"
#include "qwindowsinputcontext.h"
#include "qwindowstabletsupport.h"
+#include "qwindowstheme.h"
#include <private/qguiapplication_p.h>
#ifndef QT_NO_ACCESSIBILITY
# include "accessible/qwindowsaccessibility.h"
@@ -339,7 +340,9 @@ void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiA
qCDebug(lcQpaWindows) << __FUNCTION__ << dpiAwareness;
if (QWindowsContext::shcoredll.isValid()) {
const HRESULT hr = QWindowsContext::shcoredll.setProcessDpiAwareness(dpiAwareness);
- if (FAILED(hr)) {
+ // E_ACCESSDENIED means set externally (MSVC manifest or external app loading Qt plugin).
+ // Silence warning in that case unless debug is enabled.
+ if (FAILED(hr) && (hr != E_ACCESSDENIED || lcQpaWindows().isDebugEnabled())) {
qWarning().noquote().nospace() << "SetProcessDpiAwareness("
<< dpiAwareness << ") failed: " << QWindowsContext::comErrorString(hr)
<< ", using " << QWindowsContext::processDpiAwareness();
@@ -428,28 +431,29 @@ QString QWindowsContext::registerWindowClass(const QWindow *w)
break;
}
// Create a unique name for the flag combination
- QString cname = QStringLiteral("Qt5QWindow");
+ QString cname;
+ cname += QLatin1String("Qt5QWindow");
switch (type) {
case Qt::Tool:
- cname += QStringLiteral("Tool");
+ cname += QLatin1String("Tool");
break;
case Qt::ToolTip:
- cname += QStringLiteral("ToolTip");
+ cname += QLatin1String("ToolTip");
break;
case Qt::Popup:
- cname += QStringLiteral("Popup");
+ cname += QLatin1String("Popup");
break;
default:
break;
}
if (style & CS_DROPSHADOW)
- cname += QStringLiteral("DropShadow");
+ cname += QLatin1String("DropShadow");
if (style & CS_SAVEBITS)
- cname += QStringLiteral("SaveBits");
+ cname += QLatin1String("SaveBits");
if (style & CS_OWNDC)
- cname += QStringLiteral("OwnDC");
+ cname += QLatin1String("OwnDC");
if (icon)
- cname += QStringLiteral("Icon");
+ cname += QLatin1String("Icon");
return registerWindowClass(cname, qWindowsWndProc, style, GetSysColorBrush(COLOR_WINDOW), icon);
}
@@ -714,8 +718,8 @@ static inline QString errorMessageFromComError(const _com_error &comError)
return result;
}
if (const WORD wCode = comError.WCode())
- return QStringLiteral("IDispatch error #") + QString::number(wCode);
- return QStringLiteral("Unknown error 0x0") + QString::number(comError.Error(), 16);
+ return QString::asprintf("IDispatch error #%u", uint(wCode));
+ return QString::asprintf("Unknown error 0x0%x", uint(comError.Error()));
}
/*!
@@ -736,6 +740,9 @@ QByteArray QWindowsContext::comErrorString(HRESULT hr)
case E_UNEXPECTED:
result += QByteArrayLiteral("E_UNEXPECTED");
break;
+ case E_ACCESSDENIED:
+ result += QByteArrayLiteral("E_ACCESSDENIED");
+ break;
case CO_E_ALREADYINITIALIZED:
result += QByteArrayLiteral("CO_E_ALREADYINITIALIZED");
break;
@@ -891,6 +898,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
#endif
case QtWindows::DisplayChangedEvent:
return d->m_screenManager.handleDisplayChange(wParam, lParam);
+ if (QWindowsTheme *t = QWindowsTheme::instance())
+ t->displayChanged();
case QtWindows::SettingChangedEvent:
return d->m_screenManager.handleScreenChanges();
default:
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index 6124b004b6..a4738dc100 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -367,7 +367,7 @@ QSurfaceFormat QWindowsEGLStaticContext::formatFromConfig(EGLDisplay display, EG
\list
\o Install the Direct X SDK
\o Checkout and build ANGLE (SVN repository) as explained here:
- \l{http://code.google.com/p/angleproject/wiki/DevSetup}{ANGLE-Project}.
+ \l{https://chromium.googlesource.com/angle/angle/+/master/README.md}
When building for 64bit, de-activate the "WarnAsError" option
in every project file (as otherwise integer conversion
warnings will break the build).
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp
index d6375693d8..30d438a127 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -696,7 +696,7 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData
QByteArray data = getData(CF_UNICODETEXT, pDataObj);
if (!data.isEmpty()) {
str = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData()));
- str.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
+ str.replace(QLatin1String("\r\n"), QLatin1String("\n"));
} else {
data = getData(CF_TEXT, pDataObj);
if (!data.isEmpty()) {
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 45fbb4fdd3..3f6230172e 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -420,6 +420,8 @@ static bool isValidWheelReceiver(QWindow *candidate)
{
if (candidate) {
const QWindow *toplevel = QWindowsWindow::topLevelOf(candidate);
+ if (toplevel->type() == Qt::ForeignWindow)
+ return true;
if (const QWindowsWindow *ww = QWindowsWindow::windowsWindowOf(toplevel))
return !ww->testFlag(QWindowsWindow::BlockedByModal);
}
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
index d5d50a69cd..5283d6b260 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -226,15 +226,16 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c
if (!glesOnly && testDesktopGL())
result |= QWindowsOpenGLTester::DesktopGl;
- QSet<QString> features;
const char bugListFileVar[] = "QT_OPENGL_BUGLIST";
+ QString buglistFileName = QStringLiteral(":/qt-project.org/windows/openglblacklists/default.json");
+
if (qEnvironmentVariableIsSet(bugListFileVar)) {
const QString fileName = resolveBugListFile(QFile::decodeName(qgetenv(bugListFileVar)));
if (!fileName.isEmpty())
- features = QOpenGLConfig::gpuFeatures(qgpu, fileName);
- } else {
- features = QOpenGLConfig::gpuFeatures(qgpu, QStringLiteral(":/qt-project.org/windows/openglblacklists/default.json"));
+ buglistFileName = fileName;
}
+
+ QSet<QString> features = QOpenGLConfig::gpuFeatures(qgpu, buglistFileName);
qCDebug(lcQpaGl) << "GPU features:" << features;
if (features.contains(QStringLiteral("disable_desktopgl"))) { // Qt-specific
diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp
index d559273950..6cc56372ec 100644
--- a/src/plugins/platforms/windows/qwindowsservices.cpp
+++ b/src/plugins/platforms/windows/qwindowsservices.cpp
@@ -87,9 +87,8 @@ static inline QString mailCommand()
keyName = QString::fromWCharArray(command);
RegCloseKey(handle);
}
- if (keyName.isEmpty())
- keyName = QStringLiteral("mailto");
- keyName += QStringLiteral("\\Shell\\Open\\Command");
+ const QLatin1String mailto = keyName.isEmpty() ? QLatin1String("mailto") : QLatin1String();
+ keyName += mailto + QLatin1String("\\Shell\\Open\\Command");
if (debug)
qDebug() << __FUNCTION__ << "keyName=" << keyName;
command[0] = 0;
@@ -123,7 +122,7 @@ static inline bool launchMail(const QUrl &url)
}
// Pass the url as the parameter. Should use QProcess::startDetached(),
// but that cannot handle a Windows command line [yet].
- command.replace(QStringLiteral("%1"), url.toString(QUrl::FullyEncoded));
+ command.replace(QLatin1String("%1"), url.toString(QUrl::FullyEncoded));
if (debug)
qDebug() << __FUNCTION__ << "Launching" << command;
//start the process
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index 3689978b41..46306d438f 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -53,7 +53,7 @@
#include <QtGui/QGuiApplication>
#include <QtGui/QWindow>
#include <QtCore/QDebug>
-#include <QtCore/QScopedArrayPointer>
+#include <QtCore/QVarLengthArray>
#include <QtCore/QtMath>
#include <private/qguiapplication_p.h>
@@ -233,7 +233,7 @@ QString QWindowsTabletSupport::description() const
const unsigned size = m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, 0);
if (!size)
return QString();
- QScopedPointer<TCHAR> winTabId(new TCHAR[size + 1]);
+ QVarLengthArray<TCHAR> winTabId(size + 1);
m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, winTabId.data());
WORD implementationVersion = 0;
m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_IMPLVERSION, &implementationVersion);
@@ -246,11 +246,11 @@ QString QWindowsTabletSupport::description() const
.arg(implementationVersion >> 8).arg(implementationVersion & 0xFF)
.arg(opts, 0, 16);
if (opts & CXO_MESSAGES)
- result += QStringLiteral(" CXO_MESSAGES");
+ result += QLatin1String(" CXO_MESSAGES");
if (opts & CXO_CSRMESSAGES)
- result += QStringLiteral(" CXO_CSRMESSAGES");
+ result += QLatin1String(" CXO_CSRMESSAGES");
if (m_tiltSupport)
- result += QStringLiteral(" tilt");
+ result += QLatin1String(" tilt");
return result;
}
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 6c6eb42d63..ff556caeaf 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -319,6 +319,7 @@ QWindowsTheme::QWindowsTheme()
std::fill(m_fonts, m_fonts + NFonts, static_cast<QFont *>(0));
std::fill(m_palettes, m_palettes + NPalettes, static_cast<QPalette *>(0));
refresh();
+ refreshIconPixmapSizes();
}
QWindowsTheme::~QWindowsTheme()
@@ -330,7 +331,7 @@ QWindowsTheme::~QWindowsTheme()
static inline QStringList iconThemeSearchPaths()
{
- const QFileInfo appDir(QCoreApplication::applicationDirPath() + QStringLiteral("/icons"));
+ const QFileInfo appDir(QCoreApplication::applicationDirPath() + QLatin1String("/icons"));
return appDir.isDir() ? QStringList(appDir.absoluteFilePath()) : QStringList();
}
@@ -382,16 +383,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
return QVariant(int(WindowsKeyboardScheme));
case UiEffects:
return QVariant(uiEffects());
- case IconPixmapSizes: {
- QList<int> sizes;
- sizes << 16 << 32;
-#ifdef USE_IIMAGELIST
- sizes << 48; // sHIL_EXTRALARGE
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
- sizes << 256; // SHIL_JUMBO
-#endif // USE_IIMAGELIST
- return QVariant::fromValue(sizes);
- }
+ case IconPixmapSizes:
+ return m_fileIconSizes;
case DialogSnapToDefaultButton:
return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false));
case ContextMenuOnMouseRelease:
@@ -459,6 +452,15 @@ void QWindowsTheme::refreshFonts()
m_fonts[FixedFont] = new QFont(fixedFont);
}
+enum FileIconSize {
+ // Standard icons obtainable via shGetFileInfo(), SHGFI_SMALLICON, SHGFI_LARGEICON
+ SmallFileIcon, LargeFileIcon,
+ // Larger icons obtainable via SHGetImageList()
+ ExtraLargeFileIcon,
+ JumboFileIcon, // Vista onwards
+ FileIconSizeCount
+};
+
bool QWindowsTheme::usePlatformNativeDialog(DialogType type) const
{
return QWindowsDialogs::useHelper(type);
@@ -475,6 +477,27 @@ void QWindowsTheme::windowsThemeChanged(QWindow * window)
QWindowSystemInterface::handleThemeChange(window);
}
+static int fileIconSizes[FileIconSizeCount];
+
+void QWindowsTheme::refreshIconPixmapSizes()
+{
+ // Standard sizes: 16, 32, 48, 256
+ fileIconSizes[SmallFileIcon] = GetSystemMetrics(SM_CXSMICON); // corresponds to SHGFI_SMALLICON);
+ fileIconSizes[LargeFileIcon] = GetSystemMetrics(SM_CXICON); // corresponds to SHGFI_LARGEICON
+ fileIconSizes[ExtraLargeFileIcon] =
+ fileIconSizes[LargeFileIcon] + fileIconSizes[LargeFileIcon] / 2;
+ fileIconSizes[JumboFileIcon] = 8 * fileIconSizes[LargeFileIcon]; // empirical, has not been observed to work
+ QList<int> sizes;
+ sizes << fileIconSizes[SmallFileIcon] << fileIconSizes[LargeFileIcon];
+#ifdef USE_IIMAGELIST
+ sizes << fileIconSizes[ExtraLargeFileIcon]; // sHIL_EXTRALARGE
+ if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
+ sizes << fileIconSizes[JumboFileIcon]; // SHIL_JUMBO
+#endif // USE_IIMAGELIST
+ qCDebug(lcQpaWindows) << __FUNCTION__ << sizes;
+ m_fileIconSizes = QVariant::fromValue(sizes);
+}
+
// Defined in qpixmap_win.cpp
Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon);
@@ -702,10 +725,12 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
QPixmap pixmap;
const QString filePath = QDir::toNativeSeparators(fileInfo.filePath());
const int width = int(size.width());
- const int iconSize = width > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON;
+ const int iconSize = width > fileIconSizes[SmallFileIcon] ? SHGFI_LARGEICON : SHGFI_SMALLICON;
const int requestedImageListSize =
#ifdef USE_IIMAGELIST
- width > 48 ? sHIL_JUMBO : (width > 32 ? sHIL_EXTRALARGE : 0);
+ width > fileIconSizes[ExtraLargeFileIcon]
+ ? sHIL_JUMBO
+ : (width > fileIconSizes[LargeFileIcon] ? sHIL_EXTRALARGE : 0);
#else
0;
#endif // !USE_IIMAGELIST
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
index acf89306c2..fa1fb4d998 100644
--- a/src/plugins/platforms/windows/qwindowstheme.h
+++ b/src/plugins/platforms/windows/qwindowstheme.h
@@ -43,6 +43,8 @@
#include "qwindowsthreadpoolrunner.h"
#include <qpa/qplatformtheme.h>
+#include <QtCore/QVariant>
+
QT_BEGIN_NAMESPACE
class QWindow;
@@ -68,6 +70,7 @@ public:
QPlatformTheme::IconOptions iconOptions = 0) const Q_DECL_OVERRIDE;
void windowsThemeChanged(QWindow *window);
+ void displayChanged() { refreshIconPixmapSizes(); }
static const char *name;
@@ -77,11 +80,13 @@ private:
void refreshPalettes();
void clearFonts();
void refreshFonts();
+ void refreshIconPixmapSizes();
static QWindowsTheme *m_instance;
QPalette *m_palettes[NPalettes];
QFont *m_fonts[NFonts];
mutable QWindowsThreadPoolRunner m_threadPoolRunner;
+ QVariant m_fileIconSizes;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index e58058010d..29f0af4621 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2395,9 +2395,10 @@ void QWindowsWindow::aboutToMakeCurrent()
void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border)
{
- if (!window->handle())
- return;
- static_cast<QWindowsWindow *>(window->handle())->setHasBorderInFullScreen(border);
+ if (QPlatformWindow *handle = window->handle())
+ static_cast<QWindowsWindow *>(handle)->setHasBorderInFullScreen(border);
+ else
+ qWarning("%s invoked without window handle; call has no effect.", Q_FUNC_INFO);
}
void QWindowsWindow::setHasBorderInFullScreen(bool border)
diff --git a/src/plugins/platforms/winrt/qwinrtclipboard.cpp b/src/plugins/platforms/winrt/qwinrtclipboard.cpp
index aee9fc617d..2811f1f018 100644
--- a/src/plugins/platforms/winrt/qwinrtclipboard.cpp
+++ b/src/plugins/platforms/winrt/qwinrtclipboard.cpp
@@ -102,7 +102,7 @@ QMimeData *QWinRTClipboard::mimeData(QClipboard::Mode mode)
quint32 size;
const wchar_t *textStr = result.GetRawBuffer(&size);
QString text = QString::fromWCharArray(textStr, size);
- text.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
+ text.replace(QLatin1String("\r\n"), QLatin1String("\n"));
m_mimeData.setText(text);
return &m_mimeData;
diff --git a/src/plugins/platforms/winrt/qwinrtdrag.cpp b/src/plugins/platforms/winrt/qwinrtdrag.cpp
index 2ef50aa4e2..055aacbf56 100644
--- a/src/plugins/platforms/winrt/qwinrtdrag.cpp
+++ b/src/plugins/platforms/winrt/qwinrtdrag.cpp
@@ -504,8 +504,8 @@ static HRESULT qt_drop(IInspectable *sender, ABI::Windows::UI::Xaml::IDragEventA
class QtDragEventHandler##name : public IDragEventHandler \
{ \
public: \
- virtual HRESULT STDMETHODCALLTYPE Invoke(IInspectable *sender, \
- ABI::Windows::UI::Xaml::IDragEventArgs *e) \
+ STDMETHODIMP Invoke(IInspectable *sender, \
+ ABI::Windows::UI::Xaml::IDragEventArgs *e) \
{ \
return qt_##func(sender, e);\
} \
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 5d46c53b30..7065bb0ffb 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -265,8 +265,8 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event)
} else {
screen = createScreen(virtualDesktop, output, outputInfo.data());
qCDebug(lcQpaScreen) << "output" << screen->name() << "is connected and enabled";
- QHighDpiScaling::updateHighDpiScaling();
}
+ QHighDpiScaling::updateHighDpiScaling();
}
} else if (screen) {
if (output.crtc == XCB_NONE && output.mode == XCB_NONE) {
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index 7168e6e3bd..811ef4251a 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -979,10 +979,21 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
xkb_layout_index_t lockedLayout = xkb_state_serialize_layout(xkb_state, XKB_STATE_LAYOUT_LOCKED);
xkb_mod_mask_t latchedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED);
xkb_mod_mask_t lockedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED);
+ xkb_mod_mask_t depressedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_DEPRESSED);
- xkb_state_update_mask(kb_state, 0, latchedMods, lockedMods, 0, 0, lockedLayout);
-
+ xkb_state_update_mask(kb_state, depressedMods, latchedMods, lockedMods, 0, 0, lockedLayout);
quint32 keycode = event->nativeScanCode();
+ // handle shortcuts for level three and above
+ xkb_layout_index_t layoutIndex = xkb_state_key_get_layout(kb_state, keycode);
+ xkb_level_index_t levelIndex = 0;
+ if (layoutIndex != XKB_LAYOUT_INVALID) {
+ levelIndex = xkb_state_key_get_level(kb_state, keycode, layoutIndex);
+ if (levelIndex == XKB_LEVEL_INVALID)
+ levelIndex = 0;
+ }
+ if (levelIndex <= 1)
+ xkb_state_update_mask(kb_state, 0, latchedMods, lockedMods, 0, 0, lockedLayout);
+
xkb_keysym_t sym = xkb_state_key_get_one_sym(kb_state, keycode);
if (sym == XKB_KEY_NoSymbol) {
xkb_state_unref(kb_state);
diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp
index 825a8acd1f..f7244739a5 100644
--- a/src/plugins/platforms/xcb/qxcbmime.cpp
+++ b/src/plugins/platforms/xcb/qxcbmime.cpp
@@ -131,6 +131,11 @@ bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeDa
ret = true;
} else if ((a == XCB_ATOM_PIXMAP || a == XCB_ATOM_BITMAP) && mimeData->hasImage()) {
ret = true;
+ } else if (atomName == QLatin1String("text/plain")
+ && mimeData->hasFormat(QLatin1String("text/uri-list"))) {
+ // Return URLs also as plain text.
+ *data = QInternalMimeData::renderDataHelper(atomName, mimeData);
+ ret = true;
}
return ret;
}
@@ -149,8 +154,10 @@ QVector<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, con
}
// special cases for uris
- if (format == QLatin1String("text/uri-list"))
+ if (format == QLatin1String("text/uri-list")) {
atoms.append(connection->internAtom("text/x-moz-url"));
+ atoms.append(connection->internAtom("text/plain"));
+ }
//special cases for images
if (format == QLatin1String("image/ppm"))
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index a57b72b13e..b3dc33895b 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -394,6 +394,9 @@ int QWin32PrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const
case QPaintDevice::PdmDevicePixelRatio:
val = 1;
break;
+ case QPaintDevice::PdmDevicePixelRatioScaled:
+ val = 1 * QPaintDevice::devicePixelRatioFScale();
+ break;
default:
qWarning("QPrinter::metric: Invalid metric command");
return 0;
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 49a0c2104b..63e79c777f 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -108,43 +108,63 @@ template<> inline char *toString(const QDateTime &dateTime)
template<> inline char *toString(const QChar &c)
{
+ const ushort uc = c.unicode();
+ if (uc < 128) {
+ char msg[32] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QChar: '%c' (0x%x)", char(uc), unsigned(uc));
+ return qstrdup(msg);
+ }
return qstrdup(qPrintable(QString::fromLatin1("QChar: '%1' (0x%2)").arg(c).arg(QString::number(static_cast<int>(c.unicode()), 16))));
}
template<> inline char *toString(const QPoint &p)
{
- return qstrdup(QString::fromLatin1("QPoint(%1,%2)").arg(p.x()).arg(p.y()).toLatin1().constData());
+ char msg[128] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QPoint(%d,%d)", p.x(), p.y());
+ return qstrdup(msg);
}
template<> inline char *toString(const QSize &s)
{
- return qstrdup(QString::fromLatin1("QSize(%1x%2)").arg(s.width()).arg(s.height()).toLatin1().constData());
+ char msg[128] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QSize(%dx%d)", s.width(), s.height());
+ return qstrdup(msg);
}
template<> inline char *toString(const QRect &s)
{
- return qstrdup(QString::fromLatin1("QRect(%1,%2 %5x%6) (bottomright %3,%4)").arg(s.left()).arg(s.top()).arg(s.right()).arg(s.bottom()).arg(s.width()).arg(s.height()).toLatin1().constData());
+ char msg[256] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QRect(%d,%d %dx%d) (bottomright %d,%d)",
+ s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom());
+ return qstrdup(msg);
}
template<> inline char *toString(const QPointF &p)
{
- return qstrdup(QString::fromLatin1("QPointF(%1,%2)").arg(p.x()).arg(p.y()).toLatin1().constData());
+ char msg[64] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QPointF(%g,%g)", p.x(), p.y());
+ return qstrdup(msg);
}
template<> inline char *toString(const QSizeF &s)
{
- return qstrdup(QString::fromLatin1("QSizeF(%1x%2)").arg(s.width()).arg(s.height()).toLatin1().constData());
+ char msg[64] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QSizeF(%gx%g)", s.width(), s.height());
+ return qstrdup(msg);
}
template<> inline char *toString(const QRectF &s)
{
- return qstrdup(QString::fromLatin1("QRectF(%1,%2 %5x%6) (bottomright %3,%4)").arg(s.left()).arg(s.top()).arg(s.right()).arg(s.bottom()).arg(s.width()).arg(s.height()).toLatin1().constData());
+ char msg[256] = {'\0'};
+ qsnprintf(msg, sizeof(msg), "QRectF(%g,%g %gx%g) (bottomright %g,%g)",
+ s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom());
+ return qstrdup(msg);
}
template<> inline char *toString(const QUrl &uri)
{
if (!uri.isValid())
- return qstrdup(qPrintable(QStringLiteral("Invalid URL: ") + uri.errorString()));
+ return qstrdup(qPrintable(QLatin1String("Invalid URL: ") + uri.errorString()));
return qstrdup(uri.toEncoded().constData());
}
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h
index 5027aea732..d0d56e7bd0 100644
--- a/src/testlib/qtest_gui.h
+++ b/src/testlib/qtest_gui.h
@@ -58,6 +58,7 @@
#include <QtGui/qcolor.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qimage.h>
+#include <QtGui/qregion.h>
#ifdef QT_WIDGETS_LIB
#include <QtGui/qicon.h>
@@ -82,6 +83,39 @@ template<> inline char *toString(const QColor &color)
return qstrdup(color.name().toLocal8Bit().constData());
}
+template<> inline char *toString(const QRegion &region)
+{
+ QByteArray result = "QRegion(";
+ if (region.isNull()) {
+ result += "null";
+ } else if (region.isEmpty()) {
+ result += "empty";
+ } else {
+ const QVector<QRect> &rects = region.rects();
+ const int rectCount = rects.size();
+ if (rectCount > 1) {
+ result += QByteArray::number(rectCount);
+ result += " rectangles, ";
+ }
+ for (int i = 0; i < rectCount; ++i) {
+ if (i)
+ result += ", ";
+ const QRect &r = rects.at(i);
+ result += QByteArray::number(r.width());
+ result += 'x';
+ result += QByteArray::number(r.height());
+ if (r.x() >= 0)
+ result += '+';
+ result += QByteArray::number(r.x());
+ if (r.y() >= 0)
+ result += '+';
+ result += QByteArray::number(r.y());
+ }
+ }
+ result += ')';
+ return qstrdup(result.constData());
+}
+
inline bool qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected,
const char *file, int line)
{
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index b6c70fdd86..cfa7d1b8ca 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -958,7 +958,7 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
QBenchmarkTestMethodData::current = &benchmarkData;
const QByteArray &name = m_methods[index].name();
- QBenchmarkGlobalData::current->context.slotName = QLatin1String(name) + QStringLiteral("()");
+ QBenchmarkGlobalData::current->context.slotName = QLatin1String(name) + QLatin1String("()");
char member[512];
QTestTable table;
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 14d1cd46dc..befc280f4e 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -188,7 +188,8 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
token = keywords[state].ident;
if (token == NOTOKEN) {
- ++data;
+ if (*data)
+ ++data;
// an error really, but let's ignore this input
// to not confuse moc later. However in pre-processor
// only mode let's continue.
@@ -362,7 +363,6 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
++data;
continue;
}
-
int nextindex = pp_keywords[state].next;
int next = 0;
if (*data == pp_keywords[state].defchar)
@@ -381,7 +381,8 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso
switch (token) {
case NOTOKEN:
- ++data;
+ if (*data)
+ ++data;
break;
case PP_DEFINE:
mode = PrepareDefine;
@@ -1252,7 +1253,6 @@ void Preprocessor::parseDefineArguments(Macro *m)
error("missing ')' in macro argument list");
break;
} else if (!is_identifier(l.constData(), l.length())) {
- qDebug() << l;
error("Unexpected character in macro argument list.");
}
}
diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp
index e93e6bb26c..a99d6adf07 100644
--- a/src/tools/uic/cpp/cppwriteincludes.cpp
+++ b/src/tools/uic/cpp/cppwriteincludes.cpp
@@ -291,9 +291,8 @@ void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global)
const StringMap::const_iterator hit = m_oldHeaderToNewHeader.constFind(sit.key());
const bool mapped = hit != m_oldHeaderToNewHeader.constEnd();
const QString header = mapped ? hit.value() : sit.key();
- if (!header.trimmed().isEmpty()) {
+ if (!QStringRef(&header).trimmed().isEmpty())
m_output << "#include " << openingQuote << header << closingQuote << QLatin1Char('\n');
- }
}
}
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 8c8141f9e5..ade3c5db35 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -1255,14 +1255,14 @@ void WriteInitialization::writeProperties(const QString &varName,
QString setFunction;
if (stdset) {
- setFunction = QLatin1String("->set");
- setFunction += propertyName.left(1).toUpper();
- setFunction += propertyName.mid(1);
- setFunction += QLatin1Char('(');
+ setFunction = QLatin1String("->set")
+ + propertyName.left(1).toUpper()
+ + propertyName.midRef(1)
+ + QLatin1Char('(');
} else {
- setFunction = QLatin1String("->setProperty(\"");
- setFunction += propertyName;
- setFunction += QLatin1String("\", QVariant");
+ setFunction += QLatin1String("->setProperty(\"")
+ + propertyName
+ + QLatin1String("\", QVariant");
if (p->kind() == DomProperty::Enum)
setFunction += QLatin1String("::fromValue");
setFunction += QLatin1Char('(');
@@ -1286,9 +1286,9 @@ void WriteInitialization::writeProperties(const QString &varName,
if (stdset)
propertyValue = fixString(p->elementCstring(), m_dindent);
else {
- propertyValue = QLatin1String("QByteArray(");
- propertyValue += fixString(p->elementCstring(), m_dindent);
- propertyValue += QLatin1Char(')');
+ propertyValue = QLatin1String("QByteArray(")
+ + fixString(p->elementCstring(), m_dindent)
+ + QLatin1Char(')');
}
}
break;
@@ -1304,11 +1304,8 @@ void WriteInitialization::writeProperties(const QString &varName,
break;
case DomProperty::Enum:
propertyValue = p->elementEnum();
- if (!propertyValue.contains(QLatin1String("::"))) {
- QString scope = className;
- scope += QLatin1String("::");
- propertyValue.prepend(scope);
- }
+ if (!propertyValue.contains(QLatin1String("::")))
+ propertyValue = className + QLatin1String("::") + propertyValue;
break;
case DomProperty::Set:
propertyValue = p->elementSet();
@@ -1898,31 +1895,29 @@ QString WriteInitialization::pixCall(const QString &t, const QString &text) cons
if (m_option.extractImages) {
const QString format = image->elementData()->attributeFormat();
const QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower();
- QString rc = QLatin1String("QPixmap(QString::fromUtf8(\":/");
- rc += m_generatedClass;
- rc += QLatin1String("/images/");
- rc += text;
- rc += QLatin1Char('.');
- rc += extension;
- rc += QLatin1String("\"))");
- return rc;
- }
- QString rc = WriteIconInitialization::iconFromDataFunction();
- rc += QLatin1Char('(');
- rc += text;
- rc += QLatin1String("_ID)");
- return rc;
+ return QLatin1String("QPixmap(QString::fromUtf8(\":/")
+ + m_generatedClass
+ + QLatin1String("/images/")
+ + text
+ + QLatin1Char('.')
+ + extension
+ + QLatin1String("\"))");
+ }
+ return WriteIconInitialization::iconFromDataFunction()
+ + QLatin1Char('(')
+ + text
+ + QLatin1String("_ID)");
}
QString pixFunc = m_uic->pixmapFunction();
if (pixFunc.isEmpty())
pixFunc = QLatin1String("QString::fromUtf8");
- type += QLatin1Char('(');
- type += pixFunc;
- type += QLatin1Char('(');
- type += fixString(text, m_dindent);
- type += QLatin1String("))");
+ type += QLatin1Char('(')
+ + pixFunc
+ + QLatin1Char('(')
+ + fixString(text, m_dindent)
+ + QLatin1String("))");
return type;
}
@@ -2316,23 +2311,20 @@ QString WriteInitialization::trCall(const QString &str, const QString &commentHi
if (m_option.translateFunction.isEmpty()) {
if (m_option.idBased) {
- result = QLatin1String("qtTrId(");
+ result += QLatin1String("qtTrId(");
} else {
- result = QLatin1String("QApplication::translate(\"");
- result += m_generatedClass;
- result += QLatin1Char('"');
- result += QLatin1String(", ");
+ result += QLatin1String("QApplication::translate(\"")
+ + m_generatedClass
+ + QLatin1String("\", ");
}
} else {
- result = m_option.translateFunction;
- result += QLatin1Char('(');
+ result += m_option.translateFunction + QLatin1Char('(');
}
result += fixString(str, m_dindent);
if (!m_option.idBased) {
- result += QLatin1String(", ");
- result += comment;
+ result += QLatin1String(", ") + comment;
}
result += QLatin1Char(')');
@@ -2473,10 +2465,8 @@ void WriteInitialization::acceptWidgetScripts(const DomScripts &widgetScripts, D
QString script;
for (const DomScript *domScript : qAsConst(scripts)) {
const QString snippet = domScript->text();
- if (!snippet.isEmpty()) {
- script += snippet.trimmed();
- script += QLatin1Char('\n');
- }
+ if (!snippet.isEmpty())
+ script += QStringRef(&snippet).trimmed() + QLatin1Char('\n');
}
if (script.isEmpty())
return;
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp
index 2f57fa08ee..95888924fb 100644
--- a/src/widgets/accessible/qaccessiblewidgets.cpp
+++ b/src/widgets/accessible/qaccessiblewidgets.cpp
@@ -824,12 +824,12 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end
AttributeFormatter attrs;
QString family = charFormatFont.family();
if (!family.isEmpty()) {
- family = family.replace('\\',QStringLiteral("\\\\"));
- family = family.replace(':',QStringLiteral("\\:"));
- family = family.replace(',',QStringLiteral("\\,"));
- family = family.replace('=',QStringLiteral("\\="));
- family = family.replace(';',QStringLiteral("\\;"));
- family = family.replace('\"',QStringLiteral("\\\""));
+ family = family.replace('\\', QLatin1String("\\\\"));
+ family = family.replace(':', QLatin1String("\\:"));
+ family = family.replace(',', QLatin1String("\\,"));
+ family = family.replace('=', QLatin1String("\\="));
+ family = family.replace(';', QLatin1String("\\;"));
+ family = family.replace('\"', QLatin1String("\\\""));
attrs["font-family"] = QString::fromLatin1("\"%1\"").arg(family);
}
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 5424a4126a..11b3659990 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE
about the underlying files and directories related to items in the model.
Directories can be created and removed using mkdir(), rmdir().
- \note QFileSystemModel requires an instance of a GUI application.
+ \note QFileSystemModel requires an instance of \l QApplication.
\section1 Example Usage
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index 53db11d2d7..4c01219d87 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -1082,7 +1082,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
if (candidates.isEmpty())
after = (beforeSequence == adjacents.last() ? adjacents.first() : adjacents.last());
else
- after = (candidates.last() == adjacents.last() ? adjacents.first() : adjacents.last());
+ after = (candidates.constLast() == adjacents.last() ? adjacents.first() : adjacents.last());
// ### At this point we assumed that candidates will not contain 'after', this may not hold
// when simplifying FLOATing anchors.
@@ -1134,9 +1134,9 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
// One restriction we have is to not simplify half of an anchor and let the other half
// unsimplified. So we remove center edges before and after the sequence.
- const AnchorData *firstAnchor = g.edgeData(beforeSequence, candidates.first());
+ const AnchorData *firstAnchor = g.edgeData(beforeSequence, candidates.constFirst());
if (firstAnchor->isCenterAnchor) {
- beforeSequence = candidates.first();
+ beforeSequence = candidates.constFirst();
candidates.remove(0);
// If there's not candidates to be simplified, leave.
@@ -1144,9 +1144,9 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
continue;
}
- const AnchorData *lastAnchor = g.edgeData(candidates.last(), afterSequence);
+ const AnchorData *lastAnchor = g.edgeData(candidates.constLast(), afterSequence);
if (lastAnchor->isCenterAnchor) {
- afterSequence = candidates.last();
+ afterSequence = candidates.constLast();
candidates.remove(candidates.count() - 1);
if (candidates.isEmpty())
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index b00a950823..4b5e380f4b 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -2151,7 +2151,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const
if (!blockingPanel)
blockingPanel = &dummy;
- QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func();
+ const QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func();
if (scene_d->modalPanels.isEmpty())
return false;
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index da5c2849ae..aa781e8f8b 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -940,7 +940,7 @@ void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit)
{
// Append to list of mouse grabber items, and send a mouse grab event.
if (mouseGrabberItems.contains(item)) {
- if (mouseGrabberItems.last() == item) {
+ if (mouseGrabberItems.constLast() == item) {
Q_ASSERT(!implicit);
if (!lastMouseGrabberItemHasImplicitMouseGrab) {
qWarning("QGraphicsItem::grabMouse: already a mouse grabber");
@@ -950,14 +950,14 @@ void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit)
}
} else {
qWarning("QGraphicsItem::grabMouse: already blocked by mouse grabber: %p",
- mouseGrabberItems.last());
+ mouseGrabberItems.constLast());
}
return;
}
// Send ungrab event to the last grabber.
if (!mouseGrabberItems.isEmpty()) {
- QGraphicsItem *last = mouseGrabberItems.last();
+ QGraphicsItem *last = mouseGrabberItems.constLast();
if (lastMouseGrabberItemHasImplicitMouseGrab) {
// Implicit mouse grab is immediately lost.
last->ungrabMouse();
@@ -987,12 +987,12 @@ void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying)
return;
}
- if (item != mouseGrabberItems.last()) {
+ if (item != mouseGrabberItems.constLast()) {
// Recursively ungrab the next mouse grabber until we reach this item
// to ensure state consistency.
ungrabMouse(mouseGrabberItems.at(index + 1), itemIsDying);
}
- if (!popupWidgets.isEmpty() && item == popupWidgets.last()) {
+ if (!popupWidgets.isEmpty() && item == popupWidgets.constLast()) {
// If the item is a popup, go via removePopup to ensure state
// consistency and that it gets hidden correctly - beware that
// removePopup() reenters this function to continue removing the grab.
@@ -1017,7 +1017,7 @@ void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying)
// items get a GrabMouse event, but this is a rare case with a simple
// implementation and it does ensure a consistent state.
if (!itemIsDying && !mouseGrabberItems.isEmpty()) {
- QGraphicsItem *last = mouseGrabberItems.last();
+ QGraphicsItem *last = mouseGrabberItems.constLast();
QEvent event(QEvent::GrabMouse);
sendEvent(last, &event);
}
@@ -1039,11 +1039,11 @@ void QGraphicsScenePrivate::clearMouseGrabber()
void QGraphicsScenePrivate::grabKeyboard(QGraphicsItem *item)
{
if (keyboardGrabberItems.contains(item)) {
- if (keyboardGrabberItems.last() == item)
+ if (keyboardGrabberItems.constLast() == item)
qWarning("QGraphicsItem::grabKeyboard: already a keyboard grabber");
else
qWarning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p",
- keyboardGrabberItems.last());
+ keyboardGrabberItems.constLast());
return;
}
@@ -1051,7 +1051,7 @@ void QGraphicsScenePrivate::grabKeyboard(QGraphicsItem *item)
if (!keyboardGrabberItems.isEmpty()) {
// Just send ungrab event to current grabber.
QEvent ungrabEvent(QEvent::UngrabKeyboard);
- sendEvent(keyboardGrabberItems.last(), &ungrabEvent);
+ sendEvent(keyboardGrabberItems.constLast(), &ungrabEvent);
}
keyboardGrabberItems << item;
@@ -1071,7 +1071,7 @@ void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying
qWarning("QGraphicsItem::ungrabKeyboard: not a keyboard grabber");
return;
}
- if (item != keyboardGrabberItems.last()) {
+ if (item != keyboardGrabberItems.constLast()) {
// Recursively ungrab the topmost keyboard grabber until we reach this
// item to ensure state consistency.
ungrabKeyboard(keyboardGrabberItems.at(index + 1), itemIsDying);
@@ -1088,7 +1088,7 @@ void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying
// Send notification about mouse regrab.
if (!itemIsDying && !keyboardGrabberItems.isEmpty()) {
- QGraphicsItem *last = keyboardGrabberItems.last();
+ QGraphicsItem *last = keyboardGrabberItems.constLast();
QEvent event(QEvent::GrabKeyboard);
sendEvent(last, &event);
}
@@ -1100,7 +1100,7 @@ void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying
void QGraphicsScenePrivate::clearKeyboardGrabber()
{
if (!keyboardGrabberItems.isEmpty())
- ungrabKeyboard(keyboardGrabberItems.first());
+ ungrabKeyboard(keyboardGrabberItems.constFirst());
}
void QGraphicsScenePrivate::enableMouseTrackingOnViews()
@@ -1142,8 +1142,8 @@ void QGraphicsScenePrivate::storeMouseButtonsForMouseGrabber(QGraphicsSceneMouse
for (int i = 0x1; i <= 0x10; i <<= 1) {
if (event->buttons() & i) {
mouseGrabberButtonDownPos.insert(Qt::MouseButton(i),
- mouseGrabberItems.last()->d_ptr->genericMapFromScene(event->scenePos(),
- event->widget()));
+ mouseGrabberItems.constLast()->d_ptr->genericMapFromScene(event->scenePos(),
+ event->widget()));
mouseGrabberButtonDownScenePos.insert(Qt::MouseButton(i), event->scenePos());
mouseGrabberButtonDownScreenPos.insert(Qt::MouseButton(i), event->screenPos());
}
@@ -1308,7 +1308,7 @@ void QGraphicsScenePrivate::sendMouseEvent(QGraphicsSceneMouseEvent *mouseEvent)
return;
}
- QGraphicsItem *item = mouseGrabberItems.last();
+ QGraphicsItem *item = mouseGrabberItems.constLast();
if (item->isBlockedByModalPanel())
return;
@@ -1335,7 +1335,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// Deliver to any existing mouse grabber.
if (!mouseGrabberItems.isEmpty()) {
- if (mouseGrabberItems.last()->isBlockedByModalPanel())
+ if (mouseGrabberItems.constLast()->isBlockedByModalPanel())
return;
// The event is ignored by default, but we disregard the event's
// accepted state after delivery; the mouse is grabbed, after all.
@@ -1401,7 +1401,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// Any item will do.
if (sceneModality && cachedItemsUnderMouse.isEmpty())
- cachedItemsUnderMouse << modalPanels.first();
+ cachedItemsUnderMouse << modalPanels.constFirst();
// Find a mouse grabber by sending mouse press events to all mouse grabber
// candidates one at a time, until the event is accepted. It's accepted by
@@ -1450,7 +1450,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
sendMouseEvent(mouseEvent);
}
- bool dontSendUngrabEvents = mouseGrabberItems.isEmpty() || mouseGrabberItems.last() != item;
+ bool dontSendUngrabEvents = mouseGrabberItems.isEmpty() || mouseGrabberItems.constLast() != item;
if (disabled) {
ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);
break;
@@ -2167,8 +2167,8 @@ QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item,
*/
QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const
{
- QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape,
- Qt::DescendingOrder, deviceTransform);
+ const QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape,
+ Qt::DescendingOrder, deviceTransform);
return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
}
@@ -3771,7 +3771,7 @@ void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)
// Remove all popups when the scene loses focus.
if (!d->popupWidgets.isEmpty())
- d->removePopup(d->popupWidgets.first());
+ d->removePopup(d->popupWidgets.constFirst());
}
/*!
@@ -3868,7 +3868,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
// Find the common ancestor item for the new topmost hoverItem and the
// last item in the hoverItem list.
- QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.last()) : 0;
+ QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.constLast()) : 0;
while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem))
commonAncestorItem = commonAncestorItem->parentItem();
if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) {
@@ -3909,7 +3909,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
// Generate a move event for the item itself
if (item
&& !hoverItems.isEmpty()
- && item == hoverItems.last()) {
+ && item == hoverItems.constLast()) {
sendHoverEvent(QEvent::GraphicsSceneHoverMove, item, hoverEvent);
return true;
}
@@ -3959,7 +3959,7 @@ void QGraphicsScene::keyPressEvent(QKeyEvent *keyEvent)
// ### Merge this function with keyReleaseEvent; they are identical
// ### (except this comment).
Q_D(QGraphicsScene);
- QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0;
+ QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.constLast() : 0;
if (!item)
item = focusItem();
if (item) {
@@ -3991,7 +3991,7 @@ void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent)
// ### Merge this function with keyPressEvent; they are identical (except
// ### this comment).
Q_D(QGraphicsScene);
- QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0;
+ QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.constLast() : 0;
if (!item)
item = focusItem();
if (item) {
@@ -4100,9 +4100,9 @@ void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
// Reset the mouse grabber when the last mouse button has been released.
if (!mouseEvent->buttons()) {
if (!d->mouseGrabberItems.isEmpty()) {
- d->lastMouseGrabberItem = d->mouseGrabberItems.last();
+ d->lastMouseGrabberItem = d->mouseGrabberItems.constLast();
if (d->lastMouseGrabberItemHasImplicitMouseGrab)
- d->mouseGrabberItems.last()->ungrabMouse();
+ d->mouseGrabberItems.constLast()->ungrabMouse();
} else {
d->lastMouseGrabberItem = 0;
}
@@ -5902,7 +5902,7 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(),
touchPoint.scenePos(),
static_cast<QWidget *>(sceneTouchEvent->target()));
- item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.first();
+ item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.constFirst();
}
if (sceneTouchEvent->device()->type() == QTouchDevice::TouchScreen) {
@@ -6013,7 +6013,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
{
Q_Q(QGraphicsScene);
- if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.first() != origin) {
+ if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.constFirst() != origin) {
const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first();
cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(),
firstTouchPoint.scenePos(),
@@ -6129,7 +6129,7 @@ void QGraphicsScenePrivate::enterModal(QGraphicsItem *panel, QGraphicsItem::Pane
}
if (!mouseGrabberItems.isEmpty() && lastMouseGrabberItemHasImplicitMouseGrab) {
- QGraphicsItem *item = mouseGrabberItems.last();
+ QGraphicsItem *item = mouseGrabberItems.constLast();
if (item->isBlockedByModalPanel())
ungrabMouse(item, /*itemIsDying =*/ false);
}
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 44e80ebeb9..3f7d2d1cd1 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -2375,7 +2375,7 @@ QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const
Q_D(const QGraphicsView);
if (!d->scene)
return 0;
- QList<QGraphicsItem *> itemsAtPos = items(pos);
+ const QList<QGraphicsItem *> itemsAtPos = items(pos);
return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first();
}
@@ -2860,7 +2860,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
// the mouse grab.
// Remove all popups when the scene loses focus.
if (!d->scene->d_func()->popupWidgets.isEmpty())
- d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first());
+ d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.constFirst());
QApplication::sendEvent(d->scene, event);
break;
case QEvent::Show:
@@ -2884,7 +2884,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
|| (QApplication::activeModalWidget() && QApplication::activeModalWidget() != window())
|| (QApplication::activeWindow() != window())) {
if (!d->scene->d_func()->popupWidgets.isEmpty())
- d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first());
+ d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.constFirst());
}
d->useLastMouseEvent = false;
// a hack to pass a viewport pointer to the scene inside the leave event
diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp
index 26173b5e92..6c7c914bc0 100644
--- a/src/widgets/itemviews/qcolumnview.cpp
+++ b/src/widgets/itemviews/qcolumnview.cpp
@@ -412,9 +412,9 @@ void QColumnViewPrivate::updateScrollbars()
// find the total horizontal length of the laid out columns
int horizontalLength = 0;
if (!columns.isEmpty()) {
- horizontalLength = (columns.last()->x() + columns.last()->width()) - columns.first()->x();
+ horizontalLength = (columns.constLast()->x() + columns.constLast()->width()) - columns.constFirst()->x();
if (horizontalLength <= 0) // reverse mode
- horizontalLength = (columns.first()->x() + columns.first()->width()) - columns.last()->x();
+ horizontalLength = (columns.constFirst()->x() + columns.constFirst()->width()) - columns.constLast()->x();
}
QSize viewportSize = viewport->size();
@@ -629,7 +629,7 @@ void QColumnViewPrivate::closeColumns(const QModelIndex &parent, bool build)
while (!dirsToAppend.isEmpty()) {
QAbstractItemView *newView = createColumn(dirsToAppend.takeLast(), true);
if (!dirsToAppend.isEmpty())
- newView->setCurrentIndex(dirsToAppend.last());
+ newView->setCurrentIndex(dirsToAppend.constLast());
}
if (build && !alreadyExists)
@@ -713,8 +713,8 @@ QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bo
columnSizes.resize(qMax(columnSizes.count(), columns.count() + 1));
columnSizes[columns.count()] = initialWidth;
}
- if (!columns.isEmpty() && columns.last()->isHidden())
- columns.last()->setVisible(true);
+ if (!columns.isEmpty() && columns.constLast()->isHidden())
+ columns.constLast()->setVisible(true);
columns.append(view);
doLayout();
@@ -835,7 +835,7 @@ void QColumnViewPrivate::setPreviewWidget(QWidget *widget)
{
Q_Q(QColumnView);
if (previewColumn) {
- if (!columns.isEmpty() && columns.last() == previewColumn)
+ if (!columns.isEmpty() && columns.constLast() == previewColumn)
columns.removeLast();
previewColumn->deleteLater();
}
@@ -1003,11 +1003,11 @@ void QColumnViewPrivate::_q_changeCurrentColumn()
parentColumn->setCurrentIndex(current.parent());
}
- if (columns.last()->isHidden()) {
- columns.last()->setVisible(true);
+ if (columns.constLast()->isHidden()) {
+ columns.constLast()->setVisible(true);
}
- if (columns.last()->selectionModel())
- columns.last()->selectionModel()->clear();
+ if (columns.constLast()->selectionModel())
+ columns.constLast()->selectionModel()->clear();
updateScrollbars();
}
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp
index 315d2503a4..95e6a1840d 100644
--- a/src/widgets/itemviews/qdirmodel.cpp
+++ b/src/widgets/itemviews/qdirmodel.cpp
@@ -212,7 +212,7 @@ void QDirModelPrivate::invalidate()
Directories can be created and removed using mkdir(), rmdir(), and the
model will be automatically updated to take the changes into account.
- \note QDirModel requires an instance of a GUI application.
+ \note QDirModel requires an instance of \l QApplication.
\sa nameFilters(), setFilter(), filter(), QListView, QTreeView, QFileSystemModel,
{Dir View Example}, {Model Classes}
@@ -885,7 +885,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const
#if defined(Q_OS_WIN)
if (absolutePath.startsWith(QLatin1String("//"))) { // UNC path
- QString host = pathElements.first();
+ QString host = pathElements.constFirst();
int r = 0;
for (; r < d->root.children.count(); ++r)
if (d->root.children.at(r).info.fileName() == host)
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 3303aac6ed..0788e0287a 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -2396,9 +2396,9 @@ QPoint QListModeViewBase::initStaticLayout(const QListViewLayoutInfo &info)
} else if (info.wrap) {
if (info.flow == QListView::LeftToRight) {
x = batchSavedPosition;
- y = segmentPositions.last();
+ y = segmentPositions.constLast();
} else { // flow == QListView::TopToBottom
- x = segmentPositions.last();
+ x = segmentPositions.constLast();
y = batchSavedPosition;
}
} else { // not first and not wrap
@@ -2613,7 +2613,7 @@ int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wr
int steps = positions.count() - 1;
int max = qMax(length, bounds);
int min = qMin(length, bounds);
- int pos = min - (max - positions.last());
+ int pos = min - (max - positions.constLast());
while (pos >= 0 && steps > 0) {
pos -= (positions.at(steps) - positions.at(steps - 1));
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index ca1e8f13ee..cfe68d6b6a 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -2356,10 +2356,10 @@ void QTreeView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFl
return;
}
if (!topLeft.isValid() && !d->viewItems.isEmpty())
- topLeft = d->viewItems.first().index;
+ topLeft = d->viewItems.constFirst().index;
if (!bottomRight.isValid() && !d->viewItems.isEmpty()) {
const int column = d->header->logicalIndex(d->header->count() - 1);
- const QModelIndex index = d->viewItems.last().index;
+ const QModelIndex index = d->viewItems.constLast().index;
bottomRight = index.sibling(index.row(), column);
}
@@ -2667,9 +2667,9 @@ void QTreeView::selectAll()
SelectionMode mode = d->selectionMode;
d->executePostedLayout(); //make sure we lay out the items
if (mode != SingleSelection && mode != NoSelection && !d->viewItems.isEmpty()) {
- const QModelIndex &idx = d->viewItems.last().index;
+ const QModelIndex &idx = d->viewItems.constLast().index;
QModelIndex lastItemIndex = idx.sibling(idx.row(), d->model->columnCount(idx.parent()) - 1);
- d->select(d->viewItems.first().index, lastItemIndex,
+ d->select(d->viewItems.constFirst().index, lastItemIndex,
QItemSelectionModel::ClearAndSelect
|QItemSelectionModel::Rows);
}
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index ce5e58642c..0bc1c029fe 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -65,13 +65,9 @@ public:
T &operator()(int r, int c) { return m_storage[r * NumColumns + c]; }
int rowCount() const { return m_storage.size() / NumColumns; }
- void addRow(const T &value);
void insertRow(int r, const T &value);
void removeRow(int r);
- bool find(const T &value, int *rowPtr, int *colPtr) const ;
- int count(const T &value) const { return m_storage.count(value); }
-
// Hmmpf.. Some things are faster that way.
const Storage &storage() const { return m_storage; }
@@ -82,13 +78,6 @@ private:
};
template <class T, int NumColumns>
-void FixedColumnMatrix<T, NumColumns>::addRow(const T &value)
-{
- for (int i = 0; i < NumColumns; ++i)
- m_storage.append(value);
-}
-
-template <class T, int NumColumns>
void FixedColumnMatrix<T, NumColumns>::insertRow(int r, const T &value)
{
typename Storage::iterator it = m_storage.begin();
@@ -103,16 +92,6 @@ void FixedColumnMatrix<T, NumColumns>::removeRow(int r)
}
template <class T, int NumColumns>
-bool FixedColumnMatrix<T, NumColumns>::find(const T &value, int *rowPtr, int *colPtr) const
-{
- const int idx = m_storage.indexOf(value);
- if (idx == -1)
- return false;
- storageIndexToPosition(idx, rowPtr, colPtr);
- return true;
-}
-
-template <class T, int NumColumns>
void FixedColumnMatrix<T, NumColumns>::storageIndexToPosition(int idx, int *rowPtr, int *colPtr)
{
*rowPtr = idx / NumColumns;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index a71089793c..25874e9bcc 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -565,7 +565,7 @@ void QWidget::setAutoFillBackground(bool enabled)
Composite widgets can also be created by subclassing a standard widget,
such as QWidget or QFrame, and adding the necessary layout and child
- widgets in the constructor of the subclass. Many of the \l{Qt Examples}
+ widgets in the constructor of the subclass. Many of the \l{Qt Widgets Examples}
{examples provided with Qt} use this approach, and it is also covered in
the Qt \l{Tutorials}.
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index 242e62572b..81fbe49a43 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -1012,9 +1012,11 @@ static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget)
// The Windows compositor handles fullscreen OpenGL window specially. Besides
// having trouble with popups, it also has issues with flip-flopping between
// OpenGL-based and normal flushing. Therefore, stick with GL for fullscreen
-// windows. (QTBUG-53515)
+// windows (QTBUG-53515). Similary, translucent windows should not switch to
+// layered native windows (QTBUG-54734).
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
|| tlw->windowState().testFlag(Qt::WindowFullScreen)
+ || tlw->testAttribute(Qt::WA_TranslucentBackground)
#endif
)
{
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 6b9e5577a4..36975c5877 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -5248,6 +5248,13 @@ static QPixmap cachedPixmapFromXPM(const char * const *xpm)
return result;
}
+#ifndef QT_NO_IMAGEFORMAT_PNG
+static inline QString clearText16IconPath()
+{
+ return QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-16.png");
+}
+#endif // !QT_NO_IMAGEFORMAT_PNG
+
static QIcon clearTextIcon(bool rtl)
{
const QString directionalThemeName = rtl
@@ -5260,7 +5267,7 @@ static QIcon clearTextIcon(bool rtl)
QIcon icon;
#ifndef QT_NO_IMAGEFORMAT_PNG
- QPixmap clearText16(QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-16.png"));
+ QPixmap clearText16(clearText16IconPath());
Q_ASSERT(!clearText16.size().isEmpty());
icon.addPixmap(clearText16);
QPixmap clearText32(QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-32.png"));
@@ -5575,6 +5582,8 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti
return QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/media-volume-16.png"));
case SP_MediaVolumeMuted:
return QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/media-volume-muted-16.png"));
+ case SP_LineEditClearButton:
+ return QPixmap(clearText16IconPath());
#endif // QT_NO_IMAGEFORMAT_PNG
default:
break;
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 56531b10de..d28bd644c6 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -2933,7 +2933,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
QImage img;
QSize pixmapSize = opt->rect.size();
- if (pixmapSize.isValid()) {
+ if (!pixmapSize.isEmpty()) {
QPixmap pix(pixmapSize);
pix.fill(QColor(fillR, fillG, fillB));
QPainter pix_paint(&pix);
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index d72a898ee9..93bc00f662 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -733,7 +733,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value State_None Indicates that the widget does not have a state.
\value State_Active Indicates that the widget is active.
- \value State_AutoRaise Used to indicate if auto-raise appearance should be usd on a tool button.
+ \value State_AutoRaise Used to indicate if auto-raise appearance should be used on a tool button.
\value State_Children Used to indicate if an item view branch has children.
\value State_DownArrow Used to indicate if a down arrow should be visible on the widget.
\value State_Editing Used to indicate if an editor is opened on the widget.
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 5425644b41..3006f0c9ce 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -1044,6 +1044,10 @@ void QCompleter::setModel(QAbstractItemModel *model)
{
Q_D(QCompleter);
QAbstractItemModel *oldModel = d->proxy->sourceModel();
+#ifndef QT_NO_FILESYSTEMMODEL
+ if (qobject_cast<const QFileSystemModel *>(oldModel))
+ setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+#endif
d->proxy->setSourceModel(model);
if (d->popup)
setPopup(d->popup); // set the model and make new connections
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 774f5a708d..5778d16456 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -757,8 +757,7 @@ bool QAbstractSpinBox::event(QEvent *event)
case QEvent::HoverEnter:
case QEvent::HoverLeave:
case QEvent::HoverMove:
- if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
- d->updateHoverControl(he->pos());
+ d->updateHoverControl(static_cast<const QHoverEvent *>(event)->pos());
break;
case QEvent::ShortcutOverride:
if (d->edit->event(event))
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 51e23ca7f9..af178ce8f5 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -2108,9 +2108,9 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi)
if (lineEdit) {
const QString newText = itemText(normalized);
if (lineEdit->text() != newText) {
- lineEdit->setText(newText);
+ lineEdit->setText(newText); // may cause lineEdit -> nullptr (QTBUG-54191)
#ifndef QT_NO_COMPLETER
- if (lineEdit->completer())
+ if (lineEdit && lineEdit->completer())
lineEdit->completer()->setCompletionPrefix(newText);
#endif
}
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index cfba2cc87f..b168c98410 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -52,6 +52,8 @@
#include <qset.h>
#include <qstyle.h>
+#include <algorithm>
+
#ifndef QT_NO_DATETIMEEDIT
//#define QDATETIMEEDIT_QDTEDEBUG
@@ -246,9 +248,10 @@ void QDateTimeEdit::setDateTime(const QDateTime &datetime)
Q_D(QDateTimeEdit);
if (datetime.isValid()) {
d->clearCache();
+ const QDate date = datetime.date();
if (!(d->sections & DateSections_Mask))
- setDateRange(datetime.date(), datetime.date());
- d->setValue(QDateTime(datetime.date(), datetime.time(), d->spec), EmitIfChanged);
+ setDateRange(date, date);
+ d->setValue(QDateTime(date, datetime.time(), d->spec), EmitIfChanged);
}
}
@@ -861,14 +864,6 @@ QString QDateTimeEdit::displayFormat() const
return isRightToLeft() ? d->unreversedFormat : d->displayFormat;
}
-template<typename C> static inline C reverse(const C &l)
-{
- C ret;
- for (int i=l.size() - 1; i>=0; --i)
- ret.append(l.at(i));
- return ret;
-}
-
void QDateTimeEdit::setDisplayFormat(const QString &format)
{
Q_D(QDateTimeEdit);
@@ -882,8 +877,8 @@ void QDateTimeEdit::setDisplayFormat(const QString &format)
d->displayFormat += d->sectionNode(i).format();
}
d->displayFormat += d->separators.at(0);
- d->separators = reverse(d->separators);
- d->sectionNodes = reverse(d->sectionNodes);
+ std::reverse(d->separators.begin(), d->separators.end());
+ std::reverse(d->sectionNodes.begin(), d->sectionNodes.end());
}
d->formatExplicitlySet = true;
@@ -1776,15 +1771,18 @@ void QDateTimeEditPrivate::setSelected(int sectionIndex, bool forward)
int QDateTimeEditPrivate::sectionAt(int pos) const
{
- if (pos < separators.first().size()) {
+ if (pos < separators.first().size())
return (pos == 0 ? FirstSectionIndex : NoSectionIndex);
- } else if (displayText().size() - pos < separators.last().size() + 1) {
+
+ const QString text = displayText();
+ const int textSize = text.size();
+ if (textSize - pos < separators.last().size() + 1) {
if (separators.last().size() == 0) {
return sectionNodes.count() - 1;
}
- return (pos == displayText().size() ? LastSectionIndex : NoSectionIndex);
+ return (pos == textSize ? LastSectionIndex : NoSectionIndex);
}
- updateCache(value, displayText());
+ updateCache(value, text);
for (int i=0; i<sectionNodes.size(); ++i) {
const int tmp = sectionPos(i);
@@ -1805,12 +1803,14 @@ int QDateTimeEditPrivate::sectionAt(int pos) const
int QDateTimeEditPrivate::closestSection(int pos, bool forward) const
{
Q_ASSERT(pos >= 0);
- if (pos < separators.first().size()) {
+ if (pos < separators.first().size())
return forward ? 0 : FirstSectionIndex;
- } else if (displayText().size() - pos < separators.last().size() + 1) {
+
+ const QString text = displayText();
+ if (text.size() - pos < separators.last().size() + 1)
return forward ? LastSectionIndex : sectionNodes.size() - 1;
- }
- updateCache(value, displayText());
+
+ updateCache(value, text);
for (int i=0; i<sectionNodes.size(); ++i) {
const int tmp = sectionPos(sectionNodes.at(i));
if (pos < tmp + sectionSize(i)) {
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 55e774024a..b347e93807 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -3170,7 +3170,7 @@ void QDockAreaLayout::splitDockWidget(QDockWidget *after,
QDockWidget *dockWidget,
Qt::Orientation orientation)
{
- QList<int> path = indexOf(after);
+ const QList<int> path = indexOf(after);
if (path.isEmpty())
return;
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index d2fa9a7c06..9e95d086bd 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -811,7 +811,8 @@ void QDockWidgetPrivate::endDrag(bool abort)
} else {
setResizerActive(false);
}
- undockedGeometry = q->geometry();
+ if (q->isFloating()) // Might not be floating when dragging a QDockWidgetGroupWindow
+ undockedGeometry = q->geometry();
q->activateWindow();
} else {
// The tab was not plugged back in the QMainWindow but the QDockWidget cannot
diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp
index 1d736c8e96..9bd33409ae 100644
--- a/src/widgets/widgets/qfontcombobox.cpp
+++ b/src/widgets/widgets/qfontcombobox.cpp
@@ -162,7 +162,7 @@ static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool
return QFontDatabase::TraditionalChinese;
}
- system = writingSystems.last();
+ system = writingSystems.constLast();
if (!*hasLatin) {
// we need to show something
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 5dfa439b2e..c31e9750bf 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -1729,10 +1729,20 @@ QMenu *QMainWindow::createPopupMenu()
menu = new QMenu(this);
for (int i = 0; i < dockwidgets.size(); ++i) {
QDockWidget *dockWidget = dockwidgets.at(i);
- if (dockWidget->parentWidget() == this
- && !d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty()) {
- menu->addAction(dockwidgets.at(i)->toggleViewAction());
+ // filter to find out if we own this QDockWidget
+ if (dockWidget->parentWidget() == this) {
+ if (d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty())
+ continue;
+ } else if (QDockWidgetGroupWindow *dwgw =
+ qobject_cast<QDockWidgetGroupWindow *>(dockWidget->parentWidget())) {
+ if (dwgw->parentWidget() != this)
+ continue;
+ if (dwgw->layoutInfo()->indexOf(dockWidget).isEmpty())
+ continue;
+ } else {
+ continue;
}
+ menu->addAction(dockwidgets.at(i)->toggleViewAction());
}
menu->addSeparator();
}
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index ee6da73302..c5b08387a3 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -2384,13 +2384,10 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
QWidget *w = qobject_cast<QWidget*>(c);
if (!w)
continue;
- if (w == widget)
- continue;
- if (!w->isTopLevel() || !w->isVisible() || w->isMinimized())
- continue;
if (!qobject_cast<QDockWidget*>(w) && !qobject_cast<QDockWidgetGroupWindow *>(w))
continue;
- candidates << w;
+ if (w != widget && w->isTopLevel() && w->isVisible() && !w->isMinimized())
+ candidates << w;
if (QDockWidgetGroupWindow *group = qobject_cast<QDockWidgetGroupWindow *>(w)) {
// Sometimes, there are floating QDockWidget that have a QDockWidgetGroupWindow as a parent.
foreach (QObject *c, group->children()) {
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index a5c096c3a8..0daa624ae8 100644
--- a/src/widgets/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
@@ -479,9 +479,8 @@ QString QSpinBox::textFromValue(int value) const
QString str;
if (d->displayIntegerBase != 10) {
- str = QString::number(qAbs(value), d->displayIntegerBase);
- if (value < 0)
- str.prepend('-');
+ const QLatin1String prefix = value < 0 ? QLatin1String("-") : QLatin1String();
+ str = prefix + QString::number(qAbs(value), d->displayIntegerBase);
} else {
str = locale().toString(value);
if (!d->showGroupSeparator && (qAbs(value) >= 1000 || value == INT_MIN)) {
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 77b5a4830b..d5ecb150a8 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -2641,8 +2641,8 @@ void QWidgetTextControl::insertFromMimeData(const QMimeData *source)
#ifndef QT_NO_TEXTHTMLPARSER
if (source->hasFormat(QLatin1String("application/x-qrichtext")) && d->acceptRichText) {
// x-qrichtext is always UTF-8 (taken from Qt3 since we don't use it anymore).
- QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
- richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
+ const QString richtext = QLatin1String("<meta name=\"qrichtext\" content=\"1\" />")
+ + QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
fragment = QTextDocumentFragment::fromHtml(richtext, d->doc);
hasData = true;
} else if (source->hasHtml() && d->acceptRichText) {
diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp
index 1ac0a98cb1..83a7dc800c 100644
--- a/src/winmain/qtmain_winrt.cpp
+++ b/src/winmain/qtmain_winrt.cpp
@@ -307,7 +307,7 @@ private:
if (develMode) {
// Write a PID file to help runner
const QString pidFileName = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation))
- .absoluteFilePath(QString::number(uint(GetCurrentProcessId())) + QStringLiteral(".pid"));
+ .absoluteFilePath(QString::asprintf("%u.pid", uint(GetCurrentProcessId())));
CREATEFILE2_EXTENDED_PARAMETERS params = {
sizeof(CREATEFILE2_EXTENDED_PARAMETERS),
FILE_ATTRIBUTE_NORMAL
diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp
index d4c8519d67..1724076b84 100644
--- a/src/xml/sax/qxml.cpp
+++ b/src/xml/sax/qxml.cpp
@@ -1295,7 +1295,7 @@ static QString extractEncodingDecl(const QString &text, bool *needMoreText)
*needMoreText = false;
int l = text.length();
- QString snip = QString::fromLatin1("<?xml").left(l);
+ const QLatin1String snip("<?xml", std::min(l, 5));
if (l > 0 && !text.startsWith(snip))
return QString();
diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
index 4a5aead17a..de6884d454 100644
--- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
@@ -1197,10 +1197,11 @@ static QTime qTimeData(int index)
case 57: return QTime(23, 59, 59, 99);
case 58: return QTime(23, 59, 59, 100);
case 59: return QTime(23, 59, 59, 999);
+ case 60: return QTime();
}
return QTime(0, 0, 0);
}
-#define MAX_QTIME_DATA 60
+#define MAX_QTIME_DATA 61
void tst_QDataStream::stream_QTime_data()
{
@@ -2786,10 +2787,11 @@ void tst_QDataStream::status_QHash_QMap()
MAP_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x01", 8), QDataStream::ReadPastEnd, QDataStream::ReadPastEnd, StringHash());
}
-#define LIST_TEST(byteArray, expectedStatus, expectedList) \
+#define LIST_TEST(byteArray, initialStatus, expectedStatus, expectedList) \
{ \
QByteArray ba = byteArray; \
QDataStream stream(&ba, QIODevice::ReadOnly); \
+ stream.setStatus(initialStatus); \
stream >> list; \
QCOMPARE((int)stream.status(), (int)expectedStatus); \
QCOMPARE(list.size(), expectedList.size()); \
@@ -2801,6 +2803,7 @@ void tst_QDataStream::status_QHash_QMap()
expectedLinkedList << expectedList.at(i); \
QByteArray ba = byteArray; \
QDataStream stream(&ba, QIODevice::ReadOnly); \
+ stream.setStatus(initialStatus); \
stream >> linkedList; \
QCOMPARE((int)stream.status(), (int)expectedStatus); \
QCOMPARE(linkedList.size(), expectedLinkedList.size()); \
@@ -2812,6 +2815,7 @@ void tst_QDataStream::status_QHash_QMap()
expectedVector << expectedList.at(i); \
QByteArray ba = byteArray; \
QDataStream stream(&ba, QIODevice::ReadOnly); \
+ stream.setStatus(initialStatus); \
stream >> vector; \
QCOMPARE((int)stream.status(), (int)expectedStatus); \
QCOMPARE(vector.size(), expectedVector.size()); \
@@ -2827,8 +2831,49 @@ void tst_QDataStream::status_QLinkedList_QList_QVector()
List list;
Vector vector;
- LIST_TEST(QByteArray(), QDataStream::ReadPastEnd, List());
- LIST_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, List());
+ // ok
+ {
+ List listWithEmptyString;
+ listWithEmptyString.append("");
+
+ List someList;
+ someList.append("J");
+ someList.append("MN");
+
+ LIST_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, QDataStream::Ok, List());
+ LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00", 8), QDataStream::Ok, QDataStream::Ok, listWithEmptyString);
+ LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x02\x00J"
+ "\x00\x00\x00\x04\x00M\x00N", 18), QDataStream::Ok, QDataStream::Ok, someList);
+ }
+
+ // past end
+ {
+ LIST_TEST(QByteArray(), QDataStream::Ok, QDataStream::ReadPastEnd, List());
+ LIST_TEST(QByteArray("\x00", 1), QDataStream::Ok, QDataStream::ReadPastEnd, List());
+ LIST_TEST(QByteArray("\x00\x00", 2), QDataStream::Ok, QDataStream::ReadPastEnd, List());
+ LIST_TEST(QByteArray("\x00\x00\x00", 3), QDataStream::Ok, QDataStream::ReadPastEnd, List());
+ LIST_TEST(QByteArray("\x00\x00\x00\x01", 4), QDataStream::Ok, QDataStream::ReadPastEnd, List());
+ for (int i = 4; i < 12; ++i) {
+ LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00", i), QDataStream::Ok, QDataStream::ReadPastEnd, List());
+ }
+ }
+
+ // corrupt data
+ {
+ LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x01", 8), QDataStream::Ok, QDataStream::ReadCorruptData, List());
+ LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x01\x00J"
+ "\x00\x00\x00\x02\x00M\x00N", 18), QDataStream::Ok, QDataStream::ReadCorruptData, List());
+ }
+
+ // test the previously latched error status is not affected by reading
+ {
+ List listWithEmptyString;
+ listWithEmptyString.append("");
+
+ LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00", 8), QDataStream::ReadPastEnd, QDataStream::ReadPastEnd, listWithEmptyString);
+ LIST_TEST(QByteArray("\x00\x00\x00\x01", 4), QDataStream::ReadCorruptData, QDataStream::ReadCorruptData, List());
+ LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x01", 8), QDataStream::ReadPastEnd, QDataStream::ReadPastEnd, List());
+ }
}
void tst_QDataStream::streamToAndFromQByteArray()
@@ -3061,6 +3106,30 @@ void tst_QDataStream::compatibility_Qt3()
QCOMPARE(in_palette.brush(QPalette::Button).style(), Qt::NoBrush);
QCOMPARE(in_palette.color(QPalette::Light), QColor(Qt::green));
}
+ // QTime() was serialized to (0, 0, 0, 0) in Qt3, not (0xFF, 0xFF, 0xFF, 0xFF)
+ // This is because in Qt3 a null time was valid, and there was no support for deserializing a value of -1.
+ {
+ QByteArray stream;
+ {
+ QDataStream out(&stream, QIODevice::WriteOnly);
+ out.setVersion(QDataStream::Qt_3_3);
+ out << QTime();
+ }
+ QTime in_time;
+ {
+ QDataStream in(stream);
+ in.setVersion(QDataStream::Qt_3_3);
+ in >> in_time;
+ }
+ QVERIFY(in_time.isNull());
+
+ quint32 rawValue;
+ QDataStream in(stream);
+ in.setVersion(QDataStream::Qt_3_3);
+ in >> rawValue;
+ QCOMPARE(rawValue, quint32(0));
+ }
+
}
void tst_QDataStream::compatibility_Qt2()
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 73672f3572..e982660bef 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -120,7 +120,8 @@ private slots:
void isValid();
void schemeValidator_data();
void schemeValidator();
- void invalidSchemeValidator();
+ void setScheme_data();
+ void setScheme();
void strictParser_data();
void strictParser();
void tolerantParser();
@@ -2077,87 +2078,114 @@ void tst_QUrl::isValid()
void tst_QUrl::schemeValidator_data()
{
- QTest::addColumn<QByteArray>("encodedUrl");
+ QTest::addColumn<QString>("input");
QTest::addColumn<bool>("result");
- QTest::addColumn<QString>("toString");
-
- QTest::newRow("empty") << QByteArray() << false << QString();
-
- // ftp
- QTest::newRow("ftp:") << QByteArray("ftp:") << true << QString("ftp:");
- QTest::newRow("ftp://ftp.qt-project.org")
- << QByteArray("ftp://ftp.qt-project.org")
- << true << QString("ftp://ftp.qt-project.org");
- QTest::newRow("ftp://ftp.qt-project.org/")
- << QByteArray("ftp://ftp.qt-project.org/")
- << true << QString("ftp://ftp.qt-project.org/");
- QTest::newRow("ftp:/index.html")
- << QByteArray("ftp:/index.html")
- << false << QString();
-
- // mailto
- QTest::newRow("mailto:") << QByteArray("mailto:") << true << QString("mailto:");
- QTest::newRow("mailto://smtp.trolltech.com/ole@bull.name")
- << QByteArray("mailto://smtp.trolltech.com/ole@bull.name") << false << QString();
- QTest::newRow("mailto:") << QByteArray("mailto:") << true << QString("mailto:");
- QTest::newRow("mailto:ole@bull.name")
- << QByteArray("mailto:ole@bull.name") << true << QString("mailto:ole@bull.name");
+ QTest::addColumn<QString>("scheme");
- // file
- QTest::newRow("file:") << QByteArray("file:/etc/passwd") << true << QString("file:///etc/passwd");
+ // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
+
+ QTest::newRow("empty") << QString() << false << QString();
+
+ // uncontroversial ones
+ QTest::newRow("ftp") << "ftp://ftp.example.com/" << true << "ftp";
+ QTest::newRow("http") << "http://www.example.com/" << true << "http";
+ QTest::newRow("mailto") << "mailto:smith@example.com" << true << "mailto";
+ QTest::newRow("file-1slash") << "file:/etc/passwd" << true << "file";
+ QTest::newRow("file-2slashes") << "file://server/etc/passwd" << true << "file";
+ QTest::newRow("file-3slashes") << "file:///etc/passwd" << true << "file";
+
+ QTest::newRow("mailto+subject") << "mailto:smith@example.com?subject=Hello%20World" << true << "mailto";
+ QTest::newRow("mailto+host") << "mailto://smtp.example.com/smith@example.com" << true << "mailto";
+
+ // valid, but unexpected
+ QTest::newRow("ftp-nohost") << "ftp:/etc/passwd" << true << "ftp";
+ QTest::newRow("http-nohost") << "http:/etc/passwd" << true << "http";
+ QTest::newRow("mailto-nomail") << "mailto://smtp.example.com" << true << "mailto";
+
+ // schemes with numbers
+ QTest::newRow("digits") << "proto2://" << true << "proto2";
+
+ // schemes with dots, dashes, and pluses
+ QTest::newRow("svn+ssh") << "svn+ssh://svn.example.com" << true << "svn+ssh";
+ QTest::newRow("withdash") << "svn-ssh://svn.example.com" << true << "svn-ssh";
+ QTest::newRow("withdots") << "org.qt-project://qt-project.org" << true << "org.qt-project";
+
+ // lowercasing
+ QTest::newRow("FTP") << "FTP://ftp.example.com/" << true << "ftp";
+ QTest::newRow("HTTP") << "HTTP://www.example.com/" << true << "http";
+ QTest::newRow("MAILTO") << "MAILTO:smith@example.com" << true << "mailto";
+ QTest::newRow("FILE") << "FILE:/etc/passwd" << true << "file";
+ QTest::newRow("SVN+SSH") << "SVN+SSH://svn.example.com" << true << "svn+ssh";
+ QTest::newRow("WITHDASH") << "SVN-SSH://svn.example.com" << true << "svn-ssh";
+ QTest::newRow("WITHDOTS") << "ORG.QT-PROJECT://qt-project.org" << true << "org.qt-project";
+
+ // invalid entries
+ QTest::newRow("start-digit") << "1http://example.com" << false << "1http";
+ QTest::newRow("start-plus") << "+ssh://user@example.com" << false << "+ssh";
+ QTest::newRow("start-dot") << ".org.example:///" << false << ".org.example";
+ QTest::newRow("with-space") << "a b://" << false << "a b";
+ QTest::newRow("with-non-ascii") << "\304\245\305\243\305\245\321\200://example.com" << false << "\304\245\305\243\305\245\321\200";
+ QTest::newRow("with-control1") << "http\1://example.com" << false << "http\1";
+ QTest::newRow("with-control127") << "http\177://example.com" << false << "http\177";
+ QTest::newRow("with-null") << QString::fromLatin1("http\0://example.com", 19) << false << QString::fromLatin1("http\0", 5);
+
+ QTest::newRow("percent-encoded") << "%68%74%%74%70://example.com" << false << "%68%74%%74%70";
+
+ static const char controls[] = "!\"$&'()*,;<=>[\\]^_`{|}~";
+ for (size_t i = 0; i < sizeof(controls) - 1; ++i)
+ QTest::newRow(("with-" + QByteArray(1, controls[i])).constData())
+ << QString("pre%1post://example.com/").arg(QLatin1Char(controls[i]))
+ << false << QString("pre%1post").arg(QLatin1Char(controls[i]));
}
void tst_QUrl::schemeValidator()
{
- QFETCH(QByteArray, encodedUrl);
+ QFETCH(QString, input);
QFETCH(bool, result);
- QFETCH(QString, toString);
- QUrl url = QUrl::fromEncoded(encodedUrl);
- QEXPECT_FAIL("ftp:/index.html", "high-level URL validation not reimplemented yet", Abort);
- QEXPECT_FAIL("mailto://smtp.trolltech.com/ole@bull.name", "high-level URL validation not reimplemented yet", Abort);
+ QUrl url(input);
QCOMPARE(url.isValid(), result);
- if (!result)
- QVERIFY(url.toString().isEmpty());
-}
+ if (result) {
+ QFETCH(QString, scheme);
+ QCOMPARE(url.scheme(), scheme);
-void tst_QUrl::invalidSchemeValidator()
-{
- // test that if scheme does not start with an ALPHA, QUrl::isValid() returns false
- {
- QUrl url("1http://qt-project.org");
- QVERIFY(url.scheme().isEmpty());
- QVERIFY(url.path().startsWith("1http"));
- }
- {
- QUrl url("http://qt-project.org");
- url.setScheme("111http://qt-project.org");
- QCOMPARE(url.isValid(), false);
- QVERIFY(url.toString().isEmpty());
- }
- // non-ALPHA character at other positions in the scheme are ok
- {
- QUrl url("ht111tp://qt-project.org", QUrl::StrictMode);
+ // reconstruct with just the scheme:
+ url.setUrl(scheme + ':');
QVERIFY(url.isValid());
- QCOMPARE(url.scheme(), QString("ht111tp"));
- QVERIFY(!url.toString().isEmpty());
- }
- {
- QUrl url("http://qt-project.org");
- url.setScheme("ht123tp://qt-project.org");
- QVERIFY(!url.isValid());
+ QCOMPARE(url.scheme(), scheme);
+ } else {
QVERIFY(url.toString().isEmpty());
- url.setScheme("http");
- QVERIFY(url.isValid());
- QVERIFY(!url.toString().isEmpty());
- }
- {
- QUrl url = QUrl::fromEncoded("ht321tp://qt-project.org", QUrl::StrictMode);
- QVERIFY(url.isValid());
- QVERIFY(!url.toString().isEmpty());
}
}
+void tst_QUrl::setScheme_data()
+{
+ schemeValidator_data();
+
+ // a couple more which wouldn't work in parsing a full URL
+ QTest::newRow("with-slash") << QString() << false << "http/";
+ QTest::newRow("with-question") << QString() << false << "http?";
+ QTest::newRow("with-hash") << QString() << false << "http#";
+}
+
+void tst_QUrl::setScheme()
+{
+ QFETCH(QString, scheme);
+ QFETCH(bool, result);
+ QString expectedScheme;
+ if (result)
+ expectedScheme = scheme;
+
+ QUrl url;
+ url.setScheme(scheme);
+ QCOMPARE(url.isValid(), result);
+ QCOMPARE(url.scheme(), expectedScheme);
+
+ url.setScheme(scheme.toUpper());
+ QCOMPARE(url.isValid(), result);
+ QCOMPARE(url.scheme(), expectedScheme);
+}
+
void tst_QUrl::strictParser_data()
{
QTest::addColumn<QString>("input");
diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
index 7cdee891bb..1a70ac5e75 100644
--- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
+++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
@@ -40,6 +40,8 @@ class tst_QHashFunctions : public QObject
Q_OBJECT
private Q_SLOTS:
void qhash();
+ void qhash_of_empty_and_null_qstring();
+ void qhash_of_empty_and_null_qbytearray();
void fp_qhash_of_zero_is_zero();
void qthash_data();
void qthash();
@@ -128,6 +130,20 @@ void tst_QHashFunctions::qhash()
}
}
+void tst_QHashFunctions::qhash_of_empty_and_null_qstring()
+{
+ QString null, empty("");
+ QCOMPARE(null, empty);
+ QCOMPARE(qHash(null), qHash(empty));
+}
+
+void tst_QHashFunctions::qhash_of_empty_and_null_qbytearray()
+{
+ QByteArray null, empty("");
+ QCOMPARE(null, empty);
+ QCOMPARE(qHash(null), qHash(empty));
+}
+
void tst_QHashFunctions::fp_qhash_of_zero_is_zero()
{
QCOMPARE(qHash(-0.0f), 0U);
diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp
index fb0986d05b..1d5f7536c8 100644
--- a/tests/auto/corelib/tools/qpair/tst_qpair.cpp
+++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp
@@ -35,6 +35,7 @@ class tst_QPair : public QObject
{
Q_OBJECT
private Q_SLOTS:
+ void pairOfReferences();
void testConstexpr();
void testConversions();
void taskQTBUG_48780_pairContainingCArray();
@@ -91,6 +92,35 @@ Q_STATIC_ASSERT(!QTypeInfo<QPairPP>::isDummy );
Q_STATIC_ASSERT(!QTypeInfo<QPairPP>::isPointer);
+void tst_QPair::pairOfReferences()
+{
+ int i = 0;
+ QString s;
+
+ QPair<int&, QString&> p(i, s);
+
+ p.first = 1;
+ QCOMPARE(i, 1);
+
+ i = 2;
+ QCOMPARE(p.first, 2);
+
+ p.second = QLatin1String("Hello");
+ QCOMPARE(s, QLatin1String("Hello"));
+
+ s = QLatin1String("olleH");
+ QCOMPARE(p.second, QLatin1String("olleH"));
+
+ QPair<int&, QString&> q = p;
+ q.first = 3;
+ QCOMPARE(i, 3);
+ QCOMPARE(p.first, 3);
+
+ q.second = QLatin1String("World");
+ QCOMPARE(s, QLatin1String("World"));
+ QCOMPARE(p.second, QLatin1String("World"));
+}
+
void tst_QPair::testConstexpr()
{
Q_CONSTEXPR QPair<int, double> pID = qMakePair(0, 0.0);
diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
index 7bd732379d..c212589f59 100644
--- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
+++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
@@ -206,9 +206,9 @@ void tst_QRingBuffer::free()
ringBuffer.append(QByteArray("01234", 5));
ringBuffer.free(1);
- QCOMPARE(ringBuffer.size(), Q_INT64_C(4095 + 2048 + 5));
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(4095) + 2048 + 5);
ringBuffer.free(4096);
- QCOMPARE(ringBuffer.size(), Q_INT64_C(2047 + 5));
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(2047) + 5);
ringBuffer.free(48);
ringBuffer.free(2000);
QCOMPARE(ringBuffer.size(), Q_INT64_C(4));
@@ -268,9 +268,9 @@ void tst_QRingBuffer::chop()
ringBuffer.reserve(4096);
ringBuffer.chop(1);
- QCOMPARE(ringBuffer.size(), Q_INT64_C(5 + 2048 + 4095));
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(5) + 2048 + 4095);
ringBuffer.chop(4096);
- QCOMPARE(ringBuffer.size(), Q_INT64_C(5 + 2047));
+ QCOMPARE(ringBuffer.size(), Q_INT64_C(5) + 2047);
ringBuffer.chop(48);
ringBuffer.chop(2000);
QCOMPARE(ringBuffer.size(), Q_INT64_C(4));
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 641ca0d25e..6df9ad7cdf 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -352,7 +352,7 @@ private slots:
void replace_qchar_qstring();
void replace_uint_uint_data();
void replace_uint_uint();
- void replace_uint_uint_extra();
+ void replace_extra();
void replace_string_data();
void replace_string();
void replace_regexp_data();
@@ -475,6 +475,8 @@ private slots:
void sprintfS();
void fill();
void truncate();
+ void chop_data();
+ void chop();
void constructor();
void constructorQByteArray_data();
void constructorQByteArray();
@@ -1211,6 +1213,31 @@ void tst_QString::truncate()
}
+void tst_QString::chop_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<int>("count" );
+ QTest::addColumn<QString>("result");
+
+ const QString original("abcd");
+
+ QTest::newRow("data0") << original << 1 << QString("abc");
+ QTest::newRow("data1") << original << 0 << original;
+ QTest::newRow("data2") << original << -1 << original;
+ QTest::newRow("data3") << original << original.size() << QString();
+ QTest::newRow("data4") << original << 1000 << QString();
+}
+
+void tst_QString::chop()
+{
+ QFETCH(QString, input);
+ QFETCH(int, count);
+ QFETCH(QString, result);
+
+ input.chop(count);
+ QCOMPARE(input, result);
+}
+
void tst_QString::fill()
{
QString e;
@@ -2776,7 +2803,7 @@ void tst_QString::replace_uint_uint()
}
}
-void tst_QString::replace_uint_uint_extra()
+void tst_QString::replace_extra()
{
/*
This test is designed to be extremely slow if QString::replace() doesn't optimize the case
@@ -2813,6 +2840,44 @@ void tst_QString::replace_uint_uint_extra()
QString str5("abcdefghij");
str5.replace(8, 10, str5);
QCOMPARE(str5, QString("abcdefghabcdefghij"));
+
+ // Replacements using only part of the string modified:
+ QString str6("abcdefghij");
+ str6.replace(1, 8, str6.constData() + 3, 3);
+ QCOMPARE(str6, QString("adefj"));
+
+ QString str7("abcdefghibcdefghij");
+ str7.replace(str7.constData() + 1, 6, str7.constData() + 2, 3);
+ QCOMPARE(str7, QString("acdehicdehij"));
+
+ const int many = 1024;
+ /*
+ QS::replace(const QChar *, int, const QChar *, int, Qt::CaseSensitivity)
+ does its replacements in batches of many (please keep in sync with any
+ changes to batch size), which lead to misbehaviour if ether QChar * array
+ was part of the data being modified.
+ */
+ QString str8("abcdefg"), ans8("acdeg");
+ {
+ // Make str8 and ans8 repeat themselves many + 1 times:
+ int i = many;
+ QString big(str8), small(ans8);
+ while (i && !(i & 1)) { // Exploit many being a power of 2:
+ big += big;
+ small += small;
+ i >>= 1;
+ }
+ while (i-- > 0) {
+ str8 += big;
+ ans8 += small;
+ }
+ }
+ str8.replace(str8.constData() + 1, 5, str8.constData() + 2, 3);
+ // Pre-test the bit where the diff happens, so it gets displayed:
+ QCOMPARE(str8.mid((many - 3) * 5), ans8.mid((many - 3) * 5));
+ // Also check the full values match, of course:
+ QCOMPARE(str8.size(), ans8.size());
+ QCOMPARE(str8, ans8);
}
void tst_QString::replace_string()
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index ca57f1468a..43e05c95f9 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -7307,7 +7307,11 @@ void tst_QNetworkReply::qtbug45581WrongReplyStatusCode()
const QByteArray expectedContent =
"<root attr=\"value\" attr2=\"value2\">"
- "<person /><fruit /></root>\n";
+ "<person /><fruit /></root>"
+#ifdef Q_OS_WIN
+ "\r"
+#endif
+ "\n";
QCOMPARE(reply->readAll(), expectedContent);
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 382fbf08a8..6bb502edcb 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -1213,6 +1213,12 @@ void tst_QTcpSocket::connectDisconnectConnectDisconnect()
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
QCOMPARE(socket->socketType(), QTcpSocket::TcpSocket);
+ QCOMPARE(socket->socketDescriptor(), qintptr(-1));
+ QCOMPARE(int(socket->localPort()), 0);
+ QCOMPARE(socket->localAddress(), QHostAddress());
+ QCOMPARE(int(socket->peerPort()), 0);
+ QCOMPARE(socket->peerAddress(), QHostAddress());
+
socket->connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket->waitForReadyRead(10000));
QCOMPARE(QString::fromLatin1(socket->read(4)), QString("* OK"));
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
index ccc31cf2d3..97eb19599b 100644
--- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
@@ -142,6 +142,8 @@ private slots:
void compareQPixmaps_data();
void compareQImages();
void compareQImages_data();
+ void compareQRegion_data();
+ void compareQRegion();
#endif
void verify();
void verify2();
@@ -429,6 +431,29 @@ void tst_Cmptest::compareQImages()
QCOMPARE(opA, opB);
}
+
+void tst_Cmptest::compareQRegion_data()
+{
+ QTest::addColumn<QRegion>("rA");
+ QTest::addColumn<QRegion>("rB");
+ const QRect rect1(QPoint(10, 10), QSize(200, 50));
+ const QRegion region1(rect1);
+ QRegion listRegion2;
+ const QVector<QRect> list2 = QVector<QRect>() << QRect(QPoint(100, 200), QSize(50, 200)) << rect1;
+ listRegion2.setRects(list2.constData(), list2.size());
+ QTest::newRow("equal-empty") << QRegion() << QRegion();
+ QTest::newRow("1-empty") << region1 << QRegion();
+ QTest::newRow("equal") << region1 << region1;
+ QTest::newRow("different lists") << region1 << listRegion2;
+}
+
+void tst_Cmptest::compareQRegion()
+{
+ QFETCH(QRegion, rA);
+ QFETCH(QRegion, rB);
+
+ QCOMPARE(rA, rB);
+}
#endif // QT_GUI_LIB
static int opaqueFunc()
diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml
index 89055a3a91..621aceb887 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.lightxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml
@@ -8,13 +8,13 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_unregistered_enums">
-<Incident type="fail" file="tst_cmptest.cpp" line="158">
+<Incident type="fail" file="tst_cmptest.cpp" line="160">
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_registered_enums">
-<Incident type="fail" file="tst_cmptest.cpp" line="164">
+<Incident type="fail" file="tst_cmptest.cpp" line="167">
<Description><![CDATA[Compared values are not the same
Actual (Qt::Monday): Monday
Expected (Qt::Sunday): Sunday]]></Description>
@@ -22,7 +22,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_class_enums">
-<Incident type="fail" file="tst_cmptest.cpp" line="170">
+<Incident type="fail" file="tst_cmptest.cpp" line="173">
<Description><![CDATA[Compared values are not the same
Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1
Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2]]></Description>
@@ -42,7 +42,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_tostring">
-<Incident type="fail" file="tst_cmptest.cpp" line="259">
+<Incident type="fail" file="tst_cmptest.cpp" line="262">
<DataTag><![CDATA[int, string]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(int,123)
@@ -51,19 +51,19 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both invalid]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="259">
+<Incident type="fail" file="tst_cmptest.cpp" line="262">
<DataTag><![CDATA[null hash, invalid]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QVariantHash)
Expected (expected): QVariant()]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="259">
+<Incident type="fail" file="tst_cmptest.cpp" line="262">
<DataTag><![CDATA[string, null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QString,A simple string)
Expected (expected): QVariant(PhonyClass)]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="259">
+<Incident type="fail" file="tst_cmptest.cpp" line="262">
<DataTag><![CDATA[both non-null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(PhonyClass,<value not representable as string>)
@@ -78,31 +78,31 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal lists]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[second-last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[prefix]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 2
Expected (opB) size: 1]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[short list second]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 12
Expected (opB) size: 1]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[short list first]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 1
@@ -111,7 +111,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQListInt">
-<Incident type="fail" file="tst_cmptest.cpp" line="360">
+<Incident type="fail" file="tst_cmptest.cpp" line="363">
<Description><![CDATA[Compared lists differ at index 2.
Actual (int1): 3
Expected (int2): 4]]></Description>
@@ -119,7 +119,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQListDouble">
-<Incident type="fail" file="tst_cmptest.cpp" line="367">
+<Incident type="fail" file="tst_cmptest.cpp" line="370">
<Description><![CDATA[Compared lists differ at index 0.
Actual (double1): 1.5
Expected (double2): 1]]></Description>
@@ -127,7 +127,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQColor">
-<Incident type="fail" file="tst_cmptest.cpp" line="377">
+<Incident type="fail" file="tst_cmptest.cpp" line="380">
<Description><![CDATA[Compared values are not the same
Actual (yellow): #ffff00
Expected (green) : #00ff00]]></Description>
@@ -138,13 +138,13 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="402">
+<Incident type="fail" file="tst_cmptest.cpp" line="405">
<DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="402">
+<Incident type="fail" file="tst_cmptest.cpp" line="405">
<DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 0
@@ -153,13 +153,13 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="402">
+<Incident type="fail" file="tst_cmptest.cpp" line="405">
<DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ in size.
Actual (opA): 11x20
Expected (opB): 20x20]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="402">
+<Incident type="fail" file="tst_cmptest.cpp" line="405">
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
@@ -169,13 +169,13 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 0
@@ -184,44 +184,65 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QImages differ in size.
Actual (opA): 11x20
Expected (opB): 20x20]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[different format]]></DataTag>
<Description><![CDATA[Compared QImages differ in format.
Actual (opA): 6
Expected (opB): 3]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
+<TestFunction name="compareQRegion">
+<Incident type="pass" file="" line="0">
+ <DataTag><![CDATA[equal-empty]]></DataTag>
+</Incident>
+<Incident type="fail" file="tst_cmptest.cpp" line="455">
+ <DataTag><![CDATA[1-empty]]></DataTag>
+ <Description><![CDATA[Compared values are not the same
+ Actual (rA): QRegion(200x50+10+10)
+ Expected (rB): QRegion(null)]]></Description>
+</Incident>
+<Incident type="pass" file="" line="0">
+ <DataTag><![CDATA[equal]]></DataTag>
+</Incident>
+<Incident type="fail" file="tst_cmptest.cpp" line="455">
+ <DataTag><![CDATA[different lists]]></DataTag>
+ <Description><![CDATA[Compared values are not the same
+ Actual (rA): QRegion(200x50+10+10)
+ Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
<TestFunction name="verify">
-<Incident type="fail" file="tst_cmptest.cpp" line="441">
+<Incident type="fail" file="tst_cmptest.cpp" line="467">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="verify2">
-<Incident type="fail" file="tst_cmptest.cpp" line="447">
+<Incident type="fail" file="tst_cmptest.cpp" line="473">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="tryVerify">
-<Incident type="fail" file="tst_cmptest.cpp" line="453">
+<Incident type="fail" file="tst_cmptest.cpp" line="479">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="tryVerify2">
-<Incident type="fail" file="tst_cmptest.cpp" line="459">
+<Incident type="fail" file="tst_cmptest.cpp" line="485">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
</Incident>
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.teamcity b/tests/auto/testlib/selftests/expected_cmptest.teamcity
index 035907ab63..8801e05e6e 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.teamcity
+++ b/tests/auto/testlib/selftests/expected_cmptest.teamcity
@@ -2,13 +2,13 @@
##teamcity[testStarted name='initTestCase()']
##teamcity[testFinished name='initTestCase()']
##teamcity[testStarted name='compare_unregistered_enums()']
-##teamcity[testFailed name='compare_unregistered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(158)|]' details='Compared values are not the same']
+##teamcity[testFailed name='compare_unregistered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(160)|]' details='Compared values are not the same']
##teamcity[testFinished name='compare_unregistered_enums()']
##teamcity[testStarted name='compare_registered_enums()']
-##teamcity[testFailed name='compare_registered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(164)|]' details='Compared values are not the same|n Actual (Qt::Monday): Monday|n Expected (Qt::Sunday): Sunday']
+##teamcity[testFailed name='compare_registered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(167)|]' details='Compared values are not the same|n Actual (Qt::Monday): Monday|n Expected (Qt::Sunday): Sunday']
##teamcity[testFinished name='compare_registered_enums()']
##teamcity[testStarted name='compare_class_enums()']
-##teamcity[testFailed name='compare_class_enums()' message='Failure! |[Loc: tst_cmptest.cpp(170)|]' details='Compared values are not the same|n Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1|n Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2']
+##teamcity[testFailed name='compare_class_enums()' message='Failure! |[Loc: tst_cmptest.cpp(173)|]' details='Compared values are not the same|n Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1|n Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2']
##teamcity[testFinished name='compare_class_enums()']
##teamcity[testStarted name='compare_boolfuncs()']
##teamcity[testFinished name='compare_boolfuncs()']
@@ -17,93 +17,103 @@
##teamcity[testStarted name='compare_pointerfuncs()']
##teamcity[testFinished name='compare_pointerfuncs()']
##teamcity[testStarted name='compare_tostring(int, string)']
-##teamcity[testFailed name='compare_tostring(int, string)' message='Failure! |[Loc: tst_cmptest.cpp(259)|]' details='Compared values are not the same|n Actual (actual) : QVariant(int,123)|n Expected (expected): QVariant(QString,hi)']
+##teamcity[testFailed name='compare_tostring(int, string)' message='Failure! |[Loc: tst_cmptest.cpp(262)|]' details='Compared values are not the same|n Actual (actual) : QVariant(int,123)|n Expected (expected): QVariant(QString,hi)']
##teamcity[testFinished name='compare_tostring(int, string)']
##teamcity[testStarted name='compare_tostring(both invalid)']
##teamcity[testFinished name='compare_tostring(both invalid)']
##teamcity[testStarted name='compare_tostring(null hash, invalid)']
-##teamcity[testFailed name='compare_tostring(null hash, invalid)' message='Failure! |[Loc: tst_cmptest.cpp(259)|]' details='Compared values are not the same|n Actual (actual) : QVariant(QVariantHash)|n Expected (expected): QVariant()']
+##teamcity[testFailed name='compare_tostring(null hash, invalid)' message='Failure! |[Loc: tst_cmptest.cpp(262)|]' details='Compared values are not the same|n Actual (actual) : QVariant(QVariantHash)|n Expected (expected): QVariant()']
##teamcity[testFinished name='compare_tostring(null hash, invalid)']
##teamcity[testStarted name='compare_tostring(string, null user type)']
-##teamcity[testFailed name='compare_tostring(string, null user type)' message='Failure! |[Loc: tst_cmptest.cpp(259)|]' details='Compared values are not the same|n Actual (actual) : QVariant(QString,A simple string)|n Expected (expected): QVariant(PhonyClass)']
+##teamcity[testFailed name='compare_tostring(string, null user type)' message='Failure! |[Loc: tst_cmptest.cpp(262)|]' details='Compared values are not the same|n Actual (actual) : QVariant(QString,A simple string)|n Expected (expected): QVariant(PhonyClass)']
##teamcity[testFinished name='compare_tostring(string, null user type)']
##teamcity[testStarted name='compare_tostring(both non-null user type)']
-##teamcity[testFailed name='compare_tostring(both non-null user type)' message='Failure! |[Loc: tst_cmptest.cpp(259)|]' details='Compared values are not the same|n Actual (actual) : QVariant(PhonyClass,<value not representable as string>)|n Expected (expected): QVariant(PhonyClass,<value not representable as string>)']
+##teamcity[testFailed name='compare_tostring(both non-null user type)' message='Failure! |[Loc: tst_cmptest.cpp(262)|]' details='Compared values are not the same|n Actual (actual) : QVariant(PhonyClass,<value not representable as string>)|n Expected (expected): QVariant(PhonyClass,<value not representable as string>)']
##teamcity[testFinished name='compare_tostring(both non-null user type)']
##teamcity[testStarted name='compareQStringLists(empty lists)']
##teamcity[testFinished name='compareQStringLists(empty lists)']
##teamcity[testStarted name='compareQStringLists(equal lists)']
##teamcity[testFinished name='compareQStringLists(equal lists)']
##teamcity[testStarted name='compareQStringLists(last item different)']
-##teamcity[testFailed name='compareQStringLists(last item different)' message='Failure! |[Loc: tst_cmptest.cpp(353)|]' details='Compared lists differ at index 2.|n Actual (opA): "string3"|n Expected (opB): "DIFFERS"']
+##teamcity[testFailed name='compareQStringLists(last item different)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists differ at index 2.|n Actual (opA): "string3"|n Expected (opB): "DIFFERS"']
##teamcity[testFinished name='compareQStringLists(last item different)']
##teamcity[testStarted name='compareQStringLists(second-last item different)']
-##teamcity[testFailed name='compareQStringLists(second-last item different)' message='Failure! |[Loc: tst_cmptest.cpp(353)|]' details='Compared lists differ at index 2.|n Actual (opA): "string3"|n Expected (opB): "DIFFERS"']
+##teamcity[testFailed name='compareQStringLists(second-last item different)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists differ at index 2.|n Actual (opA): "string3"|n Expected (opB): "DIFFERS"']
##teamcity[testFinished name='compareQStringLists(second-last item different)']
##teamcity[testStarted name='compareQStringLists(prefix)']
-##teamcity[testFailed name='compareQStringLists(prefix)' message='Failure! |[Loc: tst_cmptest.cpp(353)|]' details='Compared lists have different sizes.|n Actual (opA) size: 2|n Expected (opB) size: 1']
+##teamcity[testFailed name='compareQStringLists(prefix)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists have different sizes.|n Actual (opA) size: 2|n Expected (opB) size: 1']
##teamcity[testFinished name='compareQStringLists(prefix)']
##teamcity[testStarted name='compareQStringLists(short list second)']
-##teamcity[testFailed name='compareQStringLists(short list second)' message='Failure! |[Loc: tst_cmptest.cpp(353)|]' details='Compared lists have different sizes.|n Actual (opA) size: 12|n Expected (opB) size: 1']
+##teamcity[testFailed name='compareQStringLists(short list second)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists have different sizes.|n Actual (opA) size: 12|n Expected (opB) size: 1']
##teamcity[testFinished name='compareQStringLists(short list second)']
##teamcity[testStarted name='compareQStringLists(short list first)']
-##teamcity[testFailed name='compareQStringLists(short list first)' message='Failure! |[Loc: tst_cmptest.cpp(353)|]' details='Compared lists have different sizes.|n Actual (opA) size: 1|n Expected (opB) size: 12']
+##teamcity[testFailed name='compareQStringLists(short list first)' message='Failure! |[Loc: tst_cmptest.cpp(356)|]' details='Compared lists have different sizes.|n Actual (opA) size: 1|n Expected (opB) size: 12']
##teamcity[testFinished name='compareQStringLists(short list first)']
##teamcity[testStarted name='compareQListInt()']
-##teamcity[testFailed name='compareQListInt()' message='Failure! |[Loc: tst_cmptest.cpp(360)|]' details='Compared lists differ at index 2.|n Actual (int1): 3|n Expected (int2): 4']
+##teamcity[testFailed name='compareQListInt()' message='Failure! |[Loc: tst_cmptest.cpp(363)|]' details='Compared lists differ at index 2.|n Actual (int1): 3|n Expected (int2): 4']
##teamcity[testFinished name='compareQListInt()']
##teamcity[testStarted name='compareQListDouble()']
-##teamcity[testFailed name='compareQListDouble()' message='Failure! |[Loc: tst_cmptest.cpp(367)|]' details='Compared lists differ at index 0.|n Actual (double1): 1.5|n Expected (double2): 1']
+##teamcity[testFailed name='compareQListDouble()' message='Failure! |[Loc: tst_cmptest.cpp(370)|]' details='Compared lists differ at index 0.|n Actual (double1): 1.5|n Expected (double2): 1']
##teamcity[testFinished name='compareQListDouble()']
##teamcity[testStarted name='compareQColor()']
-##teamcity[testFailed name='compareQColor()' message='Failure! |[Loc: tst_cmptest.cpp(377)|]' details='Compared values are not the same|n Actual (yellow): #ffff00|n Expected (green) : #00ff00']
+##teamcity[testFailed name='compareQColor()' message='Failure! |[Loc: tst_cmptest.cpp(380)|]' details='Compared values are not the same|n Actual (yellow): #ffff00|n Expected (green) : #00ff00']
##teamcity[testFinished name='compareQColor()']
##teamcity[testStarted name='compareQPixmaps(both null)']
##teamcity[testFinished name='compareQPixmaps(both null)']
##teamcity[testStarted name='compareQPixmaps(one null)']
-##teamcity[testFailed name='compareQPixmaps(one null)' message='Failure! |[Loc: tst_cmptest.cpp(402)|]' details='Compared QPixmaps differ.|n Actual (opA).isNull(): 1|n Expected (opB).isNull(): 0']
+##teamcity[testFailed name='compareQPixmaps(one null)' message='Failure! |[Loc: tst_cmptest.cpp(405)|]' details='Compared QPixmaps differ.|n Actual (opA).isNull(): 1|n Expected (opB).isNull(): 0']
##teamcity[testFinished name='compareQPixmaps(one null)']
##teamcity[testStarted name='compareQPixmaps(other null)']
-##teamcity[testFailed name='compareQPixmaps(other null)' message='Failure! |[Loc: tst_cmptest.cpp(402)|]' details='Compared QPixmaps differ.|n Actual (opA).isNull(): 0|n Expected (opB).isNull(): 1']
+##teamcity[testFailed name='compareQPixmaps(other null)' message='Failure! |[Loc: tst_cmptest.cpp(405)|]' details='Compared QPixmaps differ.|n Actual (opA).isNull(): 0|n Expected (opB).isNull(): 1']
##teamcity[testFinished name='compareQPixmaps(other null)']
##teamcity[testStarted name='compareQPixmaps(equal)']
##teamcity[testFinished name='compareQPixmaps(equal)']
##teamcity[testStarted name='compareQPixmaps(different size)']
-##teamcity[testFailed name='compareQPixmaps(different size)' message='Failure! |[Loc: tst_cmptest.cpp(402)|]' details='Compared QPixmaps differ in size.|n Actual (opA): 11x20|n Expected (opB): 20x20']
+##teamcity[testFailed name='compareQPixmaps(different size)' message='Failure! |[Loc: tst_cmptest.cpp(405)|]' details='Compared QPixmaps differ in size.|n Actual (opA): 11x20|n Expected (opB): 20x20']
##teamcity[testFinished name='compareQPixmaps(different size)']
##teamcity[testStarted name='compareQPixmaps(different pixels)']
-##teamcity[testFailed name='compareQPixmaps(different pixels)' message='Failure! |[Loc: tst_cmptest.cpp(402)|]' details='Compared values are not the same']
+##teamcity[testFailed name='compareQPixmaps(different pixels)' message='Failure! |[Loc: tst_cmptest.cpp(405)|]' details='Compared values are not the same']
##teamcity[testFinished name='compareQPixmaps(different pixels)']
##teamcity[testStarted name='compareQImages(both null)']
##teamcity[testFinished name='compareQImages(both null)']
##teamcity[testStarted name='compareQImages(one null)']
-##teamcity[testFailed name='compareQImages(one null)' message='Failure! |[Loc: tst_cmptest.cpp(429)|]' details='Compared QImages differ.|n Actual (opA).isNull(): 1|n Expected (opB).isNull(): 0']
+##teamcity[testFailed name='compareQImages(one null)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared QImages differ.|n Actual (opA).isNull(): 1|n Expected (opB).isNull(): 0']
##teamcity[testFinished name='compareQImages(one null)']
##teamcity[testStarted name='compareQImages(other null)']
-##teamcity[testFailed name='compareQImages(other null)' message='Failure! |[Loc: tst_cmptest.cpp(429)|]' details='Compared QImages differ.|n Actual (opA).isNull(): 0|n Expected (opB).isNull(): 1']
+##teamcity[testFailed name='compareQImages(other null)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared QImages differ.|n Actual (opA).isNull(): 0|n Expected (opB).isNull(): 1']
##teamcity[testFinished name='compareQImages(other null)']
##teamcity[testStarted name='compareQImages(equal)']
##teamcity[testFinished name='compareQImages(equal)']
##teamcity[testStarted name='compareQImages(different size)']
-##teamcity[testFailed name='compareQImages(different size)' message='Failure! |[Loc: tst_cmptest.cpp(429)|]' details='Compared QImages differ in size.|n Actual (opA): 11x20|n Expected (opB): 20x20']
+##teamcity[testFailed name='compareQImages(different size)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared QImages differ in size.|n Actual (opA): 11x20|n Expected (opB): 20x20']
##teamcity[testFinished name='compareQImages(different size)']
##teamcity[testStarted name='compareQImages(different format)']
-##teamcity[testFailed name='compareQImages(different format)' message='Failure! |[Loc: tst_cmptest.cpp(429)|]' details='Compared QImages differ in format.|n Actual (opA): 6|n Expected (opB): 3']
+##teamcity[testFailed name='compareQImages(different format)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared QImages differ in format.|n Actual (opA): 6|n Expected (opB): 3']
##teamcity[testFinished name='compareQImages(different format)']
##teamcity[testStarted name='compareQImages(different pixels)']
-##teamcity[testFailed name='compareQImages(different pixels)' message='Failure! |[Loc: tst_cmptest.cpp(429)|]' details='Compared values are not the same']
+##teamcity[testFailed name='compareQImages(different pixels)' message='Failure! |[Loc: tst_cmptest.cpp(432)|]' details='Compared values are not the same']
##teamcity[testFinished name='compareQImages(different pixels)']
+##teamcity[testStarted name='compareQRegion(equal-empty)']
+##teamcity[testFinished name='compareQRegion(equal-empty)']
+##teamcity[testStarted name='compareQRegion(1-empty)']
+##teamcity[testFailed name='compareQRegion(1-empty)' message='Failure! |[Loc: tst_cmptest.cpp(455)|]' details='Compared values are not the same|n Actual (rA): QRegion(200x50+10+10)|n Expected (rB): QRegion(null)']
+##teamcity[testFinished name='compareQRegion(1-empty)']
+##teamcity[testStarted name='compareQRegion(equal)']
+##teamcity[testFinished name='compareQRegion(equal)']
+##teamcity[testStarted name='compareQRegion(different lists)']
+##teamcity[testFailed name='compareQRegion(different lists)' message='Failure! |[Loc: tst_cmptest.cpp(455)|]' details='Compared values are not the same|n Actual (rA): QRegion(200x50+10+10)|n Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)']
+##teamcity[testFinished name='compareQRegion(different lists)']
##teamcity[testStarted name='verify()']
-##teamcity[testFailed name='verify()' message='Failure! |[Loc: tst_cmptest.cpp(441)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()']
+##teamcity[testFailed name='verify()' message='Failure! |[Loc: tst_cmptest.cpp(467)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()']
##teamcity[testFinished name='verify()']
##teamcity[testStarted name='verify2()']
-##teamcity[testFailed name='verify2()' message='Failure! |[Loc: tst_cmptest.cpp(447)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)']
+##teamcity[testFailed name='verify2()' message='Failure! |[Loc: tst_cmptest.cpp(473)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)']
##teamcity[testFinished name='verify2()']
##teamcity[testStarted name='tryVerify()']
-##teamcity[testFailed name='tryVerify()' message='Failure! |[Loc: tst_cmptest.cpp(453)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()']
+##teamcity[testFailed name='tryVerify()' message='Failure! |[Loc: tst_cmptest.cpp(479)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()']
##teamcity[testFinished name='tryVerify()']
##teamcity[testStarted name='tryVerify2()']
-##teamcity[testFailed name='tryVerify2()' message='Failure! |[Loc: tst_cmptest.cpp(459)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)']
+##teamcity[testFailed name='tryVerify2()' message='Failure! |[Loc: tst_cmptest.cpp(485)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)']
##teamcity[testFinished name='tryVerify2()']
##teamcity[testStarted name='verifyExplicitOperatorBool()']
##teamcity[testFinished name='verifyExplicitOperatorBool()']
diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt
index 9d125b3602..9c7f56e6c3 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.txt
+++ b/tests/auto/testlib/selftests/expected_cmptest.txt
@@ -2,114 +2,124 @@
Config: Using QtTest library
PASS : tst_Cmptest::initTestCase()
FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same
- Loc: [tst_cmptest.cpp(158)]
+ Loc: [tst_cmptest.cpp(160)]
FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same
Actual (Qt::Monday): Monday
Expected (Qt::Sunday): Sunday
- Loc: [tst_cmptest.cpp(164)]
+ Loc: [tst_cmptest.cpp(167)]
FAIL! : tst_Cmptest::compare_class_enums() Compared values are not the same
Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1
Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2
- Loc: [tst_cmptest.cpp(170)]
+ Loc: [tst_cmptest.cpp(173)]
PASS : tst_Cmptest::compare_boolfuncs()
PASS : tst_Cmptest::compare_to_nullptr()
PASS : tst_Cmptest::compare_pointerfuncs()
FAIL! : tst_Cmptest::compare_tostring(int, string) Compared values are not the same
Actual (actual) : QVariant(int,123)
Expected (expected): QVariant(QString,hi)
- Loc: [tst_cmptest.cpp(259)]
+ Loc: [tst_cmptest.cpp(262)]
PASS : tst_Cmptest::compare_tostring(both invalid)
FAIL! : tst_Cmptest::compare_tostring(null hash, invalid) Compared values are not the same
Actual (actual) : QVariant(QVariantHash)
Expected (expected): QVariant()
- Loc: [tst_cmptest.cpp(259)]
+ Loc: [tst_cmptest.cpp(262)]
FAIL! : tst_Cmptest::compare_tostring(string, null user type) Compared values are not the same
Actual (actual) : QVariant(QString,A simple string)
Expected (expected): QVariant(PhonyClass)
- Loc: [tst_cmptest.cpp(259)]
+ Loc: [tst_cmptest.cpp(262)]
FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values are not the same
Actual (actual) : QVariant(PhonyClass,<value not representable as string>)
Expected (expected): QVariant(PhonyClass,<value not representable as string>)
- Loc: [tst_cmptest.cpp(259)]
+ Loc: [tst_cmptest.cpp(262)]
PASS : tst_Cmptest::compareQStringLists(empty lists)
PASS : tst_Cmptest::compareQStringLists(equal lists)
FAIL! : tst_Cmptest::compareQStringLists(last item different) Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"
- Loc: [tst_cmptest.cpp(353)]
+ Loc: [tst_cmptest.cpp(356)]
FAIL! : tst_Cmptest::compareQStringLists(second-last item different) Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"
- Loc: [tst_cmptest.cpp(353)]
+ Loc: [tst_cmptest.cpp(356)]
FAIL! : tst_Cmptest::compareQStringLists(prefix) Compared lists have different sizes.
Actual (opA) size: 2
Expected (opB) size: 1
- Loc: [tst_cmptest.cpp(353)]
+ Loc: [tst_cmptest.cpp(356)]
FAIL! : tst_Cmptest::compareQStringLists(short list second) Compared lists have different sizes.
Actual (opA) size: 12
Expected (opB) size: 1
- Loc: [tst_cmptest.cpp(353)]
+ Loc: [tst_cmptest.cpp(356)]
FAIL! : tst_Cmptest::compareQStringLists(short list first) Compared lists have different sizes.
Actual (opA) size: 1
Expected (opB) size: 12
- Loc: [tst_cmptest.cpp(353)]
+ Loc: [tst_cmptest.cpp(356)]
FAIL! : tst_Cmptest::compareQListInt() Compared lists differ at index 2.
Actual (int1): 3
Expected (int2): 4
- Loc: [tst_cmptest.cpp(360)]
+ Loc: [tst_cmptest.cpp(363)]
FAIL! : tst_Cmptest::compareQListDouble() Compared lists differ at index 0.
Actual (double1): 1.5
Expected (double2): 1
- Loc: [tst_cmptest.cpp(367)]
+ Loc: [tst_cmptest.cpp(370)]
FAIL! : tst_Cmptest::compareQColor() Compared values are not the same
Actual (yellow): #ffff00
Expected (green) : #00ff00
- Loc: [tst_cmptest.cpp(377)]
+ Loc: [tst_cmptest.cpp(380)]
PASS : tst_Cmptest::compareQPixmaps(both null)
FAIL! : tst_Cmptest::compareQPixmaps(one null) Compared QPixmaps differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0
- Loc: [tst_cmptest.cpp(402)]
+ Loc: [tst_cmptest.cpp(405)]
FAIL! : tst_Cmptest::compareQPixmaps(other null) Compared QPixmaps differ.
Actual (opA).isNull(): 0
Expected (opB).isNull(): 1
- Loc: [tst_cmptest.cpp(402)]
+ Loc: [tst_cmptest.cpp(405)]
PASS : tst_Cmptest::compareQPixmaps(equal)
FAIL! : tst_Cmptest::compareQPixmaps(different size) Compared QPixmaps differ in size.
Actual (opA): 11x20
Expected (opB): 20x20
- Loc: [tst_cmptest.cpp(402)]
+ Loc: [tst_cmptest.cpp(405)]
FAIL! : tst_Cmptest::compareQPixmaps(different pixels) Compared values are not the same
- Loc: [tst_cmptest.cpp(402)]
+ Loc: [tst_cmptest.cpp(405)]
PASS : tst_Cmptest::compareQImages(both null)
FAIL! : tst_Cmptest::compareQImages(one null) Compared QImages differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0
- Loc: [tst_cmptest.cpp(429)]
+ Loc: [tst_cmptest.cpp(432)]
FAIL! : tst_Cmptest::compareQImages(other null) Compared QImages differ.
Actual (opA).isNull(): 0
Expected (opB).isNull(): 1
- Loc: [tst_cmptest.cpp(429)]
+ Loc: [tst_cmptest.cpp(432)]
PASS : tst_Cmptest::compareQImages(equal)
FAIL! : tst_Cmptest::compareQImages(different size) Compared QImages differ in size.
Actual (opA): 11x20
Expected (opB): 20x20
- Loc: [tst_cmptest.cpp(429)]
+ Loc: [tst_cmptest.cpp(432)]
FAIL! : tst_Cmptest::compareQImages(different format) Compared QImages differ in format.
Actual (opA): 6
Expected (opB): 3
- Loc: [tst_cmptest.cpp(429)]
+ Loc: [tst_cmptest.cpp(432)]
FAIL! : tst_Cmptest::compareQImages(different pixels) Compared values are not the same
- Loc: [tst_cmptest.cpp(429)]
+ Loc: [tst_cmptest.cpp(432)]
+PASS : tst_Cmptest::compareQRegion(equal-empty)
+FAIL! : tst_Cmptest::compareQRegion(1-empty) Compared values are not the same
+ Actual (rA): QRegion(200x50+10+10)
+ Expected (rB): QRegion(null)
+ Loc: [tst_cmptest.cpp(455)]
+PASS : tst_Cmptest::compareQRegion(equal)
+FAIL! : tst_Cmptest::compareQRegion(different lists) Compared values are not the same
+ Actual (rA): QRegion(200x50+10+10)
+ Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)
+ Loc: [tst_cmptest.cpp(455)]
FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. ()
- Loc: [tst_cmptest.cpp(441)]
+ Loc: [tst_cmptest.cpp(467)]
FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42)
- Loc: [tst_cmptest.cpp(447)]
+ Loc: [tst_cmptest.cpp(473)]
FAIL! : tst_Cmptest::tryVerify() 'opaqueFunc() < 2' returned FALSE. ()
- Loc: [tst_cmptest.cpp(453)]
+ Loc: [tst_cmptest.cpp(479)]
FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42)
- Loc: [tst_cmptest.cpp(459)]
+ Loc: [tst_cmptest.cpp(485)]
PASS : tst_Cmptest::verifyExplicitOperatorBool()
PASS : tst_Cmptest::cleanupTestCase()
-Totals: 13 passed, 28 failed, 0 skipped, 0 blacklisted, 246ms
+Totals: 15 passed, 30 failed, 0 skipped, 0 blacklisted, 244ms
********* Finished testing of tst_Cmptest *********
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml
index 776560f639..f64ffe3792 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xml
@@ -10,13 +10,13 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_unregistered_enums">
-<Incident type="fail" file="tst_cmptest.cpp" line="158">
+<Incident type="fail" file="tst_cmptest.cpp" line="160">
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_registered_enums">
-<Incident type="fail" file="tst_cmptest.cpp" line="164">
+<Incident type="fail" file="tst_cmptest.cpp" line="167">
<Description><![CDATA[Compared values are not the same
Actual (Qt::Monday): Monday
Expected (Qt::Sunday): Sunday]]></Description>
@@ -24,7 +24,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_class_enums">
-<Incident type="fail" file="tst_cmptest.cpp" line="170">
+<Incident type="fail" file="tst_cmptest.cpp" line="173">
<Description><![CDATA[Compared values are not the same
Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1
Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2]]></Description>
@@ -44,7 +44,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compare_tostring">
-<Incident type="fail" file="tst_cmptest.cpp" line="259">
+<Incident type="fail" file="tst_cmptest.cpp" line="262">
<DataTag><![CDATA[int, string]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(int,123)
@@ -53,19 +53,19 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both invalid]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="259">
+<Incident type="fail" file="tst_cmptest.cpp" line="262">
<DataTag><![CDATA[null hash, invalid]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QVariantHash)
Expected (expected): QVariant()]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="259">
+<Incident type="fail" file="tst_cmptest.cpp" line="262">
<DataTag><![CDATA[string, null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(QString,A simple string)
Expected (expected): QVariant(PhonyClass)]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="259">
+<Incident type="fail" file="tst_cmptest.cpp" line="262">
<DataTag><![CDATA[both non-null user type]]></DataTag>
<Description><![CDATA[Compared values are not the same
Actual (actual) : QVariant(PhonyClass,<value not representable as string>)
@@ -80,31 +80,31 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal lists]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[second-last item different]]></DataTag>
<Description><![CDATA[Compared lists differ at index 2.
Actual (opA): "string3"
Expected (opB): "DIFFERS"]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[prefix]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 2
Expected (opB) size: 1]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[short list second]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 12
Expected (opB) size: 1]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="353">
+<Incident type="fail" file="tst_cmptest.cpp" line="356">
<DataTag><![CDATA[short list first]]></DataTag>
<Description><![CDATA[Compared lists have different sizes.
Actual (opA) size: 1
@@ -113,7 +113,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQListInt">
-<Incident type="fail" file="tst_cmptest.cpp" line="360">
+<Incident type="fail" file="tst_cmptest.cpp" line="363">
<Description><![CDATA[Compared lists differ at index 2.
Actual (int1): 3
Expected (int2): 4]]></Description>
@@ -121,7 +121,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQListDouble">
-<Incident type="fail" file="tst_cmptest.cpp" line="367">
+<Incident type="fail" file="tst_cmptest.cpp" line="370">
<Description><![CDATA[Compared lists differ at index 0.
Actual (double1): 1.5
Expected (double2): 1]]></Description>
@@ -129,7 +129,7 @@
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="compareQColor">
-<Incident type="fail" file="tst_cmptest.cpp" line="377">
+<Incident type="fail" file="tst_cmptest.cpp" line="380">
<Description><![CDATA[Compared values are not the same
Actual (yellow): #ffff00
Expected (green) : #00ff00]]></Description>
@@ -140,13 +140,13 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="402">
+<Incident type="fail" file="tst_cmptest.cpp" line="405">
<DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="402">
+<Incident type="fail" file="tst_cmptest.cpp" line="405">
<DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ.
Actual (opA).isNull(): 0
@@ -155,13 +155,13 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="402">
+<Incident type="fail" file="tst_cmptest.cpp" line="405">
<DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QPixmaps differ in size.
Actual (opA): 11x20
Expected (opB): 20x20]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="402">
+<Incident type="fail" file="tst_cmptest.cpp" line="405">
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
@@ -171,13 +171,13 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[both null]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[one null]]></DataTag>
<Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 1
Expected (opB).isNull(): 0]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[other null]]></DataTag>
<Description><![CDATA[Compared QImages differ.
Actual (opA).isNull(): 0
@@ -186,44 +186,65 @@
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[equal]]></DataTag>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[different size]]></DataTag>
<Description><![CDATA[Compared QImages differ in size.
Actual (opA): 11x20
Expected (opB): 20x20]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[different format]]></DataTag>
<Description><![CDATA[Compared QImages differ in format.
Actual (opA): 6
Expected (opB): 3]]></Description>
</Incident>
-<Incident type="fail" file="tst_cmptest.cpp" line="429">
+<Incident type="fail" file="tst_cmptest.cpp" line="432">
<DataTag><![CDATA[different pixels]]></DataTag>
<Description><![CDATA[Compared values are not the same]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
+<TestFunction name="compareQRegion">
+<Incident type="pass" file="" line="0">
+ <DataTag><![CDATA[equal-empty]]></DataTag>
+</Incident>
+<Incident type="fail" file="tst_cmptest.cpp" line="455">
+ <DataTag><![CDATA[1-empty]]></DataTag>
+ <Description><![CDATA[Compared values are not the same
+ Actual (rA): QRegion(200x50+10+10)
+ Expected (rB): QRegion(null)]]></Description>
+</Incident>
+<Incident type="pass" file="" line="0">
+ <DataTag><![CDATA[equal]]></DataTag>
+</Incident>
+<Incident type="fail" file="tst_cmptest.cpp" line="455">
+ <DataTag><![CDATA[different lists]]></DataTag>
+ <Description><![CDATA[Compared values are not the same
+ Actual (rA): QRegion(200x50+10+10)
+ Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)]]></Description>
+</Incident>
+ <Duration msecs="0"/>
+</TestFunction>
<TestFunction name="verify">
-<Incident type="fail" file="tst_cmptest.cpp" line="441">
+<Incident type="fail" file="tst_cmptest.cpp" line="467">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="verify2">
-<Incident type="fail" file="tst_cmptest.cpp" line="447">
+<Incident type="fail" file="tst_cmptest.cpp" line="473">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="tryVerify">
-<Incident type="fail" file="tst_cmptest.cpp" line="453">
+<Incident type="fail" file="tst_cmptest.cpp" line="479">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="tryVerify2">
-<Incident type="fail" file="tst_cmptest.cpp" line="459">
+<Incident type="fail" file="tst_cmptest.cpp" line="485">
<Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description>
</Incident>
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
index 4299b99846..de47ac97f5 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="0" failures="28" tests="20" name="tst_Cmptest">
+<testsuite errors="0" failures="30" tests="21" name="tst_Cmptest">
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
@@ -95,6 +95,14 @@
Expected (opB): 3" result="fail"/>
<failure tag="different pixels" message="Compared values are not the same" result="fail"/>
</testcase>
+ <testcase result="fail" name="compareQRegion">
+ <failure tag="1&#x002D;empty" message="Compared values are not the same
+ Actual (rA): QRegion(200x50+10+10)
+ Expected (rB): QRegion(null)" result="fail"/>
+ <failure tag="different lists" message="Compared values are not the same
+ Actual (rA): QRegion(200x50+10+10)
+ Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)" result="fail"/>
+ </testcase>
<testcase result="fail" name="verify">
<failure message="&apos;opaqueFunc() &lt; 2&apos; returned FALSE. ()" result="fail"/>
</testcase>
diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py
index aed8829ed6..66a75a304f 100755
--- a/tests/auto/testlib/selftests/generate_expected_output.py
+++ b/tests/auto/testlib/selftests/generate_expected_output.py
@@ -104,6 +104,7 @@ if isWindows:
exit()
tests = sys.argv[1:]
+os.environ['LC_ALL'] = 'C'
if len(tests) == 0:
tests = subdirs()
print("Generating " + str(len(tests)) + " test results for: " + qtver + " in: " + rootPath)
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 9fdd37ea9b..d5d8a2ecaa 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -1930,6 +1930,13 @@ void tst_Moc::warnings_data()
<< 1
<< QString("IGNORE_ALL_STDOUT")
<< QString(":2: Error: Macro invoked with too few parameters for a use of '#'");
+
+ QTest::newRow("QTBUG-54609: crash on invalid input")
+ << QByteArray::fromBase64("EAkJCQkJbGFzcyBjbGFzcyBiYWkcV2kgTUEKcGYjZGVmaW5lIE1BKFEs/4D/FoQ=")
+ << QStringList()
+ << 1
+ << QString("IGNORE_ALL_STDOUT")
+ << QString(":-1: Error: Unexpected character in macro argument list.");
}
void tst_Moc::warnings()
@@ -1945,7 +1952,7 @@ void tst_Moc::warnings()
#ifdef Q_CC_MSVC
// for some reasons, moc compiled with MSVC uses a different output format
- QRegExp lineNumberRe(":(\\d+):");
+ QRegExp lineNumberRe(":(-?\\d+):");
lineNumberRe.setMinimal(true);
expectedStdErr.replace(lineNumberRe, "(\\1):");
#endif
diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp
index d4959a4f63..21c1759b08 100644
--- a/tests/auto/tools/qmakelib/evaltest.cpp
+++ b/tests/auto/tools/qmakelib/evaltest.cpp
@@ -594,6 +594,23 @@ void tst_qmakelib::addControlStructs()
<< ""
<< true;
+ QTest::newRow("function arguments")
+ << "defineTest(func) {\n"
+ "defined(1, var) {\nd1 = 1\nexport(d1)\n}\n"
+ "defined(3, var) {\nd3 = 1\nexport(d3)\n}\n"
+ "x1 = $$1\nexport(x1)\n"
+ "2 += foo\nx2 = $$2\nexport(x2)\n"
+ "x3 = $$3\nexport(x3)\n"
+ "4 += foo\nx4 = $$4\nexport(x4)\n"
+ "x5 = $$5\nexport(x5)\n"
+ "6 += foo\nx6 = $$6\nexport(x6)\n"
+ "}\n"
+ "1 = first\n2 = second\n3 = third\n4 = fourth\nfunc(one, two)"
+ << "1 = first\n2 = second\n3 = third\n4 = fourth\n5 = UNDEF\n6 = UNDEF\n"
+ "d1 = 1\nd3 = UNDEF\nx1 = one\nx2 = two foo\nx3 =\nx4 = foo\nx5 =\nx6 = foo"
+ << ""
+ << true;
+
QTest::newRow("ARGC and ARGS")
<< "defineTest(func) {\n"
"export(ARGC)\n"
@@ -636,6 +653,86 @@ void tst_qmakelib::addControlStructs()
<< "VAR = final"
<< ""
<< true;
+
+ QTest::newRow("error() from replace function (assignment)")
+ << "defineReplace(func) {\nerror(error)\n}\n"
+ "VAR = $$func()\n"
+ "OKE = 1"
+ << "VAR = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
+
+ QTest::newRow("error() from replace function (replacement)")
+ << "defineReplace(func) {\nerror(error)\n}\n"
+ "VAR = $$func()\n"
+ "OKE = 1"
+ << "VAR = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
+
+ QTest::newRow("error() from replace function (LHS)")
+ << "defineReplace(func) {\nerror(error)\nreturn(VAR)\n}\n"
+ "$$func() = 1\n"
+ "OKE = 1"
+ << "VAR = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
+
+ QTest::newRow("error() from replace function (loop variable)")
+ << "defineReplace(func) {\nerror(error)\nreturn(BLAH)\n}\n"
+ "for($$func()) {\nVAR = $$BLAH\nbreak()\n}\n"
+ "OKE = 1"
+ << "VAR = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
+
+ QTest::newRow("error() from replace function (built-in test arguments)")
+ << "defineReplace(func) {\nerror(error)\n}\n"
+ "message($$func()): VAR = 1\n"
+ "OKE = 1"
+ << "VAR = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
+
+ QTest::newRow("error() from replace function (built-in replace arguments)")
+ << "defineReplace(func) {\nerror(error)\n}\n"
+ "VAR = $$upper($$func())\n"
+ "OKE = 1"
+ << "VAR = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
+
+ QTest::newRow("error() from replace function (custom test arguments)")
+ << "defineReplace(func) {\nerror(error)\n}\n"
+ "defineTest(custom) {\n}\n"
+ "custom($$func()): VAR = 1\n"
+ "OKE = 1"
+ << "VAR = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
+
+ QTest::newRow("error() from replace function (custom replace arguments)")
+ << "defineReplace(func) {\nerror(error)\nreturn(1)\n}\n"
+ "defineReplace(custom) {\nreturn($$1)\n}\n"
+ "VAR = $$custom($$func(1))\n"
+ "OKE = 1"
+ << "VAR = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
+
+ QTest::newRow("REQUIRES = error()")
+ << "REQUIRES = error(error)\n"
+ "OKE = 1"
+ << "OKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
+
+ QTest::newRow("requires(error())")
+ << "requires(error(error))\n"
+ "OKE = 1"
+ << "OKE = UNDEF"
+ << "Project ERROR: error"
+ << false;
}
void tst_qmakelib::addReplaceFunctions(const QString &qindir)
@@ -2255,6 +2352,12 @@ void tst_qmakelib::addTestFunctions(const QString &qindir)
<< "Project ERROR: World, you FAIL!"
<< false;
+ QTest::newRow("if(error())")
+ << "if(error(\\'World, you FAIL!\\')): OK = 1\nOKE = 1"
+ << "OK = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: World, you FAIL!"
+ << false;
+
QTest::newRow("system()")
<< "system('"
#ifdef Q_OS_WIN
@@ -2531,6 +2634,14 @@ void tst_qmakelib::proEval_data()
"Project MESSAGE: assign split joined: word: this is a test:done\n"
"Project MESSAGE: assign split quoted: word this is a test done"
<< true;
+
+ // Raw data leak with empty file name. Verify with Valgrind or asan.
+ QTest::newRow("QTBUG-54550")
+ << "FULL = /there/is\n"
+ "VAR = $$absolute_path(, $$FULL/nothing/here/really)"
+ << "VAR = /there/is/nothing/here/really"
+ << ""
+ << true;
}
static QString formatValue(const ProStringList &vals)
diff --git a/tests/auto/tools/qmakelib/parsertest.cpp b/tests/auto/tools/qmakelib/parsertest.cpp
index 6857334746..dc92f98f45 100644
--- a/tests/auto/tools/qmakelib/parsertest.cpp
+++ b/tests/auto/tools/qmakelib/parsertest.cpp
@@ -1867,6 +1867,13 @@ void tst_qmakelib::addParseAbuse()
/* 24 */ /* else branch */ << I(0))
<< "in:1: OR operator without prior condition."
<< false;
+
+ // Token buffer overflow. Verify with Valgrind or asan.
+ QTest::newRow("QTCREATORBUG-16508")
+ << "a{b{c{d{"
+ << TS()
+ << "in:2: Missing closing brace(s)."
+ << false;
}
void tst_qmakelib::proParser_data()
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 3a3e38ba75..0098c5d884 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -286,8 +286,8 @@ retry:
// Testing get/set functions
void tst_QCompleter::getSetCheck()
{
- QStandardItemModel model(3,3);
- QCompleter completer(&model);
+ QStandardItemModel standardItemModel(3,3);
+ QCompleter completer(&standardItemModel);
// QString QCompleter::completionPrefix()
// void QCompleter::setCompletionPrefix(QString)
@@ -347,6 +347,21 @@ void tst_QCompleter::getSetCheck()
QCOMPARE(completer.wrapAround(), true); // default value
completer.setWrapAround(false);
QCOMPARE(completer.wrapAround(), false);
+
+#ifndef QT_NO_FILESYSTEMMODEL
+ // QTBUG-54642, changing from QFileSystemModel to another model should restore role.
+ completer.setCompletionRole(Qt::EditRole);
+ QCOMPARE(completer.completionRole(), static_cast<int>(Qt::EditRole)); // default value
+ QFileSystemModel fileSystemModel;
+ completer.setModel(&fileSystemModel);
+ QCOMPARE(completer.completionRole(), static_cast<int>(QFileSystemModel::FileNameRole));
+ completer.setModel(&standardItemModel);
+ QCOMPARE(completer.completionRole(), static_cast<int>(Qt::EditRole));
+ completer.setCompletionRole(Qt::ToolTipRole);
+ QStandardItemModel standardItemModel2(2, 2); // Do not clobber a custom role when changing models
+ completer.setModel(&standardItemModel2);
+ QCOMPARE(completer.completionRole(), static_cast<int>(Qt::ToolTipRole));
+#endif // QT_NO_FILESYSTEMMODEL
}
void tst_QCompleter::csMatchingOnCsSortedModel_data()
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 1ae33ef7a1..816fe1faba 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -153,6 +153,7 @@ private slots:
void itemData();
void task_QTBUG_31146_popupCompletion();
void task_QTBUG_41288_completerChangesCurrentIndex();
+ void task_QTBUG_54191_slotOnEditTextChangedSetsComboBoxToReadOnly();
void keyboardSelection();
void setCustomModelAndView();
void updateDelegateOnEditableChange();
@@ -3111,6 +3112,30 @@ void tst_QComboBox::task_QTBUG_41288_completerChangesCurrentIndex()
}
}
+namespace {
+ struct SetReadOnly {
+ QComboBox *cb;
+ explicit SetReadOnly(QComboBox *cb) : cb(cb) {}
+ void operator()() const
+ { cb->setEditable(false); }
+ };
+}
+
+void tst_QComboBox::task_QTBUG_54191_slotOnEditTextChangedSetsComboBoxToReadOnly()
+{
+ QComboBox cb;
+ cb.addItems(QStringList() << "one" << "two");
+ cb.setEditable(true);
+ cb.setCurrentIndex(0);
+
+ connect(&cb, &QComboBox::editTextChanged,
+ SetReadOnly(&cb));
+
+ cb.setCurrentIndex(1);
+ // the real test is that it didn't crash...
+ QCOMPARE(cb.currentIndex(), 1);
+}
+
void tst_QComboBox::keyboardSelection()
{
QComboBox comboBox;
diff --git a/tests/manual/diaglib/diaglib.pri b/tests/manual/diaglib/diaglib.pri
index 9bcf0317a6..e3e7c3757c 100644
--- a/tests/manual/diaglib/diaglib.pri
+++ b/tests/manual/diaglib/diaglib.pri
@@ -2,15 +2,13 @@ INCLUDEPATH += $$PWD
SOURCES += \
$$PWD/textdump.cpp \
$$PWD/eventfilter.cpp \
- $$PWD/qwindowdump.cpp \
- $$PWD/debugproxystyle.cpp
+ $$PWD/qwindowdump.cpp
HEADERS += \
$$PWD/textdump.h \
$$PWD/eventfilter.h \
$$PWD/qwindowdump.h \
- $$PWD/nativewindowdump.h \
- $$PWD/debugproxystyle.h
+ $$PWD/nativewindowdump.h
win32 {
SOURCES += $$PWD/nativewindowdump_win.cpp
@@ -24,19 +22,23 @@ greaterThan(QT_MAJOR_VERSION, 4) {
contains(QT, widgets) {
HEADERS += \
$$PWD/qwidgetdump.h \
+ $$PWD/debugproxystyle.h \
$$PWD/logwidget.h
SOURCES += \
$$PWD/qwidgetdump.cpp \
+ $$PWD/debugproxystyle.cpp \
$$PWD/logwidget.cpp
}
} else {
HEADERS += \
$$PWD/qwidgetdump.h \
+ $$PWD/debugproxystyle.h \
$$PWD/logwidget.h
SOURCES += \
$$PWD/qwidgetdump.cpp \
+ $$PWD/debugproxystyle.cpp \
$$PWD/logwidget.cpp
}
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 545b207939..f0e9dde42a 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -1785,7 +1785,7 @@ bool Configure::displayHelp()
}
desc("ANGLE", "yes", "-angle", "Use the ANGLE implementation of OpenGL ES 2.0.");
- desc("ANGLE", "no", "-no-angle", "Do not use ANGLE.\nSee http://code.google.com/p/angleproject/\n");
+ desc("ANGLE", "no", "-no-angle", "Do not use ANGLE.\nSee https://chromium.googlesource.com/angle/angle/+/master/README.md\n");
// Qt\Windows only options go below here --------------------------------------------------------------------------------
desc("\nQt for Windows only:\n\n");