Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
5.12.0
Description
Hi,
My use case is load a library (dlopen) which is linked with code generated through qmlcachegen. when I unload the library, some resources are leaked.
in the generated code contains :
int QT_MANGLE_NAMESPACE(qInitResources_myresource)() { ::unitRegistry(); Q_INIT_RESOURCE(qml_cache); return 1; } /* this calls qInitResources_myresource on dlopen, but qCleanupResources_myresource won't be called on dlclose */ Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_myresource)); int QT_MANGLE_NAMESPACE(qCleanupResources_myresource)() { Q_CLEANUP_RESOURCE(qml_cache); return 1; }
qrc seems to solve this issue by using a structure as :
namespace { struct initializer { initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources_qml_cache)(); } ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources_qml_cache)(); } } dummy; }