|
16 | 16 | ***************************************************************************/
|
17 | 17 |
|
18 | 18 | #include "qgsobjectcustomproperties.h"
|
| 19 | +#include "qgis.h" |
19 | 20 |
|
20 | 21 | #include <QDomNode>
|
21 | 22 | #include <QStringList>
|
@@ -118,17 +119,22 @@ void QgsObjectCustomProperties::writeXml( QDomNode &parentNode, QDomDocument &do
|
118 | 119 |
|
119 | 120 | QDomElement propsElement = doc.createElement( QStringLiteral( "customproperties" ) );
|
120 | 121 |
|
121 |
| - for ( QMap<QString, QVariant>::const_iterator it = mMap.constBegin(); it != mMap.constEnd(); ++it ) |
| 122 | + auto keys = mMap.keys(); |
| 123 | + |
| 124 | + std::sort( keys.begin(), keys.end() ); |
| 125 | + |
| 126 | + for ( const auto &key : qgis::as_const( keys ) ) |
122 | 127 | {
|
123 | 128 | QDomElement propElement = doc.createElement( QStringLiteral( "property" ) );
|
124 |
| - propElement.setAttribute( QStringLiteral( "key" ), it.key() ); |
125 |
| - if ( it.value().canConvert<QString>() ) |
| 129 | + propElement.setAttribute( QStringLiteral( "key" ), key ); |
| 130 | + const QVariant value = mMap.value( key ); |
| 131 | + if ( value.canConvert<QString>() ) |
126 | 132 | {
|
127 |
| - propElement.setAttribute( QStringLiteral( "value" ), it.value().toString() ); |
| 133 | + propElement.setAttribute( QStringLiteral( "value" ), value.toString() ); |
128 | 134 | }
|
129 |
| - else if ( it.value().canConvert<QStringList>() ) |
| 135 | + else if ( value.canConvert<QStringList>() ) |
130 | 136 | {
|
131 |
| - const auto constToStringList = it.value().toStringList(); |
| 137 | + const auto constToStringList = value.toStringList(); |
132 | 138 | for ( const QString &value : constToStringList )
|
133 | 139 | {
|
134 | 140 | QDomElement itemElement = doc.createElement( QStringLiteral( "value" ) );
|
|
0 commit comments