Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Server] GetLegendGraphics : Wait for feature counter finshed
  • Loading branch information
rldhont committed Sep 19, 2017
1 parent f88af6d commit f316518
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -62,6 +62,7 @@
#include "qgsannotationmanager.h"
#include "qgsannotation.h"
#include "qgsvectorlayerlabeling.h"
#include "qgsvectorlayerfeaturecounter.h"
#include "qgspallabeling.h"
#include "qgslayerrestorer.h"
#include "qgsdxfexport.h"
Expand Down Expand Up @@ -2823,13 +2824,23 @@ namespace QgsWms

// build layer tree
rootGroup.clear();
QList<QgsVectorLayerFeatureCounter *> counters;
Q_FOREACH ( QgsMapLayer *ml, layers )
{
QgsLayerTreeLayer *lt = rootGroup.addLayer( ml );
lt->setCustomProperty( QStringLiteral( "showFeatureCount" ), showFeatureCount );

if ( !ml->title().isEmpty() )
lt->setName( ml->title() );

if ( ml->type() != QgsMapLayer::VectorLayer || !showFeatureCount )
continue;

QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( ml );
QgsVectorLayerFeatureCounter *counter = vl->countSymbolFeatures();
if ( !counter )
continue;
counters.append( counter );
}

// build legend model
Expand Down Expand Up @@ -2907,6 +2918,13 @@ namespace QgsWms
}
}

for ( QgsVectorLayerFeatureCounter *c : counters )
{
if ( !c )
continue;
c->waitForFinished();
}

return legendModel;
}

Expand Down

0 comments on commit f316518

Please sign in to comment.