diff options
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 21 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel_p.h | 3 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel_p_p.h | 4 | ||||
-rw-r--r-- | src/qml/types/qqmlinstantiator.cpp | 4 | ||||
-rw-r--r-- | src/qml/types/qqmlobjectmodel.cpp | 2 | ||||
-rw-r--r-- | src/qml/types/qqmlobjectmodel_p.h | 5 |
6 files changed, 19 insertions, 20 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index e3906f2a7e..4da7199d1e 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -931,7 +931,7 @@ void QQmlDelegateModelPrivate::setInitialState(QQDMIncubationTask *incubationTas emitInitItem(incubationTask, cacheItem->object); } -QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bool asynchronous) +QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQmlIncubator::IncubationMode incubationMode) { if (!m_delegate || index < 0 || index >= m_compositor.count(group)) { qWarning() << "DelegateModel::item: index out range" << index << m_compositor.count(group); @@ -962,7 +962,8 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bo cacheItem->referenceObject(); if (cacheItem->incubationTask) { - if (!asynchronous && cacheItem->incubationTask->incubationMode() == QQmlIncubator::Asynchronous) { + bool sync = (incubationMode == QQmlIncubator::Synchronous || incubationMode == QQmlIncubator::AsynchronousIfNested); + if (sync && cacheItem->incubationTask->incubationMode() == QQmlIncubator::Asynchronous) { // previously requested async - now needed immediately cacheItem->incubationTask->forceCompletion(); } @@ -971,7 +972,7 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bo cacheItem->scriptRef += 1; - cacheItem->incubationTask = new QQDMIncubationTask(this, asynchronous ? QQmlIncubator::Asynchronous : QQmlIncubator::AsynchronousIfNested); + cacheItem->incubationTask = new QQDMIncubationTask(this, incubationMode); cacheItem->incubationTask->incubating = cacheItem; cacheItem->incubationTask->clear(); @@ -1024,7 +1025,7 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bo to ensure a reference is held. Any call to item() which returns a valid item must be matched by a call to release() in order to destroy the item. */ -QObject *QQmlDelegateModel::object(int index, bool asynchronous) +QObject *QQmlDelegateModel::object(int index, QQmlIncubator::IncubationMode incubationMode) { Q_D(QQmlDelegateModel); if (!d->m_delegate || index < 0 || index >= d->m_compositor.count(d->m_compositorGroup)) { @@ -1032,11 +1033,7 @@ QObject *QQmlDelegateModel::object(int index, bool asynchronous) return 0; } - QObject *object = d->object(d->m_compositorGroup, index, asynchronous); - if (!object) - return 0; - - return object; + return d->object(d->m_compositorGroup, index, incubationMode); } QString QQmlDelegateModelPrivate::stringValue(Compositor::Group group, int index, const QString &name) @@ -2659,7 +2656,7 @@ void QQmlDelegateModelGroup::create(QQmlV4Function *args) return; } - QObject *object = model->object(group, index, false); + QObject *object = model->object(group, index, QQmlIncubator::AsynchronousIfNested); if (object) { QVector<Compositor::Insert> inserts; Compositor::iterator it = model->m_compositor.find(group, index); @@ -3147,7 +3144,7 @@ bool QQmlPartsModel::isValid() const return m_model->isValid(); } -QObject *QQmlPartsModel::object(int index, bool asynchronous) +QObject *QQmlPartsModel::object(int index, QQmlIncubator::IncubationMode incubationMode) { QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(m_model); @@ -3156,7 +3153,7 @@ QObject *QQmlPartsModel::object(int index, bool asynchronous) return 0; } - QObject *object = model->object(m_compositorGroup, index, asynchronous); + QObject *object = model->object(m_compositorGroup, index, incubationMode); if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(object)) { QObject *part = package->part(m_part); diff --git a/src/qml/types/qqmldelegatemodel_p.h b/src/qml/types/qqmldelegatemodel_p.h index 186144d107..5ae2d48969 100644 --- a/src/qml/types/qqmldelegatemodel_p.h +++ b/src/qml/types/qqmldelegatemodel_p.h @@ -54,6 +54,7 @@ #include <private/qtqmlglobal_p.h> #include <private/qqmllistcompositor_p.h> #include <private/qqmlobjectmodel_p.h> +#include <private/qqmlincubator_p.h> #include <QtCore/qabstractitemmodel.h> #include <QtCore/qstringlist.h> @@ -109,7 +110,7 @@ public: int count() const override; bool isValid() const override { return delegate() != 0; } - QObject *object(int index, bool asynchronous = false) override; + QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; ReleaseFlags release(QObject *object) override; void cancel(int index) override; QString stringValue(int index, const QString &role) override; diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index 0f8438870a..a6a7853116 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -261,7 +261,7 @@ public: void connectModel(QQmlAdaptorModel *model); void requestMoreIfNecessary(); - QObject *object(Compositor::Group group, int index, bool asynchronous); + QObject *object(Compositor::Group group, int index, QQmlIncubator::IncubationMode incubationMode); QQmlDelegateModel::ReleaseFlags release(QObject *object); QString stringValue(Compositor::Group group, int index, const QString &name); void emitCreatedPackage(QQDMIncubationTask *incubationTask, QQuickPackage *package); @@ -357,7 +357,7 @@ public: int count() const override; bool isValid() const override; - QObject *object(int index, bool asynchronous = false) override; + QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; ReleaseFlags release(QObject *item) override; QString stringValue(int index, const QString &role) override; QList<QByteArray> watchedRoles() const { return m_watchedRoles; } diff --git a/src/qml/types/qqmlinstantiator.cpp b/src/qml/types/qqmlinstantiator.cpp index 2de5875deb..6e2b66aea7 100644 --- a/src/qml/types/qqmlinstantiator.cpp +++ b/src/qml/types/qqmlinstantiator.cpp @@ -85,7 +85,7 @@ void QQmlInstantiatorPrivate::clear() QObject *QQmlInstantiatorPrivate::modelObject(int index, bool async) { requestedIndex = index; - QObject *o = instanceModel->object(index, async); + QObject *o = instanceModel->object(index, async ? QQmlIncubator::Asynchronous : QQmlIncubator::AsynchronousIfNested); requestedIndex = -1; return o; } @@ -123,7 +123,7 @@ void QQmlInstantiatorPrivate::_q_createdItem(int idx, QObject* item) if (objects.contains(item)) //Case when it was created synchronously in regenerate return; if (requestedIndex != idx) // Asynchronous creation, reference the object - (void)instanceModel->object(idx, false); + (void)instanceModel->object(idx); item->setParent(q); if (objects.size() < idx + 1) { int modelCount = instanceModel->count(); diff --git a/src/qml/types/qqmlobjectmodel.cpp b/src/qml/types/qqmlobjectmodel.cpp index dcd0360199..dcb41469ba 100644 --- a/src/qml/types/qqmlobjectmodel.cpp +++ b/src/qml/types/qqmlobjectmodel.cpp @@ -267,7 +267,7 @@ bool QQmlObjectModel::isValid() const return true; } -QObject *QQmlObjectModel::object(int index, bool) +QObject *QQmlObjectModel::object(int index, QQmlIncubator::IncubationMode) { Q_D(QQmlObjectModel); QQmlObjectModelPrivate::Item &item = d->children[index]; diff --git a/src/qml/types/qqmlobjectmodel_p.h b/src/qml/types/qqmlobjectmodel_p.h index fc4c03874f..5e4a9c686f 100644 --- a/src/qml/types/qqmlobjectmodel_p.h +++ b/src/qml/types/qqmlobjectmodel_p.h @@ -52,6 +52,7 @@ // #include <private/qtqmlglobal_p.h> +#include <private/qqmlincubator_p.h> #include <QtQml/qqml.h> #include <QtCore/qobject.h> @@ -74,7 +75,7 @@ public: virtual int count() const = 0; virtual bool isValid() const = 0; - virtual QObject *object(int index, bool asynchronous=false) = 0; + virtual QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) = 0; virtual ReleaseFlags release(QObject *object) = 0; virtual void cancel(int) {} virtual QString stringValue(int, const QString &) = 0; @@ -113,7 +114,7 @@ public: int count() const override; bool isValid() const override; - QObject *object(int index, bool asynchronous = false) override; + QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override; ReleaseFlags release(QObject *object) override; QString stringValue(int index, const QString &role) override; void setWatchedRoles(const QList<QByteArray> &) override {} |