Skip to content

Commit

Permalink
Save project properties in predictable order
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 9, 2019
1 parent 5a85e20 commit fa850a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/core/qgsprojectproperty.cpp
Expand Up @@ -17,6 +17,8 @@

#include "qgsprojectproperty.h"
#include "qgslogger.h"
#include "qgis.h"
#include "qgsmessagelog.h"

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

if ( ! mProperties.isEmpty() )
{
QHashIterator < QString, QgsProjectProperty * > i( mProperties );
while ( i.hasNext() )
auto keys = mProperties.keys();
std::sort( keys.begin(), keys.end() );

for ( const auto &key : qgis::as_const( keys ) )
{
i.next();
if ( !i.value()->writeXml( i.key(), keyElement, document ) )
{
return false;
}
if ( !mProperties.value( key )->writeXml( key, keyElement, document ) )
QgsMessageLog::logMessage( tr( "Failed to save project property %1" ).arg( key ) );
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsprojectproperty.h
Expand Up @@ -25,6 +25,7 @@
#include <QHash>
#include <QVariant>
#include <QStringList>
#include <QCoreApplication>

#include "qgis_core.h"

Expand Down Expand Up @@ -181,6 +182,8 @@ class CORE_EXPORT QgsProjectPropertyValue : public QgsProjectProperty
*/
class CORE_EXPORT QgsProjectPropertyKey : public QgsProjectProperty
{
Q_DECLARE_TR_FUNCTIONS( QgsProjectPropertyKey )

public:

/**
Expand Down

0 comments on commit fa850a1

Please sign in to comment.