diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-04-25 10:49:34 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-04-25 10:49:35 +0200 |
commit | 6fd340c1ae0af4ba54a7d686e0fd78d5de0f53e0 (patch) | |
tree | 6cb9c736c890bc9c7a8e5f9d722a356a9a5e38bb | |
parent | 53bd6b8111eb0d7f23b3b0ca95bef4735f7a952c (diff) | |
parent | 138d5c82f11bdcd9c6594d1e539631b9560353ae (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I2fea101de38922d34088c6eca0e256ec167ad118
-rw-r--r-- | src/qml/jsruntime/qv4lookup.cpp | 13 | ||||
-rw-r--r-- | src/quick/items/qquickevents.cpp | 38 | ||||
-rw-r--r-- | tests/auto/shared/util.cpp | 7 | ||||
-rw-r--r-- | tests/auto/shared/util.pri | 6 |
4 files changed, 27 insertions, 37 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<Object &>(obj).get(&static_cast<String &>(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<Object &>(obj).get(&static_cast<String &>(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<Object &>(obj).get(&static_cast<String &>(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<Object &>(obj).get(&static_cast<String &>(str)); + return getterFallback(l, engine, object); } l->getter = getterFallback; return getterFallback(l, engine, object); 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<quint64, PointVelocityData*> PointDataForPointIdMap; +typedef QMap<quint64, PointVelocityData> 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; } 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\\\" +} |