aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2021-11-23 10:12:27 +0100
committerAndrei Golubev <andrei.golubev@qt.io>2021-11-23 18:01:17 +0100
commit509adb58688531dea802f088bcdf969771985d38 (patch)
tree6c9d15c49e9a414b526413f42a65c8961418750e
parentac2e7839b05bc0fa343c3ae266a8e53610aa11e6 (diff)
Enhance QQmltcObjectCreationHelper::set() with an assert
We don't really want to accidentally reset the pointer value after it has been set. So put an assert that should signal there's a bug in qmltc somewhere To actually make assert pass, initialize the pointer array as otherwise some random garbage will be there by default Change-Id: Ie93a41ab0e3d10d496c7d6651fa6e38796ceba1a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qml/qmltc/qqmltcobjectcreationhelper_p.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/qml/qmltc/qqmltcobjectcreationhelper_p.h b/src/qml/qmltc/qqmltcobjectcreationhelper_p.h
index 05bf3adf1e..dfa3359f8f 100644
--- a/src/qml/qmltc/qqmltcobjectcreationhelper_p.h
+++ b/src/qml/qmltc/qqmltcobjectcreationhelper_p.h
@@ -108,6 +108,7 @@ public:
{
Q_ASSERT(m_data);
Q_ASSERT(i >= 0 && i + offset() < m_size);
+ Q_ASSERT(m_data[i + offset()] == nullptr); // prevent accidental resets
m_data[i + offset()] = object;
}
};
@@ -122,7 +123,7 @@ template<typename QmltcGeneratedType>
class QQmltcObjectCreationBase
{
// Note: +1 for the document root itself
- std::array<QObject *, QmltcGeneratedType::q_qmltc_typeCount + 1> m_objects;
+ std::array<QObject *, QmltcGeneratedType::q_qmltc_typeCount + 1> m_objects = {};
public:
QQmltcObjectCreationHelper view()