summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-09-06 08:39:21 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-09-07 12:09:49 -0700
commit7e8c7b3ed86828e4b0fcc1f01a7666cfb1ecbe99 (patch)
tree016d857e0cee248deea05495f679afcb8d7f902f
parentda2fd6a9038b1130a2ae411546216d8874ffa4f7 (diff)
Q_DECLARE_INTERFACE: delete unspecialized qobject_interface_iid()
Instead of making it return a non-useful nullptr. Change-Id: Ie72b0dd0fbe84d2caae0fffd16a245cce5ea65f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/corelib/kernel/qobject.h5
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp2
2 files changed, 2 insertions, 5 deletions
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index f1e0662461..f64a1a3b08 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -481,8 +481,7 @@ inline T qobject_cast(const QObject *object)
}
-template <class T> inline const char * qobject_interface_iid()
-{ return nullptr; }
+template <class T> constexpr const char * qobject_interface_iid() = delete;
inline const QBindingStorage *qGetBindingStorage(const QObject *o)
{
@@ -497,7 +496,7 @@ inline QBindingStorage *qGetBindingStorage(QObject *o)
# define Q_DECLARE_INTERFACE(IFace, IId)
#elif !defined(Q_MOC_RUN)
# define Q_DECLARE_INTERFACE(IFace, IId) \
- template <> inline const char *qobject_interface_iid<IFace *>() \
+ template <> constexpr const char *qobject_interface_iid<IFace *>() \
{ return IId; } \
template <> inline IFace *qobject_cast<IFace *>(QObject *object) \
{ return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : nullptr)); } \
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 52b687cbfa..da62d73824 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -3582,8 +3582,6 @@ void tst_QObject::interfaceIid()
QByteArray(Bleh_iid));
QCOMPARE(QByteArray(qobject_interface_iid<Foo::Bar *>()),
QByteArray("com.qtest.foobar"));
- QCOMPARE(QByteArray(qobject_interface_iid<FooObject *>()),
- QByteArray());
}
void tst_QObject::deleteQObjectWhenDeletingEvent()