aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-07-04 11:56:07 +0200
committerMarc Mutz <[email protected]>2025-07-10 18:08:36 +0200
commitf02a0f6f8a3c79659fff5093a340e396590eda10 (patch)
treeac2adcfccc543fab49db16cd8d30062b63d15a84
parentbc613810d863eeb348b92a4d1fc83c9a3c09fab2 (diff)
qquick3dparticleutils: check extent of qt_quick3d_sine_table[]HEADdev
Let the compiler count the number of elements in qt_quick3d_sine_table[], and then statically assert that it's as expected. We had enough cases where zero-inialized elements were added at the end silently by using the old technique. As a drive-by, add Q_CONSTINIT. Amends 0b4f59d0660b9d508c394e0b3039637364c89287. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I1c3f6136803f5d2e292ea7eb827ef470efb54a61 Reviewed-by: Volker Hilsheimer <[email protected]>
-rw-r--r--src/quick3dparticles/qquick3dparticleutils.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/quick3dparticles/qquick3dparticleutils.cpp b/src/quick3dparticles/qquick3dparticleutils.cpp
index 719f0615..3514b6e0 100644
--- a/src/quick3dparticles/qquick3dparticleutils.cpp
+++ b/src/quick3dparticles/qquick3dparticleutils.cpp
@@ -6,9 +6,11 @@
#include <QtGui/qquaternion.h>
+#include <iterator>
+
QT_BEGIN_NAMESPACE
-const float qt_quick3d_sine_table[QT_QUICK3D_SINE_TABLE_SIZE] = {
+Q_CONSTINIT const float qt_quick3d_sine_table[] = {
float(0.0),
float(0.024541228522912288),
float(0.049067674327418015),
@@ -266,6 +268,7 @@ const float qt_quick3d_sine_table[QT_QUICK3D_SINE_TABLE_SIZE] = {
float(-0.049067674327418091),
float(-0.024541228522912448)
};
+static_assert(std::size(qt_quick3d_sine_table) == QT_QUICK3D_SINE_TABLE_SIZE);
QQuick3DNode *getSharedParentNode(QQuick3DNode *node, QQuick3DNode *system) {
QQuick3DNode *systemSharedParent = nullptr;