From 4fff2bb14e55484eacec0a1b49a2b02958f75eca Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 15 Dec 2017 13:53:55 +0100 Subject: Fix QQml_setParent_noEvent not to print undefined behavior errors When building Qt with -fsanitize undefined, the usage of QQml_setParent_noEvent caused the following error message: "qqmlglobal_p.h:233:5: runtime error: downcast of address 0x60300061bf10 which does not point to an object of type 'QQmlGraphics_DerivedObject'". Instead of casting to the referred type, use QObjectPrivate::get to access the d_ptr. Change-Id: I2f2224bdb20a8d2e35a3291961378231f03c4ba2 Reviewed-by: Simon Hausmann --- tests/benchmarks/qml/creation/tst_creation.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'tests/benchmarks') diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index 91f907ab5e..ed2e52f869 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -204,19 +204,13 @@ void tst_creation::qobject_qmltype() } } -struct QQmlGraphics_Derived : public QObject -{ - void setParent_noEvent(QObject *parent) { - bool sce = d_ptr->sendChildEvents; - d_ptr->sendChildEvents = false; - setParent(parent); - d_ptr->sendChildEvents = sce; - } -}; - inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent) { - static_cast(object)->setParent_noEvent(parent); + QObjectPrivate *d_ptr = QObjectPrivate::get(object); + bool sce = d_ptr->sendChildEvents; + d_ptr->sendChildEvents = false; + object->setParent(parent); + d_ptr->sendChildEvents = sce; } void tst_creation::itemtree_notree_cpp() -- cgit v1.2.3