Skip to content

Commit

Permalink
fix reordering of render order (followup 78c60a2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 2, 2015
1 parent 5f23329 commit df4a41f
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 df4a41f

Please sign in to comment.