#5310 Fix wrong use of new path id.

Used last used instead of first unused
This commit is contained in:
Jacob Støren
2020-01-08 09:35:14 +01:00
parent 45a3225ec8
commit e9086005d4
2 changed files with 12 additions and 10 deletions

View File

@@ -1399,7 +1399,7 @@ class GlobalPathListMapper
public:
GlobalPathListMapper( const QString& globalPathListTable )
{
m_nextValidIdNumber = 1;
m_maxUsedIdNumber = 0;
QStringList pathPairs = globalPathListTable.split( ";", QString::SkipEmptyParts );
for ( const QString& pathIdPathPair : pathPairs )
@@ -1422,7 +1422,7 @@ public:
if ( isOk )
{
m_nextValidIdNumber = std::max( m_nextValidIdNumber, idNumber );
m_maxUsedIdNumber = std::max( m_maxUsedIdNumber, idNumber );
}
}
@@ -1516,13 +1516,15 @@ public:
private:
QString createUnusedId()
{
QString numberString = QString( "%1" ).arg( (uint)m_nextValidIdNumber, 3, 10, QChar( '0' ) );
m_maxUsedIdNumber++;
QString numberString = QString( "%1" ).arg( (uint)m_maxUsedIdNumber, 3, 10, QChar( '0' ) );
QString pathIdentifier = PATHIDCHAR + pathIdBaseString + numberString + PATHIDCHAR;
m_nextValidIdNumber++;
return pathIdentifier;
}
size_t m_nextValidIdNumber; // Set when parsing the globalPathListTable. Increment while creating new id's
size_t m_maxUsedIdNumber; // Set when parsing the globalPathListTable. Increment while creating new id's
std::map<QString, QString> m_newPathIdToPathMap;
std::map<QString, QString> m_newPathToPathIdMap;