Skip to content

Commit

Permalink
fix reordering of render order (followup 78c60a2)
Browse files Browse the repository at this point in the history
(cherry picked from commit df4a41f)
  • Loading branch information
jef-n committed Jul 3, 2015
1 parent a07fdfa commit 37c8b9e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/gui/layertree/qgslayertreemapcanvasbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,31 @@ void QgsLayerTreeMapCanvasBridge::setCustomLayerOrder( const QStringList& order
return;

// verify that the new order is correct
QStringList defOrder = defaultLayerOrder();
QStringList sortedNewOrder = order;
QStringList defOrder( defaultLayerOrder() );
QStringList newOrder( order );
QStringList sortedNewOrder( order );
qSort( defOrder );
qSort( sortedNewOrder );

if ( defOrder.size() < sortedNewOrder.size() )
{
// some bad layers in the list?
// might contain bad layers, but also duplicates
QSet<QString> ids( defOrder.toSet() );

for ( int i = 0; i < sortedNewOrder.size(); i++ )
{
if ( i >= defOrder.size() || defOrder[i] != sortedNewOrder[i] )
if ( !ids.contains( sortedNewOrder[i] ) )
{
newOrder.removeAll( sortedNewOrder[i] );
sortedNewOrder.removeAt( i-- );
}
}
}

if ( defOrder != sortedNewOrder )
return; // must be permutation of the default order

mCustomLayerOrder = order;
mCustomLayerOrder = newOrder;
emit customLayerOrderChanged( mCustomLayerOrder );

if ( mHasCustomLayerOrder )
Expand Down

0 comments on commit 37c8b9e

Please sign in to comment.