diff options
| author | Ahmad Samir <a.samirh78@gmail.com> | 2025-09-12 20:41:17 +0300 |
|---|---|---|
| committer | Ahmad Samir <a.samirh78@gmail.com> | 2025-10-02 01:40:20 +0300 |
| commit | 24ccf8c5a0b6232594fe22c8524f3db016e55b1d (patch) | |
| tree | e4835e15b2a67b9cba1c0ff8480b94a98aca33b9 /src/corelib/kernel/qmetaobject.cpp | |
| parent | 15b1bd2c819996321dd8e76f5e7be5a9dc670f58 (diff) | |
QObject: warn about using SLOT macro with non-slot functions
And make it no-op in Qt7.
[ChangeLog][QtCore][Important Behavior Change] A warning will be shown
if the SLOT() macro is used with a function not marked as a slot, but
it'll continue to work to keep backwards-compatibility. However in Qt7
the SLOT() macro will be no-op for non-slot functions.
Change-Id: I9ea112b7a72a26fcc5548ebc3c0220eab19d0455
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
| -rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index e6b0b9043c7..a5d34eac707 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -735,9 +735,14 @@ inline int QMetaObjectPrivate::indexOfMethodRelative(const QMetaObject **baseObj Q_UNREACHABLE_RETURN(-1); } + // Is iterating backwards here significant? for (; i >= end; --i) { auto data = QMetaMethod::fromRelativeMethodIndex(m, i); if (methodMatch(m, data, name, types)) { + if (QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) + && what == QMetaMethod::Slot && data.methodType() != QMetaMethod::Slot) { + return -1; + } *baseObject = m; return i; } |
