qtwaylandscanner: Send null for a null QString with allow-null
`toUtf8().constData()` on a null `QString` results in an empty string sent over the wire, which is distinct from `null` when the request has "allow-null" specified. Notably `wl_data_offer.accept` uses a null mime_type for "not accepted". [ChangeLog][Important Behavior Changes][qtwaylandscanner] String arguments in a request will now send null rather than empty string for a null QString if the argument is declared with "allow-null". Change-Id: I4b78246e4da7b60680d7797fd6309755f44d2bb6 Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
parent
b0129c6af8
commit
75d324cbb9
@ -196,7 +196,7 @@ Scanner::WaylandEvent Scanner::readEvent(QXmlStreamReader &xml, bool request)
|
|||||||
.type = byteArrayValue(xml, "type"),
|
.type = byteArrayValue(xml, "type"),
|
||||||
.interface = byteArrayValue(xml, "interface"),
|
.interface = byteArrayValue(xml, "interface"),
|
||||||
.summary = byteArrayValue(xml, "summary"),
|
.summary = byteArrayValue(xml, "summary"),
|
||||||
.allowNull = boolValue(xml, "allowNull"),
|
.allowNull = boolValue(xml, "allow-null"),
|
||||||
};
|
};
|
||||||
event.arguments.push_back(std::move(argument));
|
event.arguments.push_back(std::move(argument));
|
||||||
}
|
}
|
||||||
@ -937,9 +937,12 @@ bool Scanner::process()
|
|||||||
printf(",\n");
|
printf(",\n");
|
||||||
QByteArray cType = waylandToCType(a.type, a.interface);
|
QByteArray cType = waylandToCType(a.type, a.interface);
|
||||||
QByteArray qtType = waylandToQtType(a.type, a.interface, e.request);
|
QByteArray qtType = waylandToQtType(a.type, a.interface, e.request);
|
||||||
if (a.type == "string")
|
if (a.type == "string") {
|
||||||
printf(" %s.toUtf8().constData()", a.name.constData());
|
printf(" ");
|
||||||
else if (a.type == "array")
|
if (a.allowNull)
|
||||||
|
printf("%s.isNull() ? nullptr : ", a.name.constData());
|
||||||
|
printf("%s.toUtf8().constData()", a.name.constData());
|
||||||
|
} else if (a.type == "array")
|
||||||
printf(" &%s_data", a.name.constData());
|
printf(" &%s_data", a.name.constData());
|
||||||
else if (cType == qtType)
|
else if (cType == qtType)
|
||||||
printf(" %s", a.name.constData());
|
printf(" %s", a.name.constData());
|
||||||
@ -1225,9 +1228,12 @@ bool Scanner::process()
|
|||||||
} else {
|
} else {
|
||||||
QByteArray cType = waylandToCType(a.type, a.interface);
|
QByteArray cType = waylandToCType(a.type, a.interface);
|
||||||
QByteArray qtType = waylandToQtType(a.type, a.interface, e.request);
|
QByteArray qtType = waylandToQtType(a.type, a.interface, e.request);
|
||||||
if (a.type == "string")
|
if (a.type == "string") {
|
||||||
printf(" %s.toUtf8().constData()", a.name.constData());
|
printf(" ");
|
||||||
else if (a.type == "array")
|
if (a.allowNull)
|
||||||
|
printf("%s.isNull() ? nullptr : ", a.name.constData());
|
||||||
|
printf("%s.toUtf8().constData()", a.name.constData());
|
||||||
|
} else if (a.type == "array")
|
||||||
printf(" &%s_data", a.name.constData());
|
printf(" &%s_data", a.name.constData());
|
||||||
else if (cType == qtType)
|
else if (cType == qtType)
|
||||||
printf(" %s", a.name.constData());
|
printf(" %s", a.name.constData());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user