We automatically call QQmlMetaType::freeUnusedTypesAndCaches() from
- the QQmlEngine dtor
- the QJSEngine dtor (after having it called in ~QQmlEngine() already)
- the QQmlTypeLoader dtor (again ...)
This operation selectively deletes types from the type registry and has the potential of leaving incomplete modules. As we don't clear the cache of loaded "plugins" (either plugins or just type registrations), the types won't be re-loaded when we need them again in a new QQmlEngine.
The reason this has never surfaced ... drumroll ... is that freeUnusedTypesAndCaches() does pretty much nothing under normal conditions. Most QQmlType instances are inserted twice into the registry. Once for their actual type, and once for their QQmlListProperty type. We check for refcount == 1 to determine if we can "safely" remove a type. The refcount is always 2 for types that come with lists.
There are a few type registrations that don't register lists or only register lists. It should be possible to exercise this bug.