qt/qml: add qml compatibility module
In Qt 5, QML has support of importing modules with version. However, this seems to be even not respected by Qt internal components. Module platform packages have even worse support for it (see #26470 (closed)).
In Qt 6, importing modules by specifying version is deprecated. However, it needs to be taken care of when Qt 5 is used.
For example, Qt introduced a new property called restoreMode
in Qt 5.14. This property is quite important because it directly affects how Binding
behaves. They were late to add this property, so they added a warning message which gets printed on every Binding
used throughout the code base that this property must be set:
qml error QML Binding: Not restoring previous value because restoreMode has not been set.
This behavior is deprecated.
You have to import QtQml 2.14 after any QtQuick imports and set
the restoreMode of the binding to fix this warning.
In Qt < 6.0 the default is Binding.RestoreBinding.
In Qt >= 6.0 the default is Binding.RestoreBindingOrValue.
Even worse, the behavior is also impacted, as it no longer restores the previous value. This makes the application behave incorrectly when Qt >= 5.14 is used. The problem is, even if the module containing this type with version older than 5.14 is imported (which is the current case), this error still appears when Qt >= 5.14 is used to build the application.
This merge request registers a new qml module, for the purpose of taking care of these issues. I already fixed the issue with Binding
, but the module may expand in the future. For the fix, I set restore mode to Binding.RestoreValueOrBinding
, which I believe is the intended usage of most Bindings throughout the VLC code base, if not all.
Also, I added a commit to lock modules from registering further types. In the docs it is stated that, protecting a module may bring performance benefits:
The performance benefit is primarily seen when registering application specific types from within the application instead of through a plugin. Using qmlProtectModule allows the engine to skip checking for a plugin when that uri is imported, which can be noticeable with slow file systems.
Close #26527 (closed).