Skip to content

Commit fa850a1

Browse files
committed
Save project properties in predictable order
1 parent 5a85e20 commit fa850a1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/core/qgsprojectproperty.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "qgsprojectproperty.h"
1919
#include "qgslogger.h"
20+
#include "qgis.h"
21+
#include "qgsmessagelog.h"
2022

2123
#include <QDomDocument>
2224
#include <QStringList>
@@ -407,14 +409,13 @@ bool QgsProjectPropertyKey::writeXml( QString const &nodeName, QDomElement &elem
407409

408410
if ( ! mProperties.isEmpty() )
409411
{
410-
QHashIterator < QString, QgsProjectProperty * > i( mProperties );
411-
while ( i.hasNext() )
412+
auto keys = mProperties.keys();
413+
std::sort( keys.begin(), keys.end() );
414+
415+
for ( const auto &key : qgis::as_const( keys ) )
412416
{
413-
i.next();
414-
if ( !i.value()->writeXml( i.key(), keyElement, document ) )
415-
{
416-
return false;
417-
}
417+
if ( !mProperties.value( key )->writeXml( key, keyElement, document ) )
418+
QgsMessageLog::logMessage( tr( "Failed to save project property %1" ).arg( key ) );
418419
}
419420
}
420421

src/core/qgsprojectproperty.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <QHash>
2626
#include <QVariant>
2727
#include <QStringList>
28+
#include <QCoreApplication>
2829

2930
#include "qgis_core.h"
3031

@@ -181,6 +182,8 @@ class CORE_EXPORT QgsProjectPropertyValue : public QgsProjectProperty
181182
*/
182183
class CORE_EXPORT QgsProjectPropertyKey : public QgsProjectProperty
183184
{
185+
Q_DECLARE_TR_FUNCTIONS( QgsProjectPropertyKey )
186+
184187
public:
185188

186189
/**

0 commit comments

Comments
 (0)