QSignalSpy: make verify() methods static

... because they can be. We call them without a value object and while
they don't touch *this, ubsan complained (rightfully):

  qsignalspy.h:29:28: runtime error: member call on address 0x7ffdfaab2b20 which does not point to an object of type 'QSignalSpy'
   0x7ffdfaab2b20: note: object has invalid vptr
    00 00 00 00  00 00 00 00 00 00 00 00  00 2b 00 00 c0 60 00 00  60 14 00 00 60 60 00 00  70 14 00 00
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 invalid vptr

Amends e68edd6a07.

Task-number: QTBUG-123544
Change-Id: I8e9ba3270a35777a704e68130d2f2bccb658a536
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
bb10
Marc Mutz 2024-04-16 08:09:03 +02:00
parent 3afcfbc400
commit d2436f7294
1 changed files with 2 additions and 2 deletions

View File

@ -29,7 +29,7 @@ public:
: QSignalSpy(verify(obj, aSignal)) {}
private:
ObjectSignal verify(const QObject *obj, const char *aSignal)
static ObjectSignal verify(const QObject *obj, const char *aSignal)
{
if (!isObjectValid(obj))
return {};
@ -69,7 +69,7 @@ public:
: QSignalSpy(verify(obj, signal)) {}
private:
ObjectSignal verify(const QObject *obj, QMetaMethod signal)
static ObjectSignal verify(const QObject *obj, QMetaMethod signal)
{
if (isObjectValid(obj) && isSignalMetaMethodValid(signal))
return {obj, signal};