aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-03 01:00:05 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-03 12:23:20 +0100
commit04e3918f0fd0c19ed830d406e1c549a037089cc4 (patch)
tree8e07ee9c550124b277983542e2ad0f7a791b5276
parentb760d972459fd3b0c41e4c85076fa933ba5c0d1d (diff)
parent254a56252874b63430701351dcd8c9bef8507353 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts: src/qmlmodels/qqmltableinstancemodel.cpp src/qmlmodels/qqmltableinstancemodel_p.h Change-Id: I89339b1cb41ba27fe30c79530859a1c2bfbecc69
-rw-r--r--src/qml/doc/src/cppintegration/data.qdoc19
-rw-r--r--src/qml/jsruntime/qv4engine.cpp2
-rw-r--r--src/qml/jsruntime/qv4engine_p.h6
-rw-r--r--src/qmlmodels/qqmltableinstancemodel.cpp21
-rw-r--r--src/qmlmodels/qqmltableinstancemodel_p.h1
-rw-r--r--src/qmlworkerscript/qquickworkerscript.cpp4
-rw-r--r--src/quick/items/qquickitem.cpp8
-rw-r--r--src/quick/items/qquicktableview.cpp11
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp10
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp3
-rw-r--r--tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml12
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp15
12 files changed, 101 insertions, 11 deletions
diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc
index 7c2693508c..0dec7fd66d 100644
--- a/src/qml/doc/src/cppintegration/data.qdoc
+++ b/src/qml/doc/src/cppintegration/data.qdoc
@@ -197,6 +197,25 @@ type or method parameter, the value can be created as a JavaScript array or
object in QML, and is automatically converted to a QVariantList or QVariantMap
when it is passed to C++.
+Mind that QVariantList and QVariantMap properties of C++ types are stored as
+values and cannot be changed in place by QML code. You can only replace the
+whole map or list, but not manipulate its contents. The following code does
+not work if the property \c l is a QVariantList:
+
+\code
+MyListExposingItem {
+ l: [1, 2, 3]
+ Component.onCompleted: l[0] = 10
+}
+\endcode
+
+The following code does work:
+\code
+MyListExposingItem {
+ l: [1, 2, 3]
+ Component.onCompleted: l = [10, 2, 3]
+}
+\endcode
\section2 QDateTime to JavaScript Date
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 86f0d6d83c..1efe09c59f 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -2355,9 +2355,11 @@ int ExecutionEngine::registerExtension()
return registrationData()->extensionCount++;
}
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *QV4::detail::getNetworkAccessManager(ExecutionEngine *engine)
{
return engine->qmlEngine()->networkAccessManager();
}
+#endif // qml_network
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index e0025feb00..efe44a324c 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -91,6 +91,7 @@ class PageAllocation;
QT_BEGIN_NAMESPACE
+#if QT_CONFIG(qml_network)
class QNetworkAccessManager;
namespace QV4 {
@@ -99,6 +100,9 @@ namespace detail {
QNetworkAccessManager *getNetworkAccessManager(ExecutionEngine *engine);
}
}
+#else
+namespace QV4 { struct QObjectMethod; }
+#endif // qml_network
// Used to allow a QObject method take and return raw V4 handles without having to expose
// 48 in the public API.
@@ -355,7 +359,9 @@ public:
FunctionObject *getStackFunction() const { return reinterpret_cast<FunctionObject *>(jsObjects + GetStack_Function); }
FunctionObject *thrower() const { return reinterpret_cast<FunctionObject *>(jsObjects + ThrowerObject); }
+#if QT_CONFIG(qml_network)
QNetworkAccessManager* (*networkAccessManager)(ExecutionEngine*) = detail::getNetworkAccessManager;
+#endif
enum JSStrings {
String_Empty,
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp
index 29c307a47a..b0c322e633 100644
--- a/src/qmlmodels/qqmltableinstancemodel.cpp
+++ b/src/qmlmodels/qqmltableinstancemodel.cpp
@@ -150,7 +150,7 @@ QQmlDelegateModelItem *QQmlTableInstanceModel::resolveModelItem(int index)
}
// Create a new item from scratch
- modelItem = m_adaptorModel.createItem(m_metaType, index);
+ modelItem = m_adaptorModel.createItem(m_metaType.data(), index);
if (modelItem) {
modelItem->delegate = delegate;
m_modelItems.insert(index, modelItem);
@@ -243,6 +243,25 @@ void QQmlTableInstanceModel::destroyModelItem(QQmlDelegateModelItem *modelItem)
delete modelItem;
}
+void QQmlTableInstanceModel::dispose(QObject *object)
+{
+ Q_ASSERT(object);
+ auto modelItem = qvariant_cast<QQmlDelegateModelItem *>(object->property(kModelItemTag));
+ Q_ASSERT(modelItem);
+
+ modelItem->releaseObject();
+
+ // The item is not referenced by anyone
+ Q_ASSERT(!modelItem->isObjectReferenced());
+ Q_ASSERT(!modelItem->isReferenced());
+
+ m_modelItems.remove(modelItem->index);
+
+ emit destroyingItem(object);
+ delete object;
+ delete modelItem;
+}
+
void QQmlTableInstanceModel::cancel(int index)
{
auto modelItem = m_modelItems.value(index);
diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h
index 06d0db06aa..95d945f979 100644
--- a/src/qmlmodels/qqmltableinstancemodel_p.h
+++ b/src/qmlmodels/qqmltableinstancemodel_p.h
@@ -110,6 +110,7 @@ public:
QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override;
ReleaseFlags release(QObject *object, ReusableFlag reusable = NotReusable) override;
+ void dispose(QObject *object);
void cancel(int) override;
void drainReusableItemsPool(int maxPoolTime) override;
diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp
index 4a79027234..0bdbbabadc 100644
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -130,7 +130,9 @@ struct WorkerScript : public QV4::ExecutionEngine {
QQuickWorkerScriptEnginePrivate *p = nullptr;
QUrl source;
QQuickWorkerScript *owner = nullptr;
+#if QT_CONFIG(qml_network)
QScopedPointer<QNetworkAccessManager> scriptLocalNAM;
+#endif
int id = -1;
};
@@ -390,6 +392,7 @@ WorkerScript::WorkerScript(int id, QQuickWorkerScriptEnginePrivate *parent)
QV4::ScopedValue sendMessage(scope, QV4::FunctionObject::createBuiltinFunction(this, name, QQuickWorkerScriptEnginePrivate::method_sendMessage, 1));
api->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("sendMessage"))), sendMessage);
globalObject->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("WorkerScript"))), api);
+#if QT_CONFIG(qml_network)
networkAccessManager = [](QV4::ExecutionEngine *engine){
auto *workerScript = static_cast<WorkerScript *>(engine);
if (workerScript->scriptLocalNAM)
@@ -400,6 +403,7 @@ WorkerScript::WorkerScript(int id, QQuickWorkerScriptEnginePrivate *parent)
workerScript->scriptLocalNAM.reset(new QNetworkAccessManager(workerScript->p));
return workerScript->scriptLocalNAM.get();
};
+#endif // qml_network
}
int QQuickWorkerScriptEngine::registerWorkerScript(QQuickWorkerScript *owner)
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index bc68d46075..4d9e3de859 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -2569,6 +2569,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
bool skip = false;
QQuickItem *startItem = item;
+ QQuickItem *originalStartItem = startItem;
// Protect from endless loop:
// If we start on an invisible item we will not find it again.
// If there is no other item which can become the focus item, we have a forever loop,
@@ -2644,7 +2645,12 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
}
}
from = last;
- if (current == startItem && from == firstFromItem) {
+ // if [from] item is equal to [firstFromItem], means we have traversed one path and
+ // jump back to parent of the chain, and then we have to check whether we have
+ // traversed all of the chain (by compare the [current] item with [startItem])
+ // Since the [startItem] might be promoted to its parent if it is invisible,
+ // we still have to check [current] item with original start item
+ if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
// wrapped around, avoid endless loops
if (item == contentItem) {
qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 6124c8304b..4926d81cfe 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -441,7 +441,16 @@ QQuickTableViewPrivate::QQuickTableViewPrivate()
QQuickTableViewPrivate::~QQuickTableViewPrivate()
{
- releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
+ for (auto *fxTableItem : loadedItems) {
+ if (auto item = fxTableItem->item) {
+ if (fxTableItem->ownItem)
+ delete item;
+ else if (tableModel)
+ tableModel->dispose(item);
+ }
+ delete fxTableItem;
+ }
+
if (tableModel)
delete tableModel;
}
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp
index e981921c69..7c98e2c1e1 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp
@@ -136,12 +136,12 @@ Texture::Texture(Atlas *atlas, const QRect &textureRect, const QByteArray &data,
{
float w = atlas->size().width();
float h = atlas->size().height();
- QRect nopad = atlasSubRect();
+ const QRect &r = atlasSubRect();
// offset by half-pixel to prevent bleeding when scaling
- m_texture_coords_rect = QRectF((nopad.x() + .5) / w,
- (nopad.y() + .5) / h,
- (nopad.width() - 1.) / w,
- (nopad.height() - 1.) / h);
+ m_texture_coords_rect = QRectF((r.x() + .5) / w,
+ (r.y() + .5) / h,
+ (size.width() - 1.) / w,
+ (size.height() - 1.) / h);
}
Texture::~Texture()
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
index b019ff4535..f636e527c3 100644
--- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
@@ -325,7 +325,8 @@ void tst_qqmlapplicationengine::failureToLoadTriggersWarningSignal()
auto url = testFileUrl("invalid.qml");
qRegisterMetaType<QList<QQmlError>>();
QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QQmlApplicationEngine failed to load component");
- QTest::ignoreMessage(QtMsgType::QtWarningMsg, QRegularExpression(url.toString() + QLatin1Char('*')));
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg,
+ QRegularExpression(QRegularExpression::escape(url.toString()) + QLatin1Char('*')));
QQmlApplicationEngine test;
QSignalSpy warningObserver(&test, &QQmlApplicationEngine::warnings);
test.load(url);
diff --git a/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml
new file mode 100644
index 0000000000..042f408753
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.14
+
+Item {
+ width: 400
+ height: 200
+ Item {
+ objectName: "hiddenChild"
+ focus: true
+ activeFocusOnTab: true
+ visible: false
+ }
+}
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index a1b4a70217..45ecbfde11 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -64,6 +64,7 @@ private slots:
void activeFocusOnTab8();
void activeFocusOnTab9();
void activeFocusOnTab10();
+ void activeFocusOnTab_infiniteLoop_data();
void activeFocusOnTab_infiniteLoop();
void nextItemInFocusChain();
@@ -1027,12 +1028,20 @@ void tst_QQuickItem::activeFocusOnTab10()
delete window;
}
+void tst_QQuickItem::activeFocusOnTab_infiniteLoop_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::newRow("infiniteLoop") << testFileUrl("activeFocusOnTab_infiniteLoop.qml"); // QTBUG-68271
+ QTest::newRow("infiniteLoop2") << testFileUrl("activeFocusOnTab_infiniteLoop2.qml");// QTBUG-81510
+}
+
void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
{
- // see QTBUG-68271
+ QFETCH(QUrl, source);
+
// create a window where the currently focused item is not visible
QScopedPointer<QQuickView>window(new QQuickView());
- window->setSource(testFileUrl("activeFocusOnTab_infiniteLoop.qml"));
+ window->setSource(source);
window->show();
auto *hiddenChild = findItem<QQuickItem>(window->rootObject(), "hiddenChild");
QVERIFY(hiddenChild);
@@ -1041,6 +1050,8 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
auto *item = hiddenChild->nextItemInFocusChain();
// focus is moved to the root object since there is no other candidate
QCOMPARE(item, window->rootObject());
+ item = hiddenChild->nextItemInFocusChain(false);
+ QCOMPARE(item, window->rootObject());
}
void tst_QQuickItem::nextItemInFocusChain()