diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index d56e9aa60c..ef89786a4d 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -290,16 +290,17 @@ class QPrivateSlotObject : public QSlotObjectBase, private FunctionStorage typedef QtPrivate::FunctionPointer FuncType; static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret) { + const auto that = static_cast(this_); switch (which) { case Destroy: - delete static_cast(this_); + delete that; break; case Call: - FuncType::template call(static_cast(this_)->func(), + FuncType::template call(that->func(), static_cast(QObjectPrivate::get(r)), a); break; case Compare: - *ret = *reinterpret_cast(a) == static_cast(this_)->func(); + *ret = *reinterpret_cast(a) == that->func(); break; case NumOperations: ; } diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 41ef92b4aa..156a6d6c42 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -413,19 +413,20 @@ namespace QtPrivate { FunctorValue function; static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret) { + const auto that = static_cast(this_); switch (which) { case Destroy: - delete static_cast(this_); + delete that; break; case Call: if constexpr (std::is_member_function_pointer_v) - FuncType::template call(static_cast(this_)->function, static_cast(r), a); + FuncType::template call(that->function, static_cast(r), a); else - FuncType::template call(static_cast(this_)->function, r, a); + FuncType::template call(that->function, r, a); break; case Compare: if constexpr (std::is_member_function_pointer_v) { - *ret = *reinterpret_cast(a) == static_cast(this_)->function; + *ret = *reinterpret_cast(a) == that->function; break; } // not implemented otherwise