diff options
author | Marc Mutz <marc.mutz@qt.io> | 2024-04-18 16:24:07 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2024-04-26 01:45:55 +0200 |
commit | 51e0a33a54968ddac179aa376cef4af73dd972af (patch) | |
tree | c52838d00ef8cbbee2e2e4bb27713fd6ff487dc2 | |
parent | 9ecb468aec3ec0d649587007786475d9a9974a30 (diff) |
QSignalSpy: de-inline most of the private ctor
... by moving its body into an out-of-line init() function.
This allows to drop the exporting of connectToSignal().
We can't de-inline the whole ctor (yet), because that would pin the
vtable to the qsignalspy.cpp TU, which would require us to export the
class wholesale to make the vtable accessible to users of the class,
but we can't export the class because it inherits QList.
Task-number: QTBUG-123544
Change-Id: Ieffd6d2f542daa20e876c6114cb5dc8150870bb4
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
-rw-r--r-- | src/testlib/qsignalspy.cpp | 11 | ||||
-rw-r--r-- | src/testlib/qsignalspy.h | 12 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/testlib/qsignalspy.cpp b/src/testlib/qsignalspy.cpp index 78eb14e6d8..3f06a09deb 100644 --- a/src/testlib/qsignalspy.cpp +++ b/src/testlib/qsignalspy.cpp @@ -244,6 +244,17 @@ QList<int> QSignalSpy::makeArgs(const QMetaMethod &member, const QObject *obj) return result; } +void QSignalSpy::init(ObjectSignal os) +{ + if (!os.obj) + return; + + if (!connectToSignal(os.obj, os.sig.methodIndex())) + return; + + sig = os.sig.methodSignature(); +} + bool QSignalSpy::connectToSignal(const QObject *sender, int sigIndex) { static const int memberOffset = QObject::staticMetaObject.methodCount(); diff --git a/src/testlib/qsignalspy.h b/src/testlib/qsignalspy.h index 5f52c1dcdf..3fc6d9483a 100644 --- a/src/testlib/qsignalspy.h +++ b/src/testlib/qsignalspy.h @@ -65,20 +65,14 @@ private: explicit QSignalSpy(ObjectSignal os) : args(os.obj ? makeArgs(os.sig, os.obj) : QList<int>{}) { - if (!os.obj) - return; - - if (!connectToSignal(os.obj, os.sig.methodIndex())) - return; - - sig = os.sig.methodSignature(); + init(os); } - + Q_TESTLIB_EXPORT void init(ObjectSignal os); Q_TESTLIB_EXPORT static ObjectSignal verify(const QObject *obj, QMetaMethod signal); Q_TESTLIB_EXPORT static ObjectSignal verify(const QObject *obj, const char *aSignal); - Q_TESTLIB_EXPORT bool connectToSignal(const QObject *sender, int sigIndex); + bool connectToSignal(const QObject *sender, int sigIndex); Q_TESTLIB_EXPORT static QList<int> makeArgs(const QMetaMethod &member, const QObject *obj); Q_TESTLIB_EXPORT void appendArgs(void **a); |