QVectorND: make some constructors explicit
QVector2D has implicit conversions towards QVector3D/4D, and QVector3D has an implicit conversion towards QVector4D. Although in principle this is fine because it's not a data loss, it's still sketchy; for instance, it allows mixed operations to compile: vector2d + vector3d; vector4d - vector3d; vector3d * vector4d; // ! (Random observation: the conversion from QPoint(F) to QVectorND are actually already marked as explicit.) This is a leftover not done for Qt 6.0. I am not making these opt-out: having an implicit conversion here is outright *dangerous*, and any usage that fails to compile needs to be inspected to make sure it was the intended behavior. [ChangeLog][Potentially Source-Incompatible Changes] The QVector2D/3D/4D converting constructors from another QVectorND now explicit. This was done to prevent a category of bugs resulting from operations accidentally mixing QVectorND objects. Fixes: QTBUG-90327 Change-Id: Ifcd873f6a0d3fc10b9e68c935fe1f69f86a2340b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
f1465c621c
commit
5a0e5521e4
@ -196,7 +196,7 @@ public:
|
||||
constexpr explicit QVector3D(QPoint point) noexcept;
|
||||
constexpr explicit QVector3D(QPointF point) noexcept;
|
||||
#ifndef QT_NO_VECTOR2D
|
||||
constexpr QVector3D(QVector2D vector) noexcept;
|
||||
constexpr explicit QVector3D(QVector2D vector) noexcept;
|
||||
constexpr QVector3D(QVector2D vector, float zpos) noexcept;
|
||||
#endif
|
||||
#ifndef QT_NO_VECTOR4D
|
||||
@ -340,11 +340,11 @@ public:
|
||||
constexpr explicit QVector4D(QPoint point) noexcept;
|
||||
constexpr explicit QVector4D(QPointF point) noexcept;
|
||||
#ifndef QT_NO_VECTOR2D
|
||||
constexpr QVector4D(QVector2D vector) noexcept;
|
||||
constexpr explicit QVector4D(QVector2D vector) noexcept;
|
||||
constexpr QVector4D(QVector2D vector, float zpos, float wpos) noexcept;
|
||||
#endif
|
||||
#ifndef QT_NO_VECTOR3D
|
||||
constexpr QVector4D(QVector3D vector) noexcept;
|
||||
constexpr explicit QVector4D(QVector3D vector) noexcept;
|
||||
constexpr QVector4D(QVector3D vector, float wpos) noexcept;
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user