qMetaTypeId(): deprecate the dummy parameter.

It was there because of MSVC6 compatibility.

It is not removed, because some code used to do
 qMetaTypeId(&myVariable);

This was not a documented feature anyway, so it should not be user
visible.

Change-Id: I55327d7e73e67a6bb741817741d530d5a650291a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
bb10
Olivier Goffart 2013-02-05 15:46:28 +01:00 committed by The Qt Project
parent f79cc2d66b
commit c6cb4ddbf9
3 changed files with 19 additions and 19 deletions

View File

@ -631,30 +631,30 @@ void qRegisterMetaTypeStreamOperators(const char *typeName
#endif // QT_NO_DATASTREAM
template <typename T>
inline Q_DECL_CONSTEXPR int qMetaTypeId(
#ifndef Q_QDOC
T * /* dummy */ = 0
#endif
)
inline Q_DECL_CONSTEXPR int qMetaTypeId()
{
Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
return QMetaTypeId2<T>::qt_metatype_id();
}
template <typename T>
inline Q_DECL_CONSTEXPR int qRegisterMetaType(
#if !defined(Q_QDOC) && !defined(Q_CC_SUN)
T * dummy = 0
#endif
)
inline Q_DECL_CONSTEXPR int qRegisterMetaType()
{
#ifdef Q_CC_SUN
return qMetaTypeId(static_cast<T *>(0));
#else
return qMetaTypeId(dummy);
#endif
return qMetaTypeId<T>();
}
#if QT_DEPRECATED_SINCE(5, 1) && !defined(Q_QDOC)
// There used to be a T *dummy = 0 argument in Qt 4.0 to support MSVC6
template <typename T>
QT_DEPRECATED inline Q_DECL_CONSTEXPR int qMetaTypeId(T *)
{ return qMetaTypeId<T>(); }
#ifndef Q_CC_SUN
template <typename T>
QT_DEPRECATED inline Q_DECL_CONSTEXPR int qRegisterMetaType(T *)
{ return qRegisterMetaType<T>(); }
#endif
#endif
template <typename T>
struct QMetaTypeIdQObject<T*, /* isPointerToTypeDerivedFromQObject */ true>
{

View File

@ -484,7 +484,7 @@ public:
template <typename T>
inline QVariant qVariantFromValue(const T &t)
{
return QVariant(qMetaTypeId<T>(reinterpret_cast<T *>(0)), &t, QTypeInfo<T>::isPointer);
return QVariant(qMetaTypeId<T>(), &t, QTypeInfo<T>::isPointer);
}
template <>
@ -494,7 +494,7 @@ template <typename T>
inline void qVariantSetValue(QVariant &v, const T &t)
{
//if possible we reuse the current QVariant private
const uint type = qMetaTypeId<T>(reinterpret_cast<T *>(0));
const uint type = qMetaTypeId<T>();
QVariant::Private &d = v.data_ptr();
if (v.isDetached() && (type == d.type || (type <= uint(QVariant::Char) && d.type <= uint(QVariant::Char)))) {
d.type = type;
@ -568,7 +568,7 @@ namespace QtPrivate {
{
static T metaType(const QVariant &v)
{
const int vid = qMetaTypeId<T>(static_cast<T *>(0));
const int vid = qMetaTypeId<T>();
if (vid == v.userType())
return *reinterpret_cast<const T *>(v.constData());
if (vid < int(QMetaType::User)) {

View File

@ -69,7 +69,7 @@ public:
}
inline QDBusReply& operator=(const QDBusMessage &reply)
{
QVariant data(qMetaTypeId(&m_data), reinterpret_cast<void*>(0));
QVariant data(qMetaTypeId<Type>(), reinterpret_cast<void*>(0));
qDBusReplyFill(reply, m_error, data);
m_data = qvariant_cast<Type>(data);
return *this;