qt5base-lts/tests/auto
Giuseppe D'Angelo 9e75a4cca3 QDomDocument: ensure a defined order of attributes when saving
XML does not impose any semantics based on the order of the attributes;
they're an unordered set. Quoting [1]:

> Note that the order of attribute specifications in a start-tag or empty-element tag is not significant

and [2] 2.2.5:

> An unordered set of attribute information items

Still, using a QHash-based implementation to store attributes is
annoying, because one cannot serialize the document in a stable way.
The order of attributes is going to depend on the QString hash function
(which we can change at any time) and the QHash seed (which is random
and changes at every run). In other words, saving the same DOM will
yield non deterministic outputs. That's annoying for testing,
reproducible builds, and so on.

Switching to an _ordered_ associative container for storing attributes
won't, on its own, ensure any specific ordering. That's because:

* attributes are currently kept associated using their name as the key,
ignoring an eventual namespace prefix;

* there's some convoluted logic that sometimes emits attributes in the
xmlns namespace (to qualify a prefix).

Hence, just go for the straightforward implementation and sort the
attributes before streaming them. In the main loop I could have used a
range-based for loop over the associative container used for attributes;
since it's a Qt container, it would have yielded just the values in the
map, and we are not interested into the keys. However I'm preparing for
further changes down the road, so I'm opting for key/value iteration.

I'm deliberately not offering an opt-out because:

* I don't think this is so expensive to justify an opt-out;
* I'm going to remove QHash anyways in a follow up commit.

[1] https://www.w3.org/TR/xml11/#sec-starttags
[2] https://www.w3.org/TR/xml-infoset/#infoitem.element

Task-number: QTBUG-76800
Task-number: QTBUG-25071
Change-Id: I6282ae2ccbee9c0099f138de48b94bb7c40b3680
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-12-09 16:29:11 +01:00
..
bic/data Revert "Add binary compatibility file generated against 6.4.0" 2022-11-17 13:52:02 +00:00
cmake Add forwarding of CMake variables to ABI-specific external projects 2022-12-08 23:24:22 +01:00
concurrent Temporarily skip tst_qtcuncurrentrun::pollForIsFinished in emulator 2022-11-30 18:01:47 +01:00
corelib Adapt corelib to use QTimeZone in place of Qt::TimeSpec 2022-12-09 16:16:48 +01:00
dbus tst_qdbusmetatype: fix build with Clang (and probably MSVC) 2022-12-09 05:07:25 +00:00
gui Fix missing text when Harfbuzz fails to shape a substring 2022-12-05 07:55:43 +01:00
guiapplauncher
network QNetworkAccessManager: Configurable number of HTTP1 TCP connections 2022-12-09 02:40:12 +00:00
opengl
other Blacklist tst_gestures on OpenSuSE 2022-11-24 09:06:47 +00:00
printsupport Port from qAsConst() to std::as_const() 2022-10-11 23:17:18 +02:00
shared Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
sql SQL/MySQL: fix handling of json column 2022-12-05 01:56:45 +00:00
testlib Use QString/QByteArray range erase() 2022-12-07 15:03:03 +02:00
tools moc: Output the "cloned" flag for methods 2022-11-27 12:47:30 +01:00
wasm Fix typo in QWasmWindowStack's name 2022-10-20 16:36:23 +02:00
widgets Port QDateTimeEdit internals to QTimeZone 2022-12-09 16:16:48 +01:00
xml QDomDocument: ensure a defined order of attributes when saving 2022-12-09 16:29:11 +01:00
CMakeLists.txt Add forwarding of CMake variables to ABI-specific external projects 2022-12-08 23:24:22 +01:00
network-settings.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00