From c642f44448752972f89a121b125873f187e088b3 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 25 Jan 2019 17:10:14 +0100 Subject: Tooling: Use fprintf rather than qDebug() for debug warning This warning is generated from a statically called ctor. At that point the system facilities to run QMessageLogger may not be in place, yet. In addition, we actually don't want the message to go through the regular QMessageLogger redirection and possibly filtering. The message should always be shown. Fixes: QTBUG-73217 Change-Id: Ief192dae8c38d5d94996ee9285e54b5cbd714f4b Reviewed-by: Andy Shaw Reviewed-by: Simon Hausmann (cherry-picked from commit 15525d2a309a6028d548797bc777e38905f36c46) --- src/qml/debugger/qqmldebug.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qml/debugger/qqmldebug.cpp b/src/qml/debugger/qqmldebug.cpp index 6246fb4207..6532576e03 100644 --- a/src/qml/debugger/qqmldebug.cpp +++ b/src/qml/debugger/qqmldebug.cpp @@ -44,16 +44,16 @@ #include #include +#include + QT_REQUIRE_CONFIG(qml_debug); QT_BEGIN_NAMESPACE QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning) { - if (!QQmlEnginePrivate::qml_debugging_enabled - && printWarning) { - qDebug("QML debugging is enabled. Only use this in a safe environment."); - } + if (!QQmlEnginePrivate::qml_debugging_enabled && printWarning) + fprintf(stderr, "QML debugging is enabled. Only use this in a safe environment.\n"); QQmlEnginePrivate::qml_debugging_enabled = true; } -- cgit v1.2.3 From 2cd99e2b69779c12309dd454584aa9546029323e Mon Sep 17 00:00:00 2001 From: Jeremy Powell Date: Thu, 18 Apr 2019 15:59:50 +1200 Subject: Fix memory leak with QQuickEventPoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Store PointVelocityData by value in the QMap to avoid leaking memory. This also appears to be slightly faster than heap allocation, with the struct being relatively small (24 or 32 bytes depending on qreal). Fixes: QTBUG-73182 Change-Id: Ibd9374746b76fd5b78c23283d278b6af42907c96 Reviewed-by: Shawn Rutledge Reviewed-by: Jan Arve Sæther --- src/quick/items/qquickevents.cpp | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index c43eab6b8a..28b217b7b3 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -1135,10 +1135,10 @@ void QQuickEventTouchPoint::reset(const QTouchEvent::TouchPoint &tp, ulong times struct PointVelocityData { QVector2D velocity; QPointF pos; - ulong timestamp; + ulong timestamp = 0; }; -typedef QMap PointDataForPointIdMap; +typedef QMap PointDataForPointIdMap; Q_GLOBAL_STATIC(PointDataForPointIdMap, g_previousPointData) static const int PointVelocityAgeLimit = 500; // milliseconds @@ -1149,42 +1149,36 @@ static const int PointVelocityAgeLimit = 500; // milliseconds */ QVector2D QQuickEventPoint::estimatedVelocity() const { - PointVelocityData *prevPoint = g_previousPointData->value(m_pointId); - if (!prevPoint) { + auto prevPointIt = g_previousPointData->find(m_pointId); + auto end = g_previousPointData->end(); + if (prevPointIt == end) { // cleanup events older than PointVelocityAgeLimit - auto end = g_previousPointData->end(); for (auto it = g_previousPointData->begin(); it != end; ) { - PointVelocityData *data = it.value(); - if (m_timestamp - data->timestamp > PointVelocityAgeLimit) { + if (m_timestamp - it->timestamp > PointVelocityAgeLimit) it = g_previousPointData->erase(it); - delete data; - } else { + else ++it; - } } - // TODO optimize: stop this dynamic memory thrashing - prevPoint = new PointVelocityData; - prevPoint->velocity = QVector2D(); - prevPoint->timestamp = 0; - prevPoint->pos = QPointF(); - g_previousPointData->insert(m_pointId, prevPoint); + prevPointIt = g_previousPointData->insert(m_pointId, PointVelocityData()); } - const ulong timeElapsed = m_timestamp - prevPoint->timestamp; + + auto &prevPoint = prevPointIt.value(); + const ulong timeElapsed = m_timestamp - prevPoint.timestamp; if (timeElapsed == 0) // in case we call estimatedVelocity() twice on the same QQuickEventPoint return m_velocity; QVector2D newVelocity; - if (prevPoint->timestamp != 0) - newVelocity = QVector2D(m_scenePos - prevPoint->pos)/timeElapsed; + if (prevPoint.timestamp != 0) + newVelocity = QVector2D(m_scenePos - prevPoint.pos) / timeElapsed; // VERY simple kalman filter: does a weighted average // where the older velocities get less and less significant static const float KalmanGain = 0.7f; QVector2D filteredVelocity = newVelocity * KalmanGain + m_velocity * (1.0f - KalmanGain); - prevPoint->velocity = filteredVelocity; - prevPoint->pos = m_scenePos; - prevPoint->timestamp = m_timestamp; + prevPoint.velocity = filteredVelocity; + prevPoint.pos = m_scenePos; + prevPoint.timestamp = m_timestamp; return filteredVelocity; } -- cgit v1.2.3 From 0e039c17ccb97071fd4210ac958a5e9b999c44f9 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 24 Apr 2019 11:29:18 +0200 Subject: Use resource path for test data on Android and iOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qtbase/mkspecs/features/testcase.prf already generates a .qrc file containing the files in TESTDATA, so instead of trying to copy QML files to the device, we can just use the existing resources. This fixes the following failure, which affects all tests using util.pri: I/QTestLib( 7143): FAIL! : tst_qquickapplication::initTestCase() 'QDir::setCurrent(m_directory)' returned FALSE. (Could not chdir to :/) Change-Id: Iddfd227c402dbe80aeaa9742a52690d3d8049e46 Reviewed-by: Andy Shaw Reviewed-by: Tor Arne Vestbø Reviewed-by: Simon Hausmann --- tests/auto/shared/util.cpp | 7 +++++-- tests/auto/shared/util.pri | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp index 189398f0c2..96876428f6 100644 --- a/tests/auto/shared/util.cpp +++ b/tests/auto/shared/util.cpp @@ -40,7 +40,9 @@ QQmlDataTest::QQmlDataTest() : m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0)), #endif - m_dataDirectoryUrl(QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/'))) + m_dataDirectoryUrl(m_dataDirectory.startsWith(QLatin1Char(':')) + ? QUrl(QLatin1String("qrc") + m_dataDirectory) + : QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/'))) { m_instance = this; } @@ -54,7 +56,8 @@ void QQmlDataTest::initTestCase() { QVERIFY2(!m_dataDirectory.isEmpty(), "'data' directory not found"); m_directory = QFileInfo(m_dataDirectory).absolutePath(); - QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory)); + if (m_dataDirectoryUrl.scheme() != QLatin1String("qrc")) + QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory)); } QString QQmlDataTest::testFile(const QString &fileName) const diff --git a/tests/auto/shared/util.pri b/tests/auto/shared/util.pri index a05af4773d..b54897ac2c 100644 --- a/tests/auto/shared/util.pri +++ b/tests/auto/shared/util.pri @@ -3,4 +3,8 @@ INCLUDEPATH += $$PWD HEADERS += $$PWD/util.h SOURCES += $$PWD/util.cpp -DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\" +android|ios { + DEFINES += QT_QMLTEST_DATADIR=\\\":/data\\\" +} else { + DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\" +} -- cgit v1.2.3 From 138d5c82f11bdcd9c6594d1e539631b9560353ae Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 23 Apr 2019 13:13:14 +0200 Subject: Revert "Optimize some Lookups" This reverts commit 2beb77c81a1f3585c15099a09ba8b2192c6da824. To optimize lookup in case of heapObject we cast its value to Object. This unfortunately does not work well when the value type of heap object is actually a string. Task-number: QTBUG-75335 Change-Id: I55d7c9e0d41f3be617ca7141a4121de3a56f8eef Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4lookup.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 54bce7d7b3..f8999342d1 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -242,9 +242,6 @@ ReturnedValue Lookup::getter0Inlinegetter0Inline(Lookup *l, ExecutionEngine *eng return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset)->asReturnedValue(); if (l->objectLookupTwoClasses.ic2 == o->internalClass) return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset2)->asReturnedValue(); - Value obj = Value::fromHeapObject(o); - Value str = Value::fromHeapObject(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]); - return static_cast(obj).get(&static_cast(str)); } l->getter = getterFallback; return getterFallback(l, engine, object); @@ -260,9 +257,6 @@ ReturnedValue Lookup::getter0Inlinegetter0MemberData(Lookup *l, ExecutionEngine return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset)->asReturnedValue(); if (l->objectLookupTwoClasses.ic2 == o->internalClass) return o->memberData->values.data()[l->objectLookupTwoClasses.offset2].asReturnedValue(); - Value obj = Value::fromHeapObject(o); - Value str = Value::fromHeapObject(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]); - return static_cast(obj).get(&static_cast(str)); } l->getter = getterFallback; return getterFallback(l, engine, object); @@ -278,9 +272,6 @@ ReturnedValue Lookup::getter0MemberDatagetter0MemberData(Lookup *l, ExecutionEng return o->memberData->values.data()[l->objectLookupTwoClasses.offset].asReturnedValue(); if (l->objectLookupTwoClasses.ic2 == o->internalClass) return o->memberData->values.data()[l->objectLookupTwoClasses.offset2].asReturnedValue(); - Value obj = Value::fromHeapObject(o); - Value str = Value::fromHeapObject(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]); - return static_cast(obj).get(&static_cast(str)); } l->getter = getterFallback; return getterFallback(l, engine, object); @@ -296,9 +287,7 @@ ReturnedValue Lookup::getterProtoTwoClasses(Lookup *l, ExecutionEngine *engine, return l->protoLookupTwoClasses.data->asReturnedValue(); if (l->protoLookupTwoClasses.protoId2 == o->internalClass->protoId) return l->protoLookupTwoClasses.data2->asReturnedValue(); - Value obj = Value::fromHeapObject(o); - Value str = Value::fromHeapObject(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]); - return static_cast(obj).get(&static_cast(str)); + return getterFallback(l, engine, object); } l->getter = getterFallback; return getterFallback(l, engine, object); -- cgit v1.2.3 From 6b6b379135e5022a3425c3135cebb58fc0f3100e Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Thu, 25 Apr 2019 08:45:24 +0200 Subject: Fix crash in QQmlMetaType::freeUnusedTypesAndCaches() Fix crash when QQmlMetaType::freeUnusedTypesAndCaches() is being called during program exit, i.e. when the parent QJSEngine instance is being destructed during exit(). Sample backtrace: #0 QQmlMetaType::freeUnusedTypesAndCaches () at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/qml/qqmlmetatype.cpp:2600 #1 0x00007fffe12fce83 in QJSEnginePrivate::~QJSEnginePrivate (this=0x60c001c0b040, __in_chrg=) at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/jsapi/qjsengine.cpp:982 #2 0x00007fffe12fce9f in QJSEnginePrivate::~QJSEnginePrivate (this=0x60c001c0b040, __in_chrg=) at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/jsapi/qjsengine.cpp:980 #3 0x00007ffff53650c3 in QScopedPointerDeleter::cleanup (pointer=) at ../../include/QtCore/../../../../../src/qt5.12/qtbase/src/corelib/tools/qscopedpointer.h:52 #4 QScopedPointer >::~QScopedPointer (this=0x60300178b3a8, __in_chrg=) at ../../include/QtCore/../../../../../src/qt5.12/qtbase/src/corelib/tools/qscopedpointer.h:107 #5 QObject::~QObject (this=, __in_chrg=) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:891 #6 0x00007fffe12ff572 in QJSEngine::~QJSEngine (this=0x60300178b3a0, __in_chrg=) at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/jsapi/qjsengine.cpp:379 #7 0x00007fffe12ff583 in QJSEngine::~QJSEngine (this=0x60300178b3a0, __in_chrg=) at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/jsapi/qjsengine.cpp:375 #8 0x00007ffff5363cc4 in QObjectPrivate::deleteChildren (this=this@entry=0x60b00016c380) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:2010 #9 0x00007ffff53650f5 in QObject::~QObject (this=, __in_chrg=) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:1032 #10 0x00007fffe103b43b in Grantlee::ScriptableTagLibrary::~ScriptableTagLibrary (this=0x607000ba4c00) at templates/lib/Grantlee_Templates_autogen/MTDBPGIEEV/../../../../../../../src/kf5/grantlee/templates/scriptabletags/scriptabletags.h:58 #11 0x00007fffe103b469 in Grantlee::ScriptableTagLibrary::~ScriptableTagLibrary (this=0x607000ba4c00) at templates/lib/Grantlee_Templates_autogen/MTDBPGIEEV/../../../../../../../src/kf5/grantlee/templates/scriptabletags/scriptabletags.h:58 #12 0x00007ffff5363cc4 in QObjectPrivate::deleteChildren (this=this@entry=0x60b00016c0c0) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:2010 #13 0x00007ffff53650f5 in QObject::~QObject (this=, __in_chrg=) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:1032 #14 0x00007fffe0fef704 in Grantlee::Engine::~Engine (this=0x60300178a2c0) at /home/kfunk/devel/src/kf5/grantlee/templates/lib/engine.cpp:60 #15 0x00007fffdf2e2482 in GrantleeTheme::Engine::~Engine (this=0x60300178a2c0) at /home/kfunk/devel/src/kf5/grantleetheme/src/grantleethemeengine.cpp:54 #16 0x00007fffdf2e24a9 in GrantleeTheme::Engine::~Engine (this=0x60300178a2c0) at /home/kfunk/devel/src/kf5/grantleetheme/src/grantleethemeengine.cpp:52 #17 0x00007ffff3f4f8d1 in MessageViewer::MessagePartRendererManager::~MessagePartRendererManager (this=0x7ffff40c8ab0 ) at /home/kfunk/devel/src/kf5/messagelib/messageviewer/src/messagepartthemes/default /messagepartrenderermanager.cpp:118 #18 0x00007ffff4b442ac in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #19 0x00007ffff4b443da in exit () from /lib/x86_64-linux-gnu/libc.so.6 Also see: https://bugs.kde.org/show_bug.cgi?id=406871 Change-Id: If5676880c87f1fa2405701a439e1a0037dce045c Reviewed-by: Ulf Hermann --- src/qml/qml/qqmlmetatype.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 1873a99a71..c0628c3523 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -2593,6 +2593,10 @@ void QQmlMetaType::freeUnusedTypesAndCaches() QMutexLocker lock(metaTypeDataLock()); QQmlMetaTypeData *data = metaTypeData(); + // in case this is being called during program exit, `data` might be destructed already + if (!data) + return; + { bool deletedAtLeastOneType; do { -- cgit v1.2.3 From 67729c5de3bf33e57bd95b92252f0569faa37012 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 15 Apr 2019 11:26:38 +0200 Subject: Blacklist tst_qquickwidget::tabKey() on opensuse Task-number: QTBUG-75171 Change-Id: I68ef40cd9fe47d26cd4c83064367c2a3272efe0f Reviewed-by: Mitch Curtis --- tests/auto/quickwidgets/qquickwidget/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/quickwidgets/qquickwidget/BLACKLIST diff --git a/tests/auto/quickwidgets/qquickwidget/BLACKLIST b/tests/auto/quickwidgets/qquickwidget/BLACKLIST new file mode 100644 index 0000000000..18ea65bb72 --- /dev/null +++ b/tests/auto/quickwidgets/qquickwidget/BLACKLIST @@ -0,0 +1,3 @@ +[tabKey] +opensuse-42.3 +opensuse-leap -- cgit v1.2.3 From d8662301188229721b12526a18db7ceb496f1ef1 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 26 Apr 2019 09:37:56 +0200 Subject: Blacklist tst_qquickwindow::openglContextCreatedSignal on opensuse Task-number: QTBUG-75454 Change-Id: I46453da06553de7be721b921b085a015741ada5f Reviewed-by: Mitch Curtis --- tests/auto/quick/qquickwindow/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/quick/qquickwindow/BLACKLIST b/tests/auto/quick/qquickwindow/BLACKLIST index bb9f403188..1282a9d5ec 100644 --- a/tests/auto/quick/qquickwindow/BLACKLIST +++ b/tests/auto/quick/qquickwindow/BLACKLIST @@ -1,3 +1,6 @@ +[openglContextCreatedSignal] +opensuse-42.3 +opensuse-leap # QTBUG-62177 [attachedProperty] osx -- cgit v1.2.3 From 64a6677ae612f0af01cbec0b8b2a2dd625bcf85b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 26 Apr 2019 14:43:48 +0200 Subject: Fix compile error with qml_tracing enabled "hasTry" doesn't exist. Change-Id: Ia6df66406e296c7623fa872ef32acc46d93b3319 Reviewed-by: Erik Verbruggen --- src/qml/compiler/qv4compilercontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp index b9ab4e5173..ca2d5128f4 100644 --- a/src/qml/compiler/qv4compilercontext.cpp +++ b/src/qml/compiler/qv4compilercontext.cpp @@ -428,7 +428,7 @@ bool Context::canUseTracingJit() const //### the next condition should be refined and have the IR distinguish between escaping and // non-escaping locals - return !hasTry && !requiresExecutionContext && !hasNestedFunctions; + return !requiresExecutionContext && !hasNestedFunctions; #else return false; #endif -- cgit v1.2.3 From eb363c3a0b7f96015d7b8f2551dbeaa86f5acf16 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 26 Apr 2019 09:54:28 +0200 Subject: Fix maximum call stack depth limits for ASAN builds ASAN enabled builds require more stack space and therefore our call depth limits should be lower. In my measurements with a recursion through arrow functions with the interpreter, as per the test case in the bug report, different types of builds require different amounts of stack space. On x86-64 Linux, I measured, by printing $rsp and subtracting: Debug: ~6k Debug with -Og: ~590 bytes Release with -O2: ~570 bytes Release (-O2) with ASAN: ~40k Fixes: QTBUG-75410 Change-Id: I403b261c677b1adb9f349958339b5a1294ae4d5d Reviewed-by: Erik Verbruggen Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index bd1124beb6..966ff12506 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -169,7 +169,7 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine) bool ok = false; maxCallDepth = qEnvironmentVariableIntValue("QV4_MAX_CALL_DEPTH", &ok); if (!ok || maxCallDepth <= 0) { -#ifdef QT_NO_DEBUG +#if defined(QT_NO_DEBUG) && !defined(__SANITIZE_ADDRESS__) maxCallDepth = 1234; #else // no (tail call) optimization is done, so there'll be a lot mare stack frames active -- cgit v1.2.3 From 3a349ea9229eae7e3e189e92e3124b169fe4f447 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 25 Apr 2019 15:07:33 +0200 Subject: Don't call unknown types "null" That is rather confusing. Task-number: QTBUG-74815 Change-Id: Id683a7f9efd63c8859c5740ceab9f161cea46ee3 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4qobjectwrapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 5467e730e3..6fed538fa8 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -565,9 +565,9 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP QQmlContextData *callingQmlContext = scope.engine->callingQmlContext(); if (!QQmlPropertyPrivate::write(object, *property, v, callingQmlContext)) { - const char *valueType = nullptr; - if (v.userType() == QVariant::Invalid) valueType = "null"; - else valueType = QMetaType::typeName(v.userType()); + const char *valueType = (v.userType() == QMetaType::UnknownType) + ? "an unknown type" + : QMetaType::typeName(v.userType()); const char *targetTypeName = QMetaType::typeName(property->propType()); if (!targetTypeName) -- cgit v1.2.3 From dbbbbe569da0aa3900a17ca22bd2be2708fb76f7 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 25 Apr 2019 15:21:19 +0200 Subject: Allow creation of variants from non-singleton QQmlTypeWrappers I don't see any reason why this should be prohibited. Change-Id: I4a54c55eff4b9151691d0587627efad4a06485f1 Fixes: QTBUG-74815 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmltypewrapper.cpp | 3 +-- tests/auto/qml/qqmllanguage/data/typeWrapperToVariant.qml | 15 +++++++++++++++ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tests/auto/qml/qqmllanguage/data/typeWrapperToVariant.qml diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 246de04316..24c5aecc00 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -97,9 +97,8 @@ QObject* QQmlTypeWrapper::singletonObject() const QVariant QQmlTypeWrapper::toVariant() const { - // Only Singleton type wrappers can be converted to a variant. if (!isSingleton()) - return QVariant(); + return QVariant::fromValue(d()->object); QQmlEngine *e = engine()->qmlEngine(); QQmlType::SingletonInstanceInfo *siinfo = d()->type().singletonInstanceInfo(); diff --git a/tests/auto/qml/qqmllanguage/data/typeWrapperToVariant.qml b/tests/auto/qml/qqmllanguage/data/typeWrapperToVariant.qml new file mode 100644 index 0000000000..8a1535ff50 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/typeWrapperToVariant.qml @@ -0,0 +1,15 @@ +import QtQml 2.0 + +QtObject { + id: root + + property QtObject target: QtObject { + Component.onCompleted: { + root.connections.target = root.target.Component + } + } + + property Connections connections: Connections { + ignoreUnknownSignals: true + } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 85dddbcb54..87468c329c 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -301,6 +301,8 @@ private slots: void polymorphicFunctionLookup(); void anchorsToParentInPropertyChanges(); + void typeWrapperToVariant(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -5085,6 +5087,19 @@ void tst_qqmllanguage::anchorsToParentInPropertyChanges() QTRY_COMPARE(o->property("edgeWidth").toInt(), 200); } +void tst_qqmllanguage::typeWrapperToVariant() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("typeWrapperToVariant.qml")); + VERIFY_ERRORS(0); + QScopedPointer o(component.create()); + QVERIFY(!o.isNull()); + QObject *connections = qvariant_cast(o->property("connections")); + QVERIFY(connections); + QObject *target = qvariant_cast(connections->property("target")); + QVERIFY(target); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3 From 8a5001247b250a7f7cb938743481b1405dcdc3a0 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 1 Apr 2019 18:01:41 +0200 Subject: MultiPointHandler: eliminate "no points" warning with native gestures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In handlePointerEventImpl, there is the call d->centroid.reset(d->currentPoints); with the expectation that currentPoints is not empty. But we weren't populating it in case of a native gesture. It still ends up being empty at the end of the gesture, but it's normal to return false from wantsPointerEvent() when there are no eligible points. Fixes: QTBUG-70083 Change-Id: I12ca6460a24d2eb6c44a639f83ce3ff17eb37613 Reviewed-by: Jan Arve Sæther --- src/quick/handlers/qquickmultipointhandler.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp index baa68e5e53..6fbab29077 100644 --- a/src/quick/handlers/qquickmultipointhandler.cpp +++ b/src/quick/handlers/qquickmultipointhandler.cpp @@ -70,14 +70,15 @@ bool QQuickMultiPointHandler::wantsPointerEvent(QQuickPointerEvent *event) if (!QQuickPointerDeviceHandler::wantsPointerEvent(event)) return false; -#if QT_CONFIG(gestures) - if (event->asPointerNativeGestureEvent()) - return true; -#endif - if (event->asPointerScrollEvent()) return false; + bool ret = false; +#if QT_CONFIG(gestures) + if (event->asPointerNativeGestureEvent() && event->point(0)->state() != QQuickEventPoint::Released) + ret = true; +#endif + // If points were pressed or released within parentItem, reset stored state // and check eligible points again. This class of handlers is intended to // handle a specific number of points, so a differing number of points will @@ -97,7 +98,7 @@ bool QQuickMultiPointHandler::wantsPointerEvent(QQuickPointerEvent *event) return true; } - const bool ret = (candidatePoints.size() >= minimumPointCount() && candidatePoints.size() <= maximumPointCount()); + ret = ret || (candidatePoints.size() >= minimumPointCount() && candidatePoints.size() <= maximumPointCount()); if (ret) { const int c = candidatePoints.count(); m_currentPoints.resize(c); -- cgit v1.2.3