Skip to content
Permalink
Browse files
Speed up loading of complex projects with many symbols
  • Loading branch information
nyalldawson committed Aug 19, 2021
1 parent 1706e7b commit 9cfdf3d31b50f788c0d8ed544f9f04da249345f0
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/core/symbology/qgssymbollayerreference.cpp
@@ -40,10 +40,12 @@ QString symbolLayerReferenceListToString( const QgsSymbolLayerReferenceList &lst
QgsSymbolLayerReferenceList stringToSymbolLayerReferenceList( const QString &str )
{
QgsSymbolLayerReferenceList lst;
if ( str.isEmpty() )
return lst;

// when saving we used ; as a concatenator... but that was silly, cos maybe the symbol keys contain this string!
// try to handle this gracefully via regex...
const QRegularExpression partsRx( QStringLiteral( "((?:.*?),(?:.*?),(?:(?:\\d+,)+)?(?:\\d+);)" ) );
const thread_local QRegularExpression partsRx( QStringLiteral( "((?:.*?),(?:.*?),(?:(?:\\d+,)+)?(?:\\d+);)" ) );
QRegularExpressionMatchIterator partsIt = partsRx.globalMatch( str + ';' );

while ( partsIt.hasNext() )
@@ -54,7 +56,7 @@ QgsSymbolLayerReferenceList stringToSymbolLayerReferenceList( const QString &str
// We should have "layer_id,symbol_key,symbol_layer_index0,symbol_layer_index1,..."
// EXCEPT that the symbol_key CAN have commas, so this whole logic is extremely broken.
// Let's see if a messy regex can save the day!
const QRegularExpression rx( QStringLiteral( "(.*?),(.*?),((?:\\d+,)+)?(\\d+)" ) );
const thread_local QRegularExpression rx( QStringLiteral( "(.*?),(.*?),((?:\\d+,)+)?(\\d+)" ) );

const QRegularExpressionMatch match = rx.match( tuple );
if ( !match.hasMatch() )

0 comments on commit 9cfdf3d

Please sign in to comment.