aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickloader.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@live.com>2015-09-07 16:29:55 -0500
committerMichael Brasser <michael.brasser@live.com>2015-09-10 17:57:10 +0000
commit6338e98729f811fd3a2d960c184e76357e908ab7 (patch)
treeb9901afee0f766a70bf00ec25176a90267582975 /src/quick/items/qquickloader.cpp
parent5aa682176613b551812e378e5990607d4a211837 (diff)
Allow forced completion of asynchronous Loader.
Setting Loader::asynchronous from true to false will attempt to force complete any operations in progress. This allows the user to begin loading something in the background, and then force the load to complete once the Loader's content must be viewed. Change-Id: I056dcc20faacb38b3529c967245416da9949e64a Task-number: QTBUG-29789 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquickloader.cpp')
-rw-r--r--src/quick/items/qquickloader.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index d46e25d255..4867e9485a 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -852,6 +852,11 @@ likelihood of glitches in animation. When loading asynchronously the status
will change to Loader.Loading. Once the entire component has been created, the
\l item will be available and the status will change to Loader.Ready.
+Changing the value of this property to \c false while an asynchronous load is in
+progress will force immediate, synchronous completion. This allows beginning an
+asynchronous load and then forcing completion if the Loader content must be
+accessed before the asynchronous load has completed.
+
To avoid seeing the items loading progressively set \c visible appropriately, e.g.
\code
@@ -878,6 +883,19 @@ void QQuickLoader::setAsynchronous(bool a)
return;
d->asynchronous = a;
+
+ if (isComponentComplete() && d->active) {
+ if (d->loadingFromSource && d->component && d->component->isLoading()) {
+ // Force a synchronous component load
+ QUrl currentSource = d->source;
+ d->clear();
+ d->source = currentSource;
+ loadFromSource();
+ } else if (d->incubator && d->incubator->isLoading()) {
+ d->incubator->forceCompletion();
+ }
+ }
+
emit asynchronousChanged();
}