From 9901d39ea6012621350a4e2a3f1466803c60829e Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 6 Apr 2020 12:11:36 +0200 Subject: [PATCH 01/17] Minimal platform: fix leaking QMinimalScreen instance This caused false alarms in fuzzing tests. The lifetime of the screen is the same as that of QMinimalIntegration. But failure to call handleScreenRemoved() also causes a warning; so as on "normal" platforms, the screen has to be separately allocated. Change-Id: Iad0cc53b8d09687400ced28bc2353b7500b01110 Reviewed-by: Robert Loehning --- src/plugins/platforms/minimal/qminimalintegration.cpp | 11 ++++++----- src/plugins/platforms/minimal/qminimalintegration.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index f457f69f111..0c2c0d0b68c 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -103,17 +103,18 @@ QMinimalIntegration::QMinimalIntegration(const QStringList ¶meters) m_options |= DebugBackingStore | EnableFonts; } - QMinimalScreen *mPrimaryScreen = new QMinimalScreen(); + m_primaryScreen = new QMinimalScreen(); - mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); - mPrimaryScreen->mDepth = 32; - mPrimaryScreen->mFormat = QImage::Format_ARGB32_Premultiplied; + m_primaryScreen->mGeometry = QRect(0, 0, 240, 320); + m_primaryScreen->mDepth = 32; + m_primaryScreen->mFormat = QImage::Format_ARGB32_Premultiplied; - QWindowSystemInterface::handleScreenAdded(mPrimaryScreen); + QWindowSystemInterface::handleScreenAdded(m_primaryScreen); } QMinimalIntegration::~QMinimalIntegration() { + QWindowSystemInterface::handleScreenRemoved(m_primaryScreen); delete m_fontDatabase; } diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h index ad1bec21126..f9c66e0c3e5 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.h +++ b/src/plugins/platforms/minimal/qminimalintegration.h @@ -88,6 +88,7 @@ public: private: mutable QPlatformFontDatabase *m_fontDatabase; + QMinimalScreen *m_primaryScreen; unsigned m_options; }; From fa463fa721b2f15cc8b95334306f1377a7e9e100 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Thu, 2 Apr 2020 15:17:58 +0200 Subject: [PATCH 02/17] WASM: Replace NO_EXIT_RUNTIME=0 with EXIT_RUNTIME=1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Get rid of double negation to make the configuration easier to understand. Change-Id: I5dfe256c2ac2ef131c3db20dce9ff492c529a5b1 Reference: https://emscripten.org/docs/tools_reference/emcc.html Reviewed-by: Morten Johan Sørvig --- mkspecs/wasm-emscripten/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/wasm-emscripten/qmake.conf b/mkspecs/wasm-emscripten/qmake.conf index 18562621ac6..a1880b4c22a 100644 --- a/mkspecs/wasm-emscripten/qmake.conf +++ b/mkspecs/wasm-emscripten/qmake.conf @@ -37,7 +37,7 @@ EMCC_COMMON_LFLAGS += \ -s FULL_ES2=1 \ -s FULL_ES3=1 \ -s USE_WEBGL2=1 \ - -s NO_EXIT_RUNTIME=0 \ + -s EXIT_RUNTIME=1 \ -s ERROR_ON_UNDEFINED_SYMBOLS=1 \ -s EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"] \ --bind \ From 36feab8bf49b4c57a45b6668921e8accaa167c36 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 15:36:01 -0300 Subject: [PATCH 03/17] QTemporaryFile/Linux: don't cut the root dir's slash Normally people shouldn't create temporary files on /, but if you're running as root, why not? Caught when running tst_qtemporaryfile as root: openat(AT_FDCWD, "", O_RDWR|O_CLOEXEC|O_TMPFILE, 0600) = -1 ENOENT (No such file or directory) Change-Id: Ibdc95e9af7bd456a94ecfffd1603ebfc17cea220 Reviewed-by: Simon Hausmann Reviewed-by: David Faure --- src/corelib/io/qtemporaryfile.cpp | 6 ++++-- tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 55d13dad70e..c016a622c74 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -284,8 +284,10 @@ createUnnamedFile(NativeFileHandle &file, QTemporaryFileName &tfn, quint32 mode, return CreateUnnamedFileStatus::NotSupported; const char *p = "."; - int lastSlash = tfn.path.lastIndexOf('/'); - if (lastSlash != -1) { + QByteArray::size_type lastSlash = tfn.path.lastIndexOf('/'); + if (lastSlash >= 0) { + if (lastSlash == 0) + lastSlash = 1; tfn.path[lastSlash] = '\0'; p = tfn.path.data(); } diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index 00417fffa03..cdf79760f61 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -517,6 +517,9 @@ void tst_QTemporaryFile::openOnRootDrives() QTemporaryFile file(driveInfo.filePath() + "XXXXXX.txt"); file.setAutoRemove(true); QVERIFY(file.open()); + + QFileInfo fi(file.fileName()); + QCOMPARE(fi.absoluteDir(), driveInfo.filePath()); } } #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) From 135d98134f4574efafe1a0302c2ecb5fb05f63fb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 15:21:55 -0300 Subject: [PATCH 04/17] tst_QSaveFile: skip test that fails when run as root FAIL! : tst_QSaveFile::retryTransactionalWrite() '!file.open(QIODevice::WriteOnly)' returned FALSE. () Loc: [/home/tjmaciei/src/qt/qt5/qtbase/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp(156)] strace reveals: access("/TEMPDIR/outfile.ro", W_OK) = 0 Change-Id: Ibdc95e9af7bd456a94ecfffd1603eb371aadb02b Reviewed-by: David Faure --- tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp index 8e500d7c8e4..361d18054bc 100644 --- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp +++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp @@ -136,6 +136,10 @@ void tst_QSaveFile::retryTransactionalWrite() { #ifndef Q_OS_UNIX QSKIP("This test is Unix only"); +#else + // root can open the read-only file for writing... + if (geteuid() == 0) + QSKIP("This test does not work as the root user"); #endif QTemporaryDir dir; QVERIFY2(dir.isValid(), qPrintable(dir.errorString())); From e961cc057bcd3b69bf567a7a608ca7bb450bcffb Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 9 Apr 2020 08:22:32 +0200 Subject: [PATCH 05/17] MinGW: Fix debug only angle builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-83397 Change-Id: I89e21cc8101a17dcdb232ff5df1a76cc08842434 Reviewed-by: Joerg Bornemann Reviewed-by: André Klitzing --- src/gui/gui.pro | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 350d4c5ee34..6e92283142c 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -59,15 +59,16 @@ load(cmake_functions) win32: CMAKE_WINDOWS_BUILD = True qtConfig(angle) { + !mingw|qtConfig(debug_and_release): debug_suffix="d" CMAKE_GL_INCDIRS = $$CMAKE_INCLUDE_DIR CMAKE_ANGLE_EGL_DLL_RELEASE = libEGL.dll CMAKE_ANGLE_EGL_IMPLIB_RELEASE = libEGL.$${QMAKE_EXTENSION_STATICLIB} CMAKE_ANGLE_GLES2_DLL_RELEASE = libGLESv2.dll CMAKE_ANGLE_GLES2_IMPLIB_RELEASE = libGLESv2.$${QMAKE_EXTENSION_STATICLIB} - CMAKE_ANGLE_EGL_DLL_DEBUG = libEGLd.dll - CMAKE_ANGLE_EGL_IMPLIB_DEBUG = libEGLd.$${QMAKE_EXTENSION_STATICLIB} - CMAKE_ANGLE_GLES2_DLL_DEBUG = libGLESv2d.dll - CMAKE_ANGLE_GLES2_IMPLIB_DEBUG = libGLESv2d.$${QMAKE_EXTENSION_STATICLIB} + CMAKE_ANGLE_EGL_DLL_DEBUG = libEGL$${debug_suffix}.dll + CMAKE_ANGLE_EGL_IMPLIB_DEBUG = libEGL$${debug_suffix}.$${QMAKE_EXTENSION_STATICLIB} + CMAKE_ANGLE_GLES2_DLL_DEBUG = libGLESv2$${debug_suffix}.dll + CMAKE_ANGLE_GLES2_IMPLIB_DEBUG = libGLESv2$${debug_suffix}.$${QMAKE_EXTENSION_STATICLIB} CMAKE_QT_OPENGL_IMPLEMENTATION = GLESv2 } else { From 31d0dcab46053e98e5628939e37f5b29060b6799 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 13:38:57 -0300 Subject: [PATCH 06/17] tst_PlatformSocketEngine: Removee SOURCES += of QtNetwork code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids ASAN warning of ODR violation: SUMMARY: AddressSanitizer: odr-violation: global 'typeinfo name for QSocketEngineHandler' at ../../../../../src/network/socket/qabstractsocketengine.cpp This trick has not been needed since we got Q_AUTOTEST_EXPORT. The main .pro file has: requires(qtConfig(private_tests)) Change-Id: Ibdc95e9af7bd456a94ecfffd1603e598932b88ad Reviewed-by: Mårten Nordheim --- .../socket/platformsocketengine/platformsocketengine.pri | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri index 868439de6a4..3422390870c 100644 --- a/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri +++ b/tests/auto/network/socket/platformsocketengine/platformsocketengine.pri @@ -5,9 +5,3 @@ QNETWORK_SRC = $$QT_SOURCE_TREE/src/network INCLUDEPATH += $$QNETWORK_SRC win32: QMAKE_USE += ws2_32 - -unix:qtConfig(reduce_exports) { - SOURCES += $$QNETWORK_SRC/socket/qnativesocketengine_unix.cpp - SOURCES += $$QNETWORK_SRC/socket/qnativesocketengine.cpp - SOURCES += $$QNETWORK_SRC/socket/qabstractsocketengine.cpp -} From 39972cf899a0addc3de465cd1d1a64df08a273a0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 18:26:39 -0300 Subject: [PATCH 07/17] KMS: fix warning about hex() and dec() being deprecated Change-Id: Ibdc95e9af7bd456a94ecfffd1603f54bcb86fb87 Reviewed-by: Allan Sandfeld Jensen --- src/platformsupport/kmsconvenience/qkmsdevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 18f7b5e23bb..8cd7f9b3688 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -396,7 +396,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, drmFormat = DRM_FORMAT_XRGB8888; drmFormatExplicit = false; } - qCDebug(qLcKmsDebug) << "Format is" << hex << drmFormat << dec << "requested_by_user =" << drmFormatExplicit + qCDebug(qLcKmsDebug) << "Format is" << Qt::hex << drmFormat << Qt::dec << "requested_by_user =" << drmFormatExplicit << "for output" << connectorName; const QString cloneSource = userConnectorConfig.value(QStringLiteral("clones")).toString(); From 1b7de8988c2d9fa3d4d435c8731634da05001ac2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 18:15:12 -0300 Subject: [PATCH 08/17] QFactoryLoader: Fix warning about binary JSON being deprecated Change-Id: Ibdc95e9af7bd456a94ecfffd1603f4abb1c3dfec Reviewed-by: Sona Kurazyan --- src/corelib/plugin/qfactoryloader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 400c8bf05f1..b03ab4349b7 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -125,6 +125,8 @@ static QJsonDocument jsonFromCborMetaData(const char *raw, qsizetype size, QStri return QJsonDocument(o); } +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QJsonDocument qJsonFromRawLibraryMetaData(const char *raw, qsizetype sectionSize, QString *errMsg) { raw += metaDataSignatureLength(); @@ -148,6 +150,7 @@ QJsonDocument qJsonFromRawLibraryMetaData(const char *raw, qsizetype sectionSize return jsonFromCborMetaData(raw, sectionSize, errMsg); } +QT_WARNING_POP class QFactoryLoaderPrivate : public QObjectPrivate { From ddc7b3c1565b5f7100df4d13e5501f76db2730ee Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 11:40:42 -0300 Subject: [PATCH 09/17] QJsonObject: add missing detach2() calls The refactoring to use CBOR missed two places where we could assign from the same object and thus cause corruption. In fixing this issue, I found a design flaw in QJsonObject, see Q_EXPECT_FAILing unit test and task QTBUG-83398. [ChangeLog][QtCore][QJsonObject] Fixed a regression from 5.13 that incorrect results when assigning elements from an object to itself. Fixes: QTBUG-83366 Change-Id: Ibdc95e9af7bd456a94ecfffd1603df24b06713aa Reviewed-by: Ulf Hermann --- src/corelib/serialization/qjsonobject.cpp | 3 + .../corelib/serialization/json/tst_qtjson.cpp | 97 +++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp index b76e50e2d25..850e878571f 100644 --- a/src/corelib/serialization/qjsonobject.cpp +++ b/src/corelib/serialization/qjsonobject.cpp @@ -452,9 +452,11 @@ QJsonValueRef QJsonObject::atImpl(T key) bool keyExists = false; int index = indexOf(o, key, &keyExists); if (!keyExists) { + detach2(o->elements.length() / 2 + 1); o->insertAt(index, key); o->insertAt(index + 1, QCborValue::fromJsonValue(QJsonValue())); } + // detaching will happen if and when this QJsonValueRef is assigned to return QJsonValueRef(this, index / 2); } @@ -1469,6 +1471,7 @@ QJsonValue QJsonObject::valueAt(int i) const void QJsonObject::setValueAt(int i, const QJsonValue &val) { Q_ASSERT(o && i >= 0 && 2 * i + 1 < o->elements.length()); + detach2(); if (val.isUndefined()) { o->removeAt(2 * i + 1); o->removeAt(2 * i); diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp index 45f815f8109..7da20772f80 100644 --- a/tests/auto/corelib/serialization/json/tst_qtjson.cpp +++ b/tests/auto/corelib/serialization/json/tst_qtjson.cpp @@ -54,7 +54,9 @@ private Q_SLOTS: void testObjectSimple(); void testObjectSmallKeys(); + void testObjectInsertCopies(); void testArraySimple(); + void testArrayInsertCopies(); void testValueObject(); void testValueArray(); void testObjectNested(); @@ -531,6 +533,75 @@ void tst_QtJson::testObjectSmallKeys() QCOMPARE(data1.end() - data1.begin(), 3); } +void tst_QtJson::testObjectInsertCopies() +{ + { + QJsonObject obj; + obj["prop1"] = "TEST"; + QCOMPARE(obj.size(), 1); + QCOMPARE(obj.value("prop1"), "TEST"); + + obj["prop2"] = obj.value("prop1"); + QCOMPARE(obj.size(), 2); + QCOMPARE(obj.value("prop1"), "TEST"); + QCOMPARE(obj.value("prop2"), "TEST"); + } + { + // see QTBUG-83366 + QJsonObject obj; + obj["value"] = "TEST"; + QCOMPARE(obj.size(), 1); + QCOMPARE(obj.value("value"), "TEST"); + + obj["prop2"] = obj.value("value"); + QCOMPARE(obj.size(), 2); + QCOMPARE(obj.value("value"), "TEST"); + QCOMPARE(obj.value("prop2"), "TEST"); + } + { + QJsonObject obj; + obj["value"] = "TEST"; + QCOMPARE(obj.size(), 1); + QCOMPARE(obj.value("value"), "TEST"); + + // same as previous, but this is a QJsonValueRef + QJsonValueRef rv = obj["prop2"]; + rv = obj["value"]; + QCOMPARE(obj.size(), 2); + QCOMPARE(obj.value("value"), "TEST"); + QCOMPARE(obj.value("prop2"), "TEST"); + } + { + QJsonObject obj; + obj["value"] = "TEST"; + QCOMPARE(obj.size(), 1); + QCOMPARE(obj.value("value"), "TEST"); + + // same as previous, but this is a QJsonValueRef + QJsonValueRef rv = obj["value"]; + obj["prop2"] = rv; + QCOMPARE(obj.size(), 2); + QCOMPARE(obj.value("value"), "TEST"); + QEXPECT_FAIL("", "QTBUG-83398: design flaw: the obj[] call invalidates the QJsonValueRef", Continue); + QCOMPARE(obj.value("prop2"), "TEST"); + } + { + QJsonObject obj; + obj["value"] = "TEST"; + QCOMPARE(obj.size(), 1); + QCOMPARE(obj.value("value"), "TEST"); + + QJsonValueRef v = obj["value"]; + QJsonObject obj2 = obj; + obj.insert("prop2", v); + QCOMPARE(obj.size(), 2); + QCOMPARE(obj.value("value"), "TEST"); + QCOMPARE(obj.value("prop2"), "TEST"); + QCOMPARE(obj2.size(), 1); + QCOMPARE(obj2.value("value"), "TEST"); + } +} + void tst_QtJson::testArraySimple() { QJsonArray array; @@ -584,6 +655,32 @@ void tst_QtJson::testArraySimple() QCOMPARE(array.at(1), QJsonValue(QLatin1String("test"))); } +void tst_QtJson::testArrayInsertCopies() +{ + { + QJsonArray array; + array.append("TEST"); + QCOMPARE(array.size(), 1); + QCOMPARE(array.at(0), "TEST"); + + array.append(array.at(0)); + QCOMPARE(array.size(), 2); + QCOMPARE(array.at(0), "TEST"); + QCOMPARE(array.at(1), "TEST"); + } + { + QJsonArray array; + array.append("TEST"); + QCOMPARE(array.size(), 1); + QCOMPARE(array.at(0), "TEST"); + + array.prepend(array.at(0)); + QCOMPARE(array.size(), 2); + QCOMPARE(array.at(0), "TEST"); + QCOMPARE(array.at(1), "TEST"); + } +} + void tst_QtJson::testValueObject() { QJsonObject object; From 57a57fda78bab652e3fb79677bd828b0f0b49962 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 11:47:33 -0300 Subject: [PATCH 10/17] QCborMap: fix assigning elements from the map to itself Similar to the QJsonObject issue of the previous commit (found with the same tests, but not the same root cause). One fix was that copying of byte data from the QByteArray to itself won't work if the array reallocates. The second was that assign(*that, other.concrete()); fails to set other.d to null after moving. By calling the operator=, we get the proper sequence of events. [ChangeLog][QtCore][QCborMap] Fixed some issues relating to assigning elements from a map to itself. Note: QCborMap is not affected by the design flaw discovered in QJsonObject because it always appends elements (it's unsorted), so existing QCborValueRef references still refer to the same value. Task-number: QTBUG-83366 Change-Id: Ibdc95e9af7bd456a94ecfffd1603df846f46094d Reviewed-by: Ulf Hermann --- src/corelib/serialization/qcborvalue.cpp | 10 ++- .../qcborvalue/tst_qcborvalue.cpp | 71 +++++++++++++++++++ 2 files changed, 78 insertions(+), 3 deletions(-) diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index 63ee5f31585..ebb3665e0ca 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -994,8 +994,12 @@ void QCborContainerPrivate::replaceAt_complex(Element &e, const QCborValue &valu e = value.container->elements.at(value.n); // Copy string data, if any - if (const ByteData *b = value.container->byteData(value.n)) - e.value = addByteData(b->byte(), b->len); + if (const ByteData *b = value.container->byteData(value.n)) { + if (this == value.container) + e.value = addByteData(b->toByteArray(), b->len); + else + e.value = addByteData(b->byte(), b->len); + } if (disp == MoveContainer) value.container->deref(); @@ -2649,7 +2653,7 @@ void QCborValueRef::assign(QCborValueRef that, QCborValue &&other) void QCborValueRef::assign(QCborValueRef that, const QCborValueRef other) { // ### optimize? - assign(that, other.concrete()); + that = other.concrete(); } QCborValue QCborValueRef::concrete(QCborValueRef self) noexcept diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 6d8161c1f99..c70518fbee5 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -79,6 +79,7 @@ private slots: void mapEmptyDetach(); void mapSimpleInitializerList(); void mapMutation(); + void mapMutateWithCopies(); void mapStringValues(); void mapStringKeys(); void mapInsertRemove_data() { basics_data(); } @@ -923,6 +924,76 @@ void tst_QCborValue::mapMutation() QCOMPARE(val[any][3].toMap().size(), 1); } +void tst_QCborValue::mapMutateWithCopies() +{ + { + QCborMap map; + map[QLatin1String("prop1")] = "TEST"; + QCOMPARE(map.size(), 1); + QCOMPARE(map.value("prop1"), "TEST"); + + map[QLatin1String("prop2")] = map.value("prop1"); + QCOMPARE(map.size(), 2); + QCOMPARE(map.value("prop1"), "TEST"); + QCOMPARE(map.value("prop2"), "TEST"); + } + { + // see QTBUG-83366 + QCborMap map; + map[QLatin1String("value")] = "TEST"; + QCOMPARE(map.size(), 1); + QCOMPARE(map.value("value"), "TEST"); + + QCborValue v = map.value("value"); + map[QLatin1String("prop2")] = v; + QCOMPARE(map.size(), 2); + QCOMPARE(map.value("value"), "TEST"); + QCOMPARE(map.value("prop2"), "TEST"); + } + { + QCborMap map; + map[QLatin1String("value")] = "TEST"; + QCOMPARE(map.size(), 1); + QCOMPARE(map.value("value"), "TEST"); + + // same as previous, but this is a QJsonValueRef + QCborValueRef rv = map[QLatin1String("prop2")]; + rv = map[QLatin1String("value")]; + QCOMPARE(map.size(), 2); + QCOMPARE(map.value("value"), "TEST"); + QCOMPARE(map.value("prop2"), "TEST"); + } + { + QCborMap map; + map[QLatin1String("value")] = "TEST"; + QCOMPARE(map.size(), 1); + QCOMPARE(map.value("value"), "TEST"); + + // same as previous, but now we call the operator[] that reallocates + // after we create the source QCborValueRef + QCborValueRef rv = map[QLatin1String("value")]; + map[QLatin1String("prop2")] = rv; + QCOMPARE(map.size(), 2); + QCOMPARE(map.value("value"), "TEST"); + QCOMPARE(map.value("prop2"), "TEST"); + } + { + QCborMap map; + map[QLatin1String("value")] = "TEST"; + QCOMPARE(map.size(), 1); + QCOMPARE(map.value("value"), "TEST"); + + QCborValueRef v = map[QLatin1String("value")]; + QCborMap map2 = map; + map.insert(QLatin1String("prop2"), v); + QCOMPARE(map.size(), 2); + QCOMPARE(map.value("value"), "TEST"); + QCOMPARE(map.value("prop2"), "TEST"); + QCOMPARE(map2.size(), 1); + QCOMPARE(map2.value("value"), "TEST"); + } +} + void tst_QCborValue::arrayPrepend() { QCborArray a; From 954d66e5720b5dd7d31de62364f5e2a8df0bcac3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 11:42:06 -0300 Subject: [PATCH 11/17] QCborArray: fix operator[] that extends the array This was never tested. The infinite loop in QCborContainerPrivate::grow is the proof. [ChangeLog][QtCore][QCborArray] Fixed an infinite loop when operator[] was called with with an index larger than the array's size plus 1. Change-Id: Ibdc95e9af7bd456a94ecfffd1603df3855c73f20 Reviewed-by: Ulf Hermann --- src/corelib/serialization/qcborvalue.cpp | 2 +- .../qcborvalue/tst_qcborvalue.cpp | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index ebb3665e0ca..c45a09ad997 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -956,7 +956,7 @@ QCborContainerPrivate *QCborContainerPrivate::grow(QCborContainerPrivate *d, qsi d = detach(d, index + 1); Q_ASSERT(d); int j = d->elements.size(); - while (j < index) + while (j++ < index) d->append(Undefined()); return d; } diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index c70518fbee5..05cf199abe6 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -65,6 +65,7 @@ private slots: void arrayEmptyDetach(); void arrayInitializerList(); void arrayMutation(); + void arrayMutateWithCopies(); void arrayPrepend(); void arrayInsertRemove_data() { basics_data(); } void arrayInsertRemove(); @@ -817,6 +818,59 @@ void tst_QCborValue::arrayMutation() QCOMPARE(val[2].toArray().size(), 5); } +void tst_QCborValue::arrayMutateWithCopies() +{ + { + QCborArray array; + array.append("TEST"); + QCOMPARE(array.size(), 1); + QCOMPARE(array.at(0), "TEST"); + + array.append(array.at(0)); + QCOMPARE(array.size(), 2); + QCOMPARE(array.at(0), "TEST"); + QCOMPARE(array.at(1), "TEST"); + } + { + QCborArray array; + array.append("TEST"); + QCOMPARE(array.size(), 1); + QCOMPARE(array.at(0), "TEST"); + + // same as previous, but with prepend() not append() + array.prepend(array.at(0)); + QCOMPARE(array.size(), 2); + QCOMPARE(array.at(0), "TEST"); + QCOMPARE(array.at(1), "TEST"); + } + { + QCborArray array; + array.append("TEST"); + QCOMPARE(array.size(), 1); + QCOMPARE(array.at(0), "TEST"); + + // same as previous, but using a QCborValueRef + QCborValueRef rv = array[0]; + array.prepend(rv); + QCOMPARE(array.size(), 2); + QCOMPARE(array.at(0), "TEST"); + QCOMPARE(array.at(1), "TEST"); + } + { + QCborArray array; + array.append("TEST"); + QCOMPARE(array.size(), 1); + QCOMPARE(array.at(0), "TEST"); + + // same as previous, but now extending the array + QCborValueRef rv = array[0]; + array[2] = rv; + QCOMPARE(array.size(), 3); + QCOMPARE(array.at(0), "TEST"); + QCOMPARE(array.at(2), "TEST"); + } +} + void tst_QCborValue::mapMutation() { QCborMap m; From 712ed3d5d6645ef4a091e22f508de1ada8fdf94c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 8 Apr 2020 13:25:13 +0200 Subject: [PATCH 12/17] Switch to using versioned deprecated macros Change-Id: I4728e6ecc7218a6c98fd3a10e50e6edd1704fb83 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/serialization/qtextstream.h | 48 ++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/corelib/serialization/qtextstream.h b/src/corelib/serialization/qtextstream.h index 0d8a9a548e5..97d596137ec 100644 --- a/src/corelib/serialization/qtextstream.h +++ b/src/corelib/serialization/qtextstream.h @@ -271,30 +271,30 @@ Q_CORE_EXPORT QTextStream &ws(QTextStream &s); #if QT_DEPRECATED_SINCE(5, 15) // This namespace only exists for 'using namespace' declarations. namespace QTextStreamFunctions { -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::bin") QTextStream &bin(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::oct") QTextStream &oct(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::dec") QTextStream &dec(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::hex") QTextStream &hex(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::showbase") QTextStream &showbase(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::forcesign") QTextStream &forcesign(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::forcepoint") QTextStream &forcepoint(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::noshowbase") QTextStream &noshowbase(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::noforcesign") QTextStream &noforcesign(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::noforcepoint") QTextStream &noforcepoint(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::uppercasebase") QTextStream &uppercasebase(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::uppercasedigits") QTextStream &uppercasedigits(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::lowercasebase") QTextStream &lowercasebase(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::lowercasedigits") QTextStream &lowercasedigits(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::fixed") QTextStream &fixed(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::scientific") QTextStream &scientific(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::left") QTextStream &left(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::right") QTextStream &right(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::center") QTextStream ¢er(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::endl") QTextStream &endl(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::flush") QTextStream &flush(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::reset") QTextStream &reset(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::bom") QTextStream &bom(QTextStream &s); -Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::ws") QTextStream &ws(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::bin") QTextStream &bin(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::oct") QTextStream &oct(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::dec") QTextStream &dec(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::hex") QTextStream &hex(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::showbase") QTextStream &showbase(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::forcesign") QTextStream &forcesign(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::forcepoint") QTextStream &forcepoint(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::noshowbase") QTextStream &noshowbase(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::noforcesign") QTextStream &noforcesign(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::noforcepoint") QTextStream &noforcepoint(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::uppercasebase") QTextStream &uppercasebase(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::uppercasedigits") QTextStream &uppercasedigits(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::lowercasebase") QTextStream &lowercasebase(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::lowercasedigits") QTextStream &lowercasedigits(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::fixed") QTextStream &fixed(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::scientific") QTextStream &scientific(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::left") QTextStream &left(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::right") QTextStream &right(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::center") QTextStream ¢er(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::endl") QTextStream &endl(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::flush") QTextStream &flush(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::reset") QTextStream &reset(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::bom") QTextStream &bom(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X(5, 15, "Use Qt::ws") QTextStream &ws(QTextStream &s); } // namespace QTextStreamFunctions QT_WARNING_PUSH From f0ec2eb151f5e3d9a26ce86a1ba86d41f1fe24c4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 18:12:14 -0300 Subject: [PATCH 13/17] Fix warning about QMetaObject::isEditable() being deprecated Change-Id: Ibdc95e9af7bd456a94ecfffd1603f482445bff28 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qmetaobjectbuilder.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index 4ecc340787b..0f018074e4b 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -575,6 +575,16 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty return QMetaPropertyBuilder(this, index); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED +static bool deprecatedIsEditable(const QMetaProperty &prototype) +{ + return prototype.isEditable(); +} +QT_WARNING_POP +#endif + /*! Adds a new property to this class that has the same information as \a prototype. This is used to clone the properties of an existing @@ -592,7 +602,7 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot property.setDesignable(prototype.isDesignable()); property.setScriptable(prototype.isScriptable()); property.setStored(prototype.isStored()); - property.setEditable(prototype.isEditable()); + property.setEditable(deprecatedIsEditable(prototype)); property.setUser(prototype.isUser()); property.setStdCppSet(prototype.hasStdCppSet()); property.setEnumOrFlag(prototype.isEnumType()); From 7cd2d2b7516211d233f657edd98903911536b1ff Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 14:26:50 -0300 Subject: [PATCH 14/17] tst_QFileInfo: fix running with systems without /etc/passwd Clear Linux containers running as root may have no /etc/passwd. But they'll have /etc/machine-id because systemd creates that. Also test /proc/version (a Linux-specific file) because that isn't writeable even by root. Take the opportunity to check with access() instead of assuming root and only root can write to the file. Change-Id: Ibdc95e9af7bd456a94ecfffd1603e8359604752b Reviewed-by: Volker Hilsheimer --- tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 09ef0ea44fa..1788c044941 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1887,10 +1887,11 @@ void tst_QFileInfo::isWritable() #if defined (Q_OS_QNX) // On QNX /etc is usually on a read-only filesystem QVERIFY(!QFileInfo("/etc/passwd").isWritable()); #elif defined (Q_OS_UNIX) && !defined(Q_OS_VXWORKS) // VxWorks does not have users/groups - if (::getuid() == 0) - QVERIFY(QFileInfo("/etc/passwd").isWritable()); - else - QVERIFY(!QFileInfo("/etc/passwd").isWritable()); + for (const char *attempt : { "/etc/passwd", "/etc/machine-id", "/proc/version" }) { + if (access(attempt, F_OK) == -1) + continue; + QCOMPARE(QFileInfo(attempt).isWritable(), ::access(attempt, W_OK) == 0); + } #endif } From cf4a8b12fa277c2ea218f022607934f60fed1a06 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 9 Apr 2020 11:50:30 +0200 Subject: [PATCH 15/17] Remove more calls to deprecated TouchPoint functions Followup to ed3ed0b9db97a8fab0c03add23228b6b0a96f171 68916fede41d1eca5d07eb6b1db518d41a007616 and 3c159957f863cf8d367a9261e7016e52cd0348c1. In QWindowSystemInterfacePrivate::fromNativeTouchPoints() and QWindowSystemInterfacePrivate::toNativeTouchPoints() we continue using struct TouchPoint's QRectF area as storage for the screen position + ellipse diameters; as the comment says, this is _unrotated_, meaning that rotation is stored separately, and area should not be construed as the bounding box of the rotated ellipse. (In Qt 6 we can make the QPA touchpoint look the same as the QTouchEvent::TouchPoint to eliminate the need to calculate the center of the rect.) In QGraphicsScenePrivate::updateTouchPointsForItem(), setRect() sets the position and the ellipse diameters, but the latter is redundant because the purpose of this function is to localize a touchpoint to the coordinate system of a particular QGraphicsItem. Ellipse diameters should stay the same. In QApplicationPrivate::updateTouchPointsForWidget(), as in QGraphicsScene, we are localizing touchpoints to a widget and to the screen that the widget is shown on, so only the position needs to be set, while preserving the sub-pixel resolution that mapFromGlobal(QPoint) loses. Fixes: QTBUG-83403 Change-Id: I61d29e14cbe38567767b164af6ae895082c5e1a1 Reviewed-by: Volker Hilsheimer --- src/gui/kernel/qwindowsysteminterface.cpp | 9 +++++---- src/widgets/graphicsview/qgraphicsscene.cpp | 4 ---- src/widgets/kernel/qapplication.cpp | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index aefb3776831..90541eb3147 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -687,9 +687,8 @@ QList states |= point->state; p.setState(point->state); - const QPointF screenPos = point->area.center(); - p.setScreenPos(QHighDpi::fromNativePixels(screenPos, window)); - p.setScreenRect(QHighDpi::fromNativePixels(point->area, window)); + p.setScreenPos(QHighDpi::fromNativePixels(point->area.center(), window)); + p.setEllipseDiameters(point->area.size()); // The local pos and rect are not set, they will be calculated // when the event gets processed by QGuiApplication. @@ -750,7 +749,9 @@ QList p.id = pt.id(); p.flags = pt.flags(); p.normalPosition = QHighDpi::toNativeLocalPosition(pt.normalizedPos(), window); - p.area = QHighDpi::toNativePixels(pt.screenRect(), window); + QRectF area(QPointF(), pt.ellipseDiameters()); + area.moveCenter(pt.screenPos()); + p.area = QHighDpi::toNativePixels(area, window); p.pressure = pt.pressure(); p.state = pt.state(); p.velocity = QHighDpi::toNativePixels(pt.velocity(), window); diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 38c68b8fa56..f2ff658d3bd 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -5920,10 +5920,6 @@ void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouch item->d_ptr->genericMapFromSceneTransform(static_cast(touchEvent->target())); for (auto &touchPoint : touchEvent->_touchPoints) { - // Deprecated TouchPoint::setRect clobbers ellipseDiameters, restore - const QSizeF ellipseDiameters = touchPoint.ellipseDiameters(); - touchPoint.setRect(mapFromScene.map(touchPoint.sceneRect()).boundingRect()); - touchPoint.setEllipseDiameters(ellipseDiameters); touchPoint.setPos(mapFromScene.map(touchPoint.scenePos())); touchPoint.setStartPos(mapFromScene.map(touchPoint.startScenePos())); touchPoint.setLastPos(mapFromScene.map(touchPoint.lastScenePos())); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 80e4aa525e3..4ea70096e81 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4168,7 +4168,7 @@ bool QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i]; // preserve the sub-pixel resolution - const QPointF screenPos = touchPoint.screenRect().center(); + const QPointF screenPos = touchPoint.screenPos(); const QPointF delta = screenPos - screenPos.toPoint(); touchPoint.d->pos = widget->mapFromGlobal(screenPos.toPoint()) + delta; From 9de8313b0b432cae48ef47a73eba1e465ae0d8fc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 8 Apr 2020 18:35:08 -0300 Subject: [PATCH 16/17] Fix warning about deprecated QComboBox::AdjustToMinimumContentsLength Change-Id: Ibdc95e9af7bd456a94ecfffd1603f5c25dabf78e Reviewed-by: Volker Hilsheimer --- src/widgets/widgets/qcombobox.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index b1f2d40d384..607709d2187 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -385,6 +385,16 @@ int QComboBoxPrivate::computeWidthHint() const return tmp.width(); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED +static constexpr QComboBox::SizeAdjustPolicy deprecatedAdjustToMinimumContentsLength() +{ + return QComboBox::AdjustToMinimumContentsLength; +} +QT_WARNING_POP +#endif + QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const { Q_Q(const QComboBox); @@ -412,10 +422,11 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const } } break; - case QComboBox::AdjustToMinimumContentsLength: + case deprecatedAdjustToMinimumContentsLength(): for (int i = 0; i < count && !hasIcon; ++i) hasIcon = !q->itemIcon(i).isNull(); - default: + break; + case QComboBox::AdjustToMinimumContentsLengthWithIcon: ; } } else { @@ -1792,7 +1803,7 @@ void QComboBox::setMinimumContentsLength(int characters) d->minimumContentsLength = characters; if (d->sizeAdjustPolicy == AdjustToContents - || d->sizeAdjustPolicy == AdjustToMinimumContentsLength + || d->sizeAdjustPolicy == deprecatedAdjustToMinimumContentsLength() || d->sizeAdjustPolicy == AdjustToMinimumContentsLengthWithIcon) { d->sizeHint = QSize(); d->adjustComboBoxSize(); From 1ec350e35fcea87c527b36cf429b595731059240 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 10 Apr 2020 12:55:43 +0200 Subject: [PATCH 17/17] Stop using obsolete TouchPoint rect accessors in tests and examples Followup to cf4a8b12fa277c2ea218f022607934f60fed1a06 68916fede41d1eca5d07eb6b1db518d41a007616 and 3c159957f863cf8d367a9261e7016e52cd0348c1. Task-number: QTBUG-83403 Change-Id: Ieaf418860c565dbe883384e7f296a829fbfa1e33 Reviewed-by: Volker Hilsheimer --- .../touch/fingerpaint/scribblearea.cpp | 12 +- .../kernel/qtouchevent/tst_qtouchevent.cpp | 119 ++++++++++-------- 2 files changed, 75 insertions(+), 56 deletions(-) diff --git a/examples/widgets/touch/fingerpaint/scribblearea.cpp b/examples/widgets/touch/fingerpaint/scribblearea.cpp index e490495cd93..4af0ec8e7e7 100644 --- a/examples/widgets/touch/fingerpaint/scribblearea.cpp +++ b/examples/widgets/touch/fingerpaint/scribblearea.cpp @@ -205,22 +205,24 @@ bool ScribbleArea::event(QEvent *event) continue; default: { - QRectF rect = touchPoint.rect(); - if (rect.isEmpty()) { + QSizeF diams = touchPoint.ellipseDiameters(); + if (diams.isEmpty()) { qreal diameter = MaximumDiameter; if (touch->device()->capabilities() & QTouchDevice::Pressure) diameter = MinimumDiameter + (MaximumDiameter - MinimumDiameter) * touchPoint.pressure(); - rect.setSize(QSizeF(diameter, diameter)); + diams = QSizeF(diameter, diameter); } QPainter painter(&image); painter.setPen(Qt::NoPen); painter.setBrush(myPenColors.at(touchPoint.id() % myPenColors.count())); - painter.drawEllipse(rect); + painter.drawEllipse(touchPoint.pos(), diams.width() / 2, diams.height() / 2); painter.end(); modified = true; - int rad = 2; + const int rad = 2; + QRectF rect(QPointF(), diams); + rect.moveCenter(touchPoint.pos()); update(rect.toRect().adjusted(-rad,-rad, +rad, +rad)); } break; diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 54bb8fe0bd1..ff4f4111fec 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the $MODULE$ of the Qt Toolkit. @@ -656,9 +656,10 @@ void tst_QTouchEvent::basicRawEventTranslation() QCOMPARE(touchBeginPoint.normalizedPos(), rawTouchPoint.normalizedPos()); QCOMPARE(touchBeginPoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); QCOMPARE(touchBeginPoint.lastNormalizedPos(), touchBeginPoint.normalizedPos()); - QCOMPARE(touchBeginPoint.rect(), QRectF(pos, QSizeF(0, 0))); - QCOMPARE(touchBeginPoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); - QCOMPARE(touchBeginPoint.sceneRect(), touchBeginPoint.screenRect()); + QCOMPARE(touchBeginPoint.pos(), pos); + QCOMPARE(touchBeginPoint.screenPos(), rawTouchPoint.screenPos()); + QCOMPARE(touchBeginPoint.scenePos(), touchBeginPoint.scenePos()); + QCOMPARE(touchBeginPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(touchBeginPoint.pressure(), qreal(1.)); QCOMPARE(touchBeginPoint.velocity(), QVector2D()); if (!QHighDpiScaling::isActive()) @@ -691,9 +692,10 @@ void tst_QTouchEvent::basicRawEventTranslation() QCOMPARE(touchUpdatePoint.normalizedPos(), rawTouchPoint.normalizedPos()); QCOMPARE(touchUpdatePoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); QCOMPARE(touchUpdatePoint.lastNormalizedPos(), touchBeginPoint.normalizedPos()); - QCOMPARE(touchUpdatePoint.rect(), QRectF(pos + delta, QSizeF(0, 0))); - QCOMPARE(touchUpdatePoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); - QCOMPARE(touchUpdatePoint.sceneRect(), touchUpdatePoint.screenRect()); + QCOMPARE(touchUpdatePoint.pos(), pos + delta); + QCOMPARE(touchUpdatePoint.screenPos(), rawTouchPoint.screenPos()); + QCOMPARE(touchUpdatePoint.scenePos(), touchUpdatePoint.scenePos()); + QCOMPARE(touchUpdatePoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(touchUpdatePoint.pressure(), qreal(1.)); // releasing the point translates to TouchEnd @@ -723,9 +725,10 @@ void tst_QTouchEvent::basicRawEventTranslation() QCOMPARE(touchEndPoint.normalizedPos(), rawTouchPoint.normalizedPos()); QCOMPARE(touchEndPoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); QCOMPARE(touchEndPoint.lastNormalizedPos(), touchUpdatePoint.normalizedPos()); - QCOMPARE(touchEndPoint.rect(), QRectF(pos + delta + delta, QSizeF(0, 0))); - QCOMPARE(touchEndPoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); - QCOMPARE(touchEndPoint.sceneRect(), touchEndPoint.screenRect()); + QCOMPARE(touchEndPoint.pos(), pos + delta + delta); + QCOMPARE(touchEndPoint.screenPos(), rawTouchPoint.screenPos()); + QCOMPARE(touchEndPoint.scenePos(), touchEndPoint.scenePos()); + QCOMPARE(touchEndPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(touchEndPoint.pressure(), qreal(0.)); } @@ -800,9 +803,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); - QCOMPARE(leftTouchPoint.rect(), QRectF(leftPos, QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.sceneRect(), QRectF(leftScreenPos, QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.screenRect(), QRectF(leftScreenPos, QSizeF(0, 0))); + QCOMPARE(leftTouchPoint.pos(), leftPos); + QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); + QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); + QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchBeginPoints.first(); @@ -820,9 +824,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); - QCOMPARE(rightTouchPoint.rect(), QRectF(rightPos, QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.sceneRect(), QRectF(rightScreenPos, QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.screenRect(), QRectF(rightScreenPos, QSizeF(0, 0))); + QCOMPARE(rightTouchPoint.pos(), rightPos); + QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); + QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); + QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); } @@ -864,9 +869,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); - QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); + QCOMPARE(leftTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); + QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); + QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); + QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchUpdatePoints.first(); @@ -884,9 +890,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); - QCOMPARE(rightTouchPoint.rect(), QRectF(rightWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); + QCOMPARE(rightTouchPoint.pos(), rightWidget.mapFromParent(centerPos.toPoint())); + QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); + QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); + QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); } @@ -928,9 +935,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); - QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); + QCOMPARE(leftTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); + QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); + QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); + QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.pressure(), qreal(0.)); QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchEndPoints.first(); @@ -948,9 +956,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); - QCOMPARE(rightTouchPoint.rect(), QRectF(rightWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); + QCOMPARE(rightTouchPoint.pos(), rightWidget.mapFromParent(centerPos.toPoint())); + QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); + QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); + QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.pressure(), qreal(0.)); } } @@ -1177,9 +1186,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); - QCOMPARE(leftTouchPoint.rect(), QRectF(leftPos, QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.sceneRect(), QRectF(leftScreenPos, QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.screenRect(), QRectF(leftScreenPos, QSizeF(0, 0))); + QCOMPARE(leftTouchPoint.pos(), leftPos); + QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); + QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); + QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchBeginPoints.at(1); @@ -1197,9 +1207,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); - QCOMPARE(rightTouchPoint.rect(), QRectF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()), QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.sceneRect(), QRectF(rightScreenPos, QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.screenRect(), QRectF(rightScreenPos, QSizeF(0, 0))); + QCOMPARE(rightTouchPoint.pos(), rightWidget.mapFromParent(rightScreenPos.toPoint())); + QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); + QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); + QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); } @@ -1241,9 +1252,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); - QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); + QCOMPARE(leftTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); + QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); + QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); + QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchUpdatePoints.at(1); @@ -1261,9 +1273,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); - QCOMPARE(rightTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); + QCOMPARE(rightTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); + QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); + QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); + QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); } @@ -1305,9 +1318,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); - QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); - QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); + QCOMPARE(leftTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); + QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); + QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); + QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(leftTouchPoint.pressure(), qreal(0.)); QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchEndPoints.at(1); @@ -1325,9 +1339,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); - QCOMPARE(rightTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); - QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); + QCOMPARE(rightTouchPoint.pos(), leftWidget.mapFromParent(centerPos.toPoint())); + QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); + QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); + QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0)); QCOMPARE(rightTouchPoint.pressure(), qreal(0.)); } } @@ -1858,13 +1873,13 @@ void tst_QTouchEvent::testMultiDevice() tp.id = 0; tp.state = Qt::TouchPointPressed; const QPoint screenOrigin = w.screen()->geometry().topLeft(); - const QRect area0(120, 120, 20, 20); + const QRectF area0(120, 120, 20, 20); tp.area = QHighDpi::toNative(area0, QHighDpiScaling::factor(&w), screenOrigin); pointsOne.append(tp); pointsTwo.append(tp); tp.id = 1; - const QRect area1(140, 140, 20, 20); + const QRectF area1(140, 140, 20, 20); tp.area = QHighDpi::toNative(area1, QHighDpiScaling::factor(&w), screenOrigin); pointsTwo.append(tp); @@ -1880,12 +1895,14 @@ void tst_QTouchEvent::testMultiDevice() QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1); QCOMPARE(filter.d.value(deviceTwo).points.count(), 2); - QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).screenRect(), QRectF(area0)); + QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).screenPos(), area0.center()); + QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).ellipseDiameters(), area0.size()); QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).state(), pointsOne[0].state); - QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenRect(), QRectF(area0)); + QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenPos(), area0.center()); + QCOMPARE(filter.d.value(deviceTwo).points.at(0).ellipseDiameters(), area0.size()); QCOMPARE(filter.d.value(deviceTwo).points.at(0).state(), pointsTwo[0].state); - QCOMPARE(filter.d.value(deviceTwo).points.at(1).screenRect(), QRectF(area1)); + QCOMPARE(filter.d.value(deviceTwo).points.at(1).screenPos(), area1.center()); QCOMPARE(filter.d.value(deviceTwo).points.at(1).state(), pointsTwo[1].state); }