QDBusArgument: disambiguate between QMap on std::pair and std::map
For QMap on a std::pair, QMap::iterator{}.operator->() would result in a type that has "first" and "second" members: std::pair itself. But it would be wrong to marshall and demarshall the first and second elements thereof as the key and value, so give preference to the .key() and .value() selection, which would store the std::pair as the type. Fixes: QTBUG-123401 Change-Id: I6818d78a57394e37857bfffd17bd69bb692dd03b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 5401a9a6cd3263eda15911c3fbfc81ebea2e798f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 9ffed81b159e9bdf4aba26dfdbd08ff508ffe8b3) (cherry picked from commit 1e11f8fa80e5bbce11d0dfe7213d8af1e8c10fe3)
This commit is contained in:
parent
df50d3d52f
commit
bb3d6f96af
@ -265,7 +265,11 @@ using IfAssociativeIteratorHasKeyAndValue =
|
||||
|
||||
template <typename Iterator>
|
||||
using IfAssociativeIteratorHasFirstAndSecond =
|
||||
std::enable_if_t<qxp::is_detected_v<FirstAndSecondTest, Iterator>, bool>;
|
||||
std::enable_if_t<
|
||||
std::conjunction_v<
|
||||
std::negation<qxp::is_detected<KeyAndValueTest, Iterator>>,
|
||||
qxp::is_detected<FirstAndSecondTest, Iterator>
|
||||
>, bool>;
|
||||
|
||||
template <typename T, typename U>
|
||||
using IfIsNotSame =
|
||||
|
@ -152,7 +152,9 @@ void commonInit()
|
||||
qDBusRegisterMetaType<QMap<QDBusObjectPath, QString> >();
|
||||
qDBusRegisterMetaType<QMap<qlonglong, QDateTime> >();
|
||||
qDBusRegisterMetaType<QMap<QDBusSignature, QString> >();
|
||||
qDBusRegisterMetaType<QMap<QString, std::pair<int, int>>>();
|
||||
|
||||
qDBusRegisterMetaType<std::pair<int, int>>();
|
||||
qDBusRegisterMetaType<MyStruct>();
|
||||
qDBusRegisterMetaType<MyVariantMapStruct>();
|
||||
qDBusRegisterMetaType<QList<MyVariantMapStruct> >();
|
||||
@ -468,6 +470,8 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2)
|
||||
return compare<QMap<qlonglong, QDateTime> >(arg, v2);
|
||||
else if (id == qMetaTypeId<QMap<QDBusSignature, QString> >())
|
||||
return compare<QMap<QDBusSignature, QString> >(arg, v2);
|
||||
else if (id == qMetaTypeId<QMap<QString, std::pair<int, int>>>())
|
||||
return compare<QMap<QString, std::pair<int, int>>>(arg, v2);
|
||||
|
||||
else if (id == qMetaTypeId<QList<QByteArray> >())
|
||||
return compare<QList<QByteArray> >(arg, v2);
|
||||
|
@ -475,6 +475,17 @@ void tst_QDBusMarshall::sendMaps_data()
|
||||
QTest::newRow("gs-map") << QVariant::fromValue(gsmap) << "a{gs}"
|
||||
<< "[Argument: a{gs} {[Signature: a{gs}] = \"array of dict_entry of (signature, string)\", [Signature: i] = \"int32\", [Signature: s] = \"string\"}]";
|
||||
|
||||
QMap<QString, std::pair<int, int>> siimap;
|
||||
QTest::newRow("empty-sii-map") << QVariant::fromValue(siimap) << "a{s(ii)}"
|
||||
<< "[Argument: a{s(ii)} {}]";
|
||||
siimap["0,0"] = { 0, 0 };
|
||||
siimap["1,-1"] = { 1, -1 };
|
||||
QTest::newRow("sii-map") << QVariant::fromValue(siimap) << "a{s(ii)}"
|
||||
<< "[Argument: a{s(ii)} {"
|
||||
"\"0,0\" = [Argument: (ii) 0, 0], "
|
||||
"\"1,-1\" = [Argument: (ii) 1, -1]"
|
||||
"}]";
|
||||
|
||||
if (fileDescriptorPassing) {
|
||||
svmap["zzfiledescriptor"] = QVariant::fromValue(QDBusUnixFileDescriptor(fileDescriptorForTest()));
|
||||
QTest::newRow("sv-map1-fd") << QVariant::fromValue(svmap) << "a{sv}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user