Skip to content

QmlObject: Use std::shared_ptr to properly track the lifetime of QQmlEngine

Arjen Hiemstra requested to merge work/ahiemstra/factorydelete into master

The engine passed to QmlObject is potentially shared, either because it comes from QmlObjectSharedEngine or because the caller is already using it. Since raw pointers do not provide any information about that, deprecate the raw pointer constructors and replace them with a constructor taking a std::shared_ptr.

This allows QmlObject to properly track if its the first user of the QQmlEngine and if so, call KDeclarative::setupEngine on it. It also allows it to know if it is the last user of the engine, and in that case properly cleanup the QNAM factory, without affecting the shared engine case.

BUG: 451790

The second commit drops the KDeclarative instance from QmlObject, since the only remaining non-deprecated methods are static so we no longer need an instance to access them.

Edited by Arjen Hiemstra

Merge request reports

Loading