qt: assign value type source size as a whole to prevent potential double image loading
- Feb 01, 2025
-
-
Partially changing a value type changes the whole value. In image case, this means that the images can get re-loaded with indeterminate size just to discard them after the size is determined. Fortunately this does not happen currently, because the sizes are determined before the component is complete and QQuickImage only loads if the component is complete. However, due to the declarative nature of QML, bindings are evaluated and assigned one by one, this means that source size would be changed two times even if .width and .height are pending re-evaluation at the same time (such as both depend on DPR). At the same time, the order is also not defined, so with such a setup as following: sourceSize.width: width * eDPR sourceSize.height: height * eDPR When eDPR changes, Qt evaluates the binding for width or height, adjusts sourceSize, sourceSize changes and change signal is signalled, then evaluates the other sub-part of the value type (width or height), adjusts sourceSize, sourceSize changes again and change signal is signalled. Qt could technically optimize this, but as of Qt 6.8.1 it is not the case. Meanwhile with the following: sourceSize: Qt.size(width * eDPR, height * eDPR) When eDPR changes, Qt evaluates the binding and adjusts the source size, sourceSize changes and change signal is signalled. Source size does not change two times, and the image would not be loaded two times.
32a0be32 -
Partially changing a value type changes the whole value. In image case, this means that the images can get re-loaded with indeterminate size just to discard them after the size is determined. Fortunately this does not happen currently, because the sizes are determined before the component is complete and QQuickImage only loads if the component is complete. However, due to the declarative nature of QML, bindings are evaluated and assigned one by one, this means that source size would be changed two times even if .width and .height are pending re-evaluation at the same time (such as both depend on DPR). At the same time, the order is also not defined, so with such a setup as following: sourceSize.width: width * eDPR sourceSize.height: height * eDPR When eDPR changes, Qt evaluates the binding for width or height, adjusts sourceSize, sourceSize changes and change signal is signalled, then evaluates the other sub-part of the value type (width or height), adjusts sourceSize, sourceSize changes again and change signal is signalled. Qt could technically optimize this, but as of Qt 6.8.1 it is not the case. Meanwhile with the following: sourceSize: Qt.size(width * eDPR, height * eDPR) When eDPR changes, Qt evaluates the binding and adjusts the source size, sourceSize changes and change signal is signalled. Source size does not change two times, and the image would not be loaded two times.
73066495 -
Partially changing a value type changes the whole value. In image case, this means that the images can get re-loaded with indeterminate size just to discard them after the size is determined. Fortunately this does not happen currently, because the sizes are determined before the component is complete and QQuickImage only loads if the component is complete. However, due to the declarative nature of QML, bindings are evaluated and assigned one by one, this means that source size would be changed two times even if .width and .height are pending re-evaluation at the same time (such as both depend on DPR). At the same time, the order is also not defined, so with such a setup as following: sourceSize.width: width * eDPR sourceSize.height: height * eDPR When eDPR changes, Qt evaluates the binding for width or height, adjusts sourceSize, sourceSize changes and change signal is signalled, then evaluates the other sub-part of the value type (width or height), adjusts sourceSize, sourceSize changes again and change signal is signalled. Qt could technically optimize this, but as of Qt 6.8.1 it is not the case. Meanwhile with the following: sourceSize: Qt.size(width * eDPR, height * eDPR) When eDPR changes, Qt evaluates the binding and adjusts the source size, sourceSize changes and change signal is signalled. Source size does not change two times, and the image would not be loaded two times.
cec6daa9 -
Partially changing a value type changes the whole value. In image case, this means that the images can get re-loaded with indeterminate size just to discard them after the size is determined. Fortunately this does not happen currently, because the sizes are determined before the component is complete and QQuickImage only loads if the component is complete. However, due to the declarative nature of QML, bindings are evaluated and assigned one by one, this means that source size would be changed two times even if .width and .height are pending re-evaluation at the same time (such as both depend on DPR). At the same time, the order is also not defined, so with such a setup as following: sourceSize.width: width * eDPR sourceSize.height: height * eDPR When eDPR changes, Qt evaluates the binding for width or height, adjusts sourceSize, sourceSize changes and change signal is signalled, then evaluates the other sub-part of the value type (width or height), adjusts sourceSize, sourceSize changes again and change signal is signalled. Qt could technically optimize this, but as of Qt 6.8.1 it is not the case. Meanwhile with the following: sourceSize: Qt.size(width * eDPR, height * eDPR) When eDPR changes, Qt evaluates the binding and adjusts the source size, sourceSize changes and change signal is signalled. Source size does not change two times, and the image would not be loaded two times.
426d5085 -
Partially changing a value type changes the whole value. In image case, this means that the images can get re-loaded with indeterminate size just to discard them after the size is determined. Fortunately this does not happen currently, because the sizes are determined before the component is complete and QQuickImage only loads if the component is complete. However, due to the declarative nature of QML, bindings are evaluated and assigned one by one, this means that source size would be changed two times even if .width and .height are pending re-evaluation at the same time (such as both depend on DPR). At the same time, the order is also not defined, so with such a setup as following: sourceSize.width: width * eDPR sourceSize.height: height * eDPR When eDPR changes, Qt evaluates the binding for width or height, adjusts sourceSize, sourceSize changes and change signal is signalled, then evaluates the other sub-part of the value type (width or height), adjusts sourceSize, sourceSize changes again and change signal is signalled. Qt could technically optimize this, but as of Qt 6.8.1 it is not the case. Meanwhile with the following: sourceSize: Qt.size(width * eDPR, height * eDPR) When eDPR changes, Qt evaluates the binding and adjusts the source size, sourceSize changes and change signal is signalled. Source size does not change two times, and the image would not be loaded two times.
7adbf332 -
Partially changing a value type changes the whole value. In image case, this means that the images can get re-loaded with indeterminate size just to discard them after the size is determined. Fortunately this does not happen currently, because the sizes are determined before the component is complete and QQuickImage only loads if the component is complete. However, due to the declarative nature of QML, bindings are evaluated and assigned one by one, this means that source size would be changed two times even if .width and .height are pending re-evaluation at the same time (such as both depend on DPR). At the same time, the order is also not defined, so with such a setup as following: sourceSize.width: width * eDPR sourceSize.height: height * eDPR When eDPR changes, Qt evaluates the binding for width or height, adjusts sourceSize, sourceSize changes and change signal is signalled, then evaluates the other sub-part of the value type (width or height), adjusts sourceSize, sourceSize changes again and change signal is signalled. Qt could technically optimize this, but as of Qt 6.8.1 it is not the case. Meanwhile with the following: sourceSize: Qt.size(width * eDPR, height * eDPR) When eDPR changes, Qt evaluates the binding and adjusts the source size, sourceSize changes and change signal is signalled. Source size does not change two times, and the image would not be loaded two times.
cf11d530 -
Partially changing a value type changes the whole value. In image case, this means that the images can get re-loaded with indeterminate size just to discard them after the size is determined. Fortunately this does not happen currently, because the sizes are determined before the component is complete and QQuickImage only loads if the component is complete. However, due to the declarative nature of QML, bindings are evaluated and assigned one by one, this means that source size would be changed two times even if .width and .height are pending re-evaluation at the same time (such as both depend on DPR). At the same time, the order is also not defined, so with such a setup as following: sourceSize.width: width * eDPR sourceSize.height: height * eDPR When eDPR changes, Qt evaluates the binding for width or height, adjusts sourceSize, sourceSize changes and change signal is signalled, then evaluates the other sub-part of the value type (width or height), adjusts sourceSize, sourceSize changes again and change signal is signalled. Qt could technically optimize this, but as of Qt 6.8.1 it is not the case. Meanwhile with the following: sourceSize: Qt.size(width * eDPR, height * eDPR) When eDPR changes, Qt evaluates the binding and adjusts the source size, sourceSize changes and change signal is signalled. Source size does not change two times, and the image would not be loaded two times.
a25a34da
-