diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 53e320e717b..51cb7f4856e 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2390,7 +2390,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 ad2f2564506..47012f9a28d 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: