diff options
author | Marc Mutz <[email protected]> | 2024-03-20 17:14:41 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2024-03-22 14:53:17 +0000 |
commit | f9e79171b6228de4a223c19c82b76ed1d5b4524b (patch) | |
tree | b97286cbf8fbb37cdd67fc39f5207927ca600f32 | |
parent | d50ba5ff5ec0d2ed78643043278950b58ac2cb08 (diff) |
QMetaMethod: document that fromSignal(nullptr) is ok
... and add a test.
Pick-to: 6.2 5.15
Change-Id: I907899d7c54349d2fc23ea5ab58a1e67826b622b
Reviewed-by: Thiago Macieira <[email protected]>
Reviewed-by: MÃ¥rten Nordheim <[email protected]>
(cherry picked from commit 78db468f4895911e50849223899abf2c5fb1c72e)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
(cherry picked from commit 9f14d0a288ef5355ca92e64fe464735f119b8ec5)
(cherry picked from commit fcd465512aa78039123343da86610a36f509878e)
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 97bc2f160c3..12a8038c612 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2338,7 +2338,7 @@ QMetaMethod::MethodType QMetaMethod::methodType() const \since 5.0 Returns the meta-method that corresponds to the given \a signal, or an - invalid QMetaMethod if \a signal is not a signal of the class. + invalid QMetaMethod if \a signal is \c{nullptr} or not a signal of the class. Example: diff --git a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp index 4cc15159e7f..4b502700fd4 100644 --- a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp +++ b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp @@ -22,6 +22,7 @@ private slots: void comparisonOperators(); void fromSignal(); + void fromSignalOfNullSignalIsInvalid(); void gadget(); void revision(); @@ -719,6 +720,12 @@ void tst_QMetaMethod::fromSignal() #undef FROMSIGNAL_HELPER } +void tst_QMetaMethod::fromSignalOfNullSignalIsInvalid() +{ + constexpr decltype(&QObject::destroyed) ptr = nullptr; + QVERIFY(!QMetaMethod::fromSignal(ptr).isValid()); +} + class MyGadget { Q_GADGET public: |