Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
None
Description
http://doc.qt.io/qt-5/qqmlengine.html#clearComponentCache can be used to clear any loaded components, but it doesn't take care of deleting the instances of those components. If a user wants to reload the QML in their application after calling clearComponentCache(), it is not currently clear how they would do it. Apparently, deleting the root objects is enough for this, as QQmlApplicationEngine listens to the destroyed signal:
void QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *c) { Q_Q(QQmlApplicationEngine); switch (c->status()) { case QQmlComponent::Error: qWarning() << "QQmlApplicationEngine failed to load component"; qWarning() << qPrintable(c->errorString()); q->objectCreated(0, c->url()); break; case QQmlComponent::Ready: { auto newObj = c->create(); objects << newObj; QObject::connect(newObj, &QObject::destroyed, q, [&](QObject *obj) { objects.removeAll(obj); }); q->objectCreated(objects.constLast(), c->url()); } break; case QQmlComponent::Loading: case QQmlComponent::Null: return; //These cases just wait for the next status update }
A QQmlApplicationEngine::clear() function would make it obvious how to achieve this.
Attachments
Issue Links
- relates to
-
QTBUG-26366 Improve qml runtime features
-
- Open
-
-
QTBUG-81116 Provide method to remove a single entry from QML Type Cache
-
- Open
-