QQuickLoader: prevent clearing initial properties after active = true
After commit b6d88c73
, we implement the method [disposeInitialPropertyValues]
and clear the cache of initial properties actually. Since we also call this
method after source loaded, it will cause loss of initial properties after
active = true.
Fixes: QTBUG-83895
Change-Id: Iaa500fff14dcaad79a9e68dcbac9f65fa8720456
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
This commit is contained in:
parent
c1ae217a52
commit
a135f3d6c3
|
@ -711,7 +711,6 @@ void QQuickLoaderPrivate::incubatorStateChanged(QQmlIncubator::Status status)
|
|||
emit q->progressChanged();
|
||||
if (status == QQmlIncubator::Ready)
|
||||
emit q->loaded();
|
||||
disposeInitialPropertyValues(); // cleanup
|
||||
}
|
||||
|
||||
void QQuickLoaderPrivate::_q_sourceLoaded()
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property int i: 0
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
objectName: "loader"
|
||||
active: false
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
loader.setSource("CacheClearTest.qml", {i: 12})
|
||||
loader.active = true
|
||||
loader.active = false
|
||||
loader.active = true
|
||||
root.i = loader.item.i // should be 12
|
||||
}
|
||||
}
|
|
@ -698,6 +698,11 @@ void tst_QQuickLoader::initialPropertyValues_data()
|
|||
<< QStringList()
|
||||
<< (QStringList() << "oldi" << "i")
|
||||
<< (QVariantList() << 12 << 42);
|
||||
|
||||
QTest::newRow("ensure initial properties aren't disposed after active = true") << testFileUrl("initialPropertyValues.12.qml")
|
||||
<< QStringList()
|
||||
<< (QStringList() << "i")
|
||||
<< (QVariantList() << 12);
|
||||
}
|
||||
|
||||
void tst_QQuickLoader::initialPropertyValues()
|
||||
|
|
Loading…
Reference in New Issue