fix compilation with conforming compilers (e.g. GCC >= 4.7)

In qdbus_cast(), qMetaTypeId<QDBusArgument> as well as
qvariant_cast<QDBusArgument> are used. They don't depend
on any template argument of qdbus_cast(), so their
definitions need to be available at function template
definition instead of instantiation time.

But the necessary Q_DECLARE_METATYPE(QDBusArgument)
was at the end of the header, after the defintion of
qdbus_cast(), which is too late for conformin compilers.

Fixed by moving it up just after the QDBusArgument
definition.

Similarly, in tst_qdatetime and tst_qvector, the
Q_DECLARE_METATYPE() for Qt::DateFormat and QVector<int>,
and with it the specialisation of QMetaTypeId<>, were
issued after the first use of meta typing; too late for
conforming compilers.

Change-Id: I25ca0b06e68d5184597a22708404a8f2040b2de1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Marc Mutz 2012-07-06 15:58:00 +02:00 committed by Qt by Nokia
parent c327838f67
commit 7e0562c5ff
3 changed files with 7 additions and 6 deletions

View File

@ -151,6 +151,10 @@ protected:
mutable QDBusArgumentPrivate *d;
};
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDBusArgument)
QT_BEGIN_NAMESPACE
template<typename T> inline T qdbus_cast(const QDBusArgument &arg
#ifndef Q_QDOC
, T * = 0
@ -396,8 +400,6 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map)
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDBusArgument)
QT_END_HEADER
#endif // QT_NO_DBUS

View File

@ -141,6 +141,7 @@ Q_DECLARE_METATYPE(QDateTime)
Q_DECLARE_METATYPE(QDate)
Q_DECLARE_METATYPE(QTime)
Q_DECLARE_METATYPE(Qt::TimeSpec)
Q_DECLARE_METATYPE(Qt::DateFormat)
tst_QDateTime::tst_QDateTime()
{
@ -1626,7 +1627,5 @@ void tst_QDateTime::utcOffsetLessThan() const
QVERIFY(!(dt2 < dt1));
}
Q_DECLARE_METATYPE(Qt::DateFormat)
QTEST_APPLESS_MAIN(tst_QDateTime)
#include "tst_qdatetime.moc"

View File

@ -293,6 +293,8 @@ private:
template<typename T> void detach() const;
};
Q_DECLARE_METATYPE(QVector<int>);
template<typename T> struct SimpleValue
{
static T at(int index)
@ -2026,8 +2028,6 @@ void tst_QVector::const_shared_null()
QVERIFY(!v2.isDetached());
}
Q_DECLARE_METATYPE(QVector<int>);
template<typename T>
void tst_QVector::setSharable_data() const
{