QDBusArgument: ensure std::vector isn't seen as an associative container

This broke compilation of qDBusRegisterMetaType<std::vector<MyStruct>>
because std::vector<T> is in fact std::vector<T, std::allocator<T>>.

Pick-to: 6.2
Change-Id: I6a13f5f0476a3faa3a43da54d90d652b4bdd8186
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
David Faure 2021-08-24 14:20:41 +02:00
parent 42cf2a2617
commit 546e11f1dc
2 changed files with 4 additions and 1 deletions

View File

@ -264,7 +264,7 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const Container<Key, T> &ma
}
template <template <typename, typename> class Container, typename Key, typename T,
typename = typename Container<Key, T>::iterator>
QtPrivate::IfAssociativeIteratorHasKeyAndValue<typename Container<Key, T>::iterator> = true>
inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<Key, T> &map)
{
arg.beginMap();

View File

@ -245,6 +245,8 @@ void tst_QDBusMetaType::initTestCase()
qDBusRegisterMetaType<QList<Struct3> >();
qDBusRegisterMetaType<QList<Struct4> >();
qDBusRegisterMetaType<std::vector<Struct1> >();
qDBusRegisterMetaType<Invalid0>();
qDBusRegisterMetaType<Invalid1>();
qDBusRegisterMetaType<Invalid2>();
@ -305,6 +307,7 @@ void tst_QDBusMetaType::dynamicTypes_data()
QTest::newRow("Struct1") << qMetaTypeId<Struct1>() << "(s)";
QTest::newRow("QList<Struct1>") << qMetaTypeId<QList<Struct1> >() << "a(s)";
QTest::newRow("std::vector<Struct1>") << qMetaTypeId<std::vector<Struct1> >() << "a(s)";
QTest::newRow("Struct2") << qMetaTypeId<Struct2>() << "(sos)";
QTest::newRow("QList<Struct2>") << qMetaTypeId<QList<Struct2>>() << "a(sos)";