diff options
author | Chris Adams <christopher.adams@nokia.com> | 2011-10-06 14:37:09 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-06 08:17:18 +0200 |
commit | 0db214e51ac36d5ce5499c52cf4054b81e910bbb (patch) | |
tree | 58b0a9f1002d67df48ebc2a1f9390937917ef196 /src | |
parent | e503a51856db7ecb93bdc02b00ba0e4d78273278 (diff) |
QSGLoader shouldn't load component when active is false
Previously, QSGLoader still loaded the component specified, but didn't
instantiate the item. This commit ensures that no component is loaded
from the source, and that the onLoaded signal is emitted only when
loading occurs (when the loader is active).
Task-number: QTBUG-21710
Change-Id: I2d83603ef84d6942fb84141e9e146d2cf9654fc4
Reviewed-on: http://codereview.qt-project.org/5915
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/items/qsgloader.cpp | 29 | ||||
-rw-r--r-- | src/declarative/items/qsgloader_p_p.h | 1 |
2 files changed, 16 insertions, 14 deletions
diff --git a/src/declarative/items/qsgloader.cpp b/src/declarative/items/qsgloader.cpp index 0a0a3b9cc5..91dce3b364 100644 --- a/src/declarative/items/qsgloader.cpp +++ b/src/declarative/items/qsgloader.cpp @@ -53,8 +53,9 @@ QT_BEGIN_NAMESPACE QSGLoaderPrivate::QSGLoaderPrivate() - : item(0), component(0), ownComponent(false), updatingSize(false), - itemWidthValid(false), itemHeightValid(false), active(true) + : item(0), component(0), updatingSize(false), + itemWidthValid(false), itemHeightValid(false), + active(true), loadingFromSource(false) { } @@ -79,10 +80,9 @@ void QSGLoaderPrivate::clear() { disposeInitialPropertyValues(); - if (ownComponent) { + if (loadingFromSource && component) { component->deleteLater(); component = 0; - ownComponent = false; } source = QUrl(); @@ -340,11 +340,10 @@ void QSGLoader::loadFromSource() return; } - d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this); - d->ownComponent = true; - - if (isComponentComplete()) + if (isComponentComplete()) { + d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this); d->load(); + } } /*! @@ -384,7 +383,6 @@ void QSGLoader::setSourceComponent(QDeclarativeComponent *comp) d->clear(); d->component = comp; - d->ownComponent = false; d->loadingFromSource = false; if (d->active) @@ -520,7 +518,7 @@ void QSGLoaderPrivate::load() q, SIGNAL(progressChanged())); emit q->statusChanged(); emit q->progressChanged(); - if (ownComponent) + if (loadingFromSource) emit q->sourceChanged(); else emit q->sourceComponentChanged(); @@ -535,7 +533,7 @@ void QSGLoaderPrivate::_q_sourceLoaded() if (component) { if (!component->errors().isEmpty()) { QDeclarativeEnginePrivate::warning(qmlEngine(q), component->errors()); - if (ownComponent) + if (loadingFromSource) emit q->sourceChanged(); else emit q->sourceComponentChanged(); @@ -582,7 +580,7 @@ void QSGLoaderPrivate::_q_sourceLoaded() source = QUrl(); } completeCreateWithInitialPropertyValues(component, obj, initialPropertyValues, qmlGlobalForIpv); - if (ownComponent) + if (loadingFromSource) emit q->sourceChanged(); else emit q->sourceComponentChanged(); @@ -653,7 +651,12 @@ void QSGLoader::componentComplete() { Q_D(QSGLoader); QSGItem::componentComplete(); - d->load(); + if (active()) { + if (d->loadingFromSource) { + d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this); + } + d->load(); + } } /*! diff --git a/src/declarative/items/qsgloader_p_p.h b/src/declarative/items/qsgloader_p_p.h index 732ec8679d..13292ffc54 100644 --- a/src/declarative/items/qsgloader_p_p.h +++ b/src/declarative/items/qsgloader_p_p.h @@ -86,7 +86,6 @@ public: QDeclarativeComponent *component; v8::Persistent<v8::Object> initialPropertyValues; v8::Persistent<v8::Object> qmlGlobalForIpv; - bool ownComponent : 1; bool updatingSize: 1; bool itemWidthValid : 1; bool itemHeightValid : 1; |