Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.13.2
-
None
Description
QQmlEngine provides 2 functions for managing in-memory cache:
- clearComponentCache() - remove all cache entries
- trimComponentCache() - remove unused entries (of which no instance exists)
Request:
Add a function to remove a single file from the cache. As a result a newly created instance from this QML file should contain changes to that file. Example: feature for resetting source property of Loader, after the source file was changed.
Example:
Loader { id: loader source: "FileThatChanges.qml" } // click button after making changes to the QML file "FileThatChanges.qml" or another file that is included by "FileThatChanges.qml" Button { text: "Reload" onClicked: { var src = loader.source loader.source = "" qmlEngine.removeFromComponentCache(src) // a C++ interface for this would be enough loader.soruce = src } }
This can be done right now with the TypeCache property in QQmlTypeLoader, but it is private. So adding an accessor for m_typeCache in qqmltypeloader_p.h or a function like removeFromComponentCache(QString fileName) would be enough.
Use case:
Allow changes to QML files at runtime without clearing the whole cache. trimComponentCache() cannot always be used for this, because QML cache entries can reference one another, thus it won't clear entries referenced from other entries of which instances still exist (even if the sub-QML instance itself is deleted!).
Attachments
Issue Links
- relates to
-
QTBUG-62601 Add QQmlApplicationEngine::clear() to delete root objects after clearComponentCache() is called
-
- Open
-
Gerrit Reviews
For Gerrit Dashboard: QTBUG-81116 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
341592,2 | WIP add Loader.reload() function | dev | qt/qtdeclarative | Status: NEW | -2 | 0 |