Add nicer error message in qMetaTypeId function.

The function can be used only with a registered type and it would fail
to compile for other types. By adding the static assert we can print
an almost user friendly compilation error message.

Change-Id: I59ab148cabf32afe0baef186b82cb03303b57780
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
bb10
Jędrzej Nowacki 2012-03-06 15:12:06 +01:00 committed by Qt by Nokia
parent f72cbc7ce4
commit 7439fb47cd
1 changed files with 1 additions and 0 deletions

View File

@ -484,6 +484,7 @@ inline int qMetaTypeId(
#endif
)
{
Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use Q_DECLARE_METATYPE macro to make it know to Qt's meta-object system");
return QMetaTypeId2<T>::qt_metatype_id();
}