diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2017-11-06 16:13:13 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2017-11-30 07:35:35 +0000 |
commit | 60d589ccddb036e84883a6c2ef63a5292c8ad022 (patch) | |
tree | d0615d751ed79e73a9f1ac7938831e144c513a81 /src/qml/types/qqmlobjectmodel_p.h | |
parent | 8bdf33051aa679db1f060314c6ccab1cb9a77a7a (diff) |
QQmlIntanceModel: use QQmlIncubator::IncubationMode instead of bool to specify incubation mode
The current implementation would pass a boolean to signal if asynchronous
or synchronous incubation should be used to create an item. The problem with this approach
is that passing 'synchronous" would translate to QQmlIncubation::AsynchronousIfNested
later down the chain. This meant that even if the caller requested synchronous incubation, it
could end up with asynchronous incubation anyway, e.g if an async parent incubator was active at
the time of the call. And this can easily come as an unhandled supprise for the caller, and as
such, cause unforseen bugs.
This patch is a first of a set of patches that is done to fix the bug reported in the task below.
It will not change any behavior, it is written to preserve the logic exactly as it were, just
as a preparation for subsequent patches. It makes it explicit at the call location what
incubation mode will be used, and especially make it clear whenever the AsynchronousIfNested
flag is in play.
Task-number: QTBUG-61537
Change-Id: I8b3ba5438ebb2cd59983a098bd8ceeeb844da87b
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/qml/types/qqmlobjectmodel_p.h')
-rw-r--r-- | src/qml/types/qqmlobjectmodel_p.h | 5 |
1 files changed, 3 insertions, 2 deletions
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 {} |