Loader: Actually clear initial properties when changing source
Fixes: QTBUG-79435 Change-Id: Ic99a3b1a9d64426a64117b90a3e11fe99af0d260 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
8bc05e07c8
commit
b6d88c73c4
|
@ -590,8 +590,8 @@ void QQuickLoader::setSource(QQmlV4Function *args)
|
|||
|
||||
d->clear();
|
||||
QUrl sourceUrl = d->resolveSourceUrl(args);
|
||||
d->disposeInitialPropertyValues();
|
||||
if (!ipv->isUndefined()) {
|
||||
d->disposeInitialPropertyValues();
|
||||
d->initialPropertyValues.set(args->v4engine(), ipv);
|
||||
}
|
||||
d->qmlCallingContext.set(scope.engine, scope.engine->qmlContext());
|
||||
|
@ -601,6 +601,7 @@ void QQuickLoader::setSource(QQmlV4Function *args)
|
|||
|
||||
void QQuickLoaderPrivate::disposeInitialPropertyValues()
|
||||
{
|
||||
initialPropertyValues.clear();
|
||||
}
|
||||
|
||||
void QQuickLoaderPrivate::load()
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
import QtQml 2.12
|
||||
QtObject {
|
||||
property int i: 42
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property int oldi: 0
|
||||
property int i: 0
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
objectName: "loader"
|
||||
active: true
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
loader.setSource("CacheClearTest.qml", {i: 12})
|
||||
root.oldi = loader.item.i
|
||||
loader.setSource("CacheClearTest.qml")
|
||||
root.i = loader.item.i // should be 42
|
||||
}
|
||||
}
|
|
@ -681,6 +681,11 @@ void tst_QQuickLoader::initialPropertyValues_data()
|
|||
<< QStringList()
|
||||
<< (QStringList() << "initialValue")
|
||||
<< (QVariantList() << 6);
|
||||
|
||||
QTest::newRow("source url changed, previously initial properties are discared") << testFileUrl("initialPropertyValues.11.qml")
|
||||
<< QStringList()
|
||||
<< (QStringList() << "oldi" << "i")
|
||||
<< (QVariantList() << 12 << 42);
|
||||
}
|
||||
|
||||
void tst_QQuickLoader::initialPropertyValues()
|
||||
|
|
Loading…
Reference in New Issue