Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.8.3
-
None
Description
Behavior of QQmlEngine::clearComponentCache has changed in 6.8.3 in comparison to 6.8.2 and earlier versions, affecting users functionalities relying on that method and it's behavior.
The following code:
import QtQuick import QtQuick.Controls import Test Window { id: root visible: true function load() { const component = Qt.createComponent(`MyItem.qml`) return component.createObject(root) } Component.onCompleted: { let instance = load() console.log(instance) instance.destroy() CacheCleaner.clearComponentCache() instance = load() console.log(instance) } }
On Qt 6.8.2 prints:
qml: MyItem_QMLTYPE_2(0x7ee6a4002df0) qml: MyItem_QMLTYPE_3(0x5706d0db0dd0)
The component has been removed from the cache resulting with other type name for the second instance.
On Qt 6.8.3:
qml: MyItem_QMLTYPE_2(0x71a958002df0) qml: MyItem_QMLTYPE_2(0x5cc39bb09c00)
The type remains the same.
To achieve similar behavior (but not exactly the same) it can be modified to e.g.:
import QtQuick import QtQuick.Controls import Test Window { id: root visible: true function load() { const component = Qt.createComponent(`MyItem.qml`) return component.createObject(root) } Component.onCompleted: { const instance = load() console.log(instance) instance.destroy() CacheCleaner.clearComponentCache() Qt.callLater(() => { CacheCleaner.clearComponentCache() const instance = load() console.log(instance) }) } }
However it's also not clear why two separate calls to QQmlEngine::clearComponentCache are needed to achieve desired effect of cache clearing.