@@ -1247,8 +1247,6 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
1247
1247
}
1248
1248
delete theImage;
1249
1249
1250
- QMap<QString, QString> originalLayerFilters = applyRequestedLayerFilters ( layersList );
1251
-
1252
1250
#ifdef HAVE_SERVER_PYTHON_PLUGINS
1253
1251
Q_FOREACH ( QgsMapLayer *layer, QgsMapLayerRegistry::instance ()->mapLayers () )
1254
1252
{
@@ -1257,7 +1255,11 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
1257
1255
throw QgsMapServiceException ( " Security" , " You are not allowed to access to the layer: " + layer->name () );
1258
1256
}
1259
1257
}
1258
+ #endif
1259
+
1260
+ QHash<QgsMapLayer*, QString> originalLayerFilters = applyRequestedLayerFilters ( layersList );
1260
1261
1262
+ #ifdef HAVE_SERVER_PYTHON_PLUGINS
1261
1263
applyAccessControlLayersFilters ( layersList, originalLayerFilters );
1262
1264
#endif
1263
1265
@@ -1266,6 +1268,8 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
1266
1268
// GetPrint request needs a template parameter
1267
1269
if ( !mParameters .contains ( " TEMPLATE" ) )
1268
1270
{
1271
+ restoreLayerFilters ( originalLayerFilters );
1272
+ clearFeatureSelections ( selectedLayerIdList );
1269
1273
throw QgsMapServiceException ( " ParameterMissing" , " The TEMPLATE parameter is required for the GetPrint request" );
1270
1274
}
1271
1275
@@ -1340,6 +1344,8 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
1340
1344
}
1341
1345
else // unknown format
1342
1346
{
1347
+ restoreLayerFilters ( originalLayerFilters );
1348
+ clearFeatureSelections ( selectedLayerIdList );
1343
1349
throw QgsMapServiceException ( " InvalidFormat" , " Output format '" + formatString + " ' is not supported in the GetPrint request" );
1344
1350
}
1345
1351
@@ -1381,8 +1387,6 @@ QImage* QgsWMSServer::getMap( HitTest* hitTest )
1381
1387
QPainter thePainter ( theImage );
1382
1388
thePainter.setRenderHint ( QPainter::Antialiasing ); // make it look nicer
1383
1389
1384
- QMap<QString, QString> originalLayerFilters = applyRequestedLayerFilters ( layersList );
1385
-
1386
1390
#ifdef HAVE_SERVER_PYTHON_PLUGINS
1387
1391
Q_FOREACH ( QgsMapLayer *layer, QgsMapLayerRegistry::instance ()->mapLayers () )
1388
1392
{
@@ -1391,7 +1395,11 @@ QImage* QgsWMSServer::getMap( HitTest* hitTest )
1391
1395
throw QgsMapServiceException ( " Security" , " You are not allowed to access to the layer: " + layer->name () );
1392
1396
}
1393
1397
}
1398
+ #endif
1399
+
1400
+ QHash<QgsMapLayer*, QString> originalLayerFilters = applyRequestedLayerFilters ( layersList );
1394
1401
1402
+ #ifdef HAVE_SERVER_PYTHON_PLUGINS
1395
1403
applyAccessControlLayersFilters ( layersList, originalLayerFilters );
1396
1404
#endif
1397
1405
@@ -1618,7 +1626,7 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, const QString& version )
1618
1626
1619
1627
// get the layer registered in QgsMapLayerRegistry and apply possible filters
1620
1628
QStringList layerIds = layerSet ( layersList, stylesList, mMapRenderer ->destinationCrs () );
1621
- QMap<QString , QString> originalLayerFilters = applyRequestedLayerFilters ( layersList );
1629
+ QHash<QgsMapLayer* , QString> originalLayerFilters = applyRequestedLayerFilters ( layersList );
1622
1630
#ifdef HAVE_SERVER_PYTHON_PLUGINS
1623
1631
applyAccessControlLayersFilters ( layersList, originalLayerFilters );
1624
1632
#endif
@@ -1702,6 +1710,7 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, const QString& version )
1702
1710
#ifdef HAVE_SERVER_PYTHON_PLUGINS
1703
1711
if ( !mAccessControl ->layerReadPermission ( currentLayer ) )
1704
1712
{
1713
+ restoreLayerFilters ( originalLayerFilters );
1705
1714
throw QgsMapServiceException ( " Security" , " You are not allowed to access to the layer: " + currentLayer->name () );
1706
1715
}
1707
1716
#endif
@@ -2486,9 +2495,9 @@ QStringList QgsWMSServer::layerSet( const QStringList &layersList,
2486
2495
}
2487
2496
2488
2497
2489
- QMap<QString , QString> QgsWMSServer::applyRequestedLayerFilters ( const QStringList& layerList ) const
2498
+ QHash<QgsMapLayer* , QString> QgsWMSServer::applyRequestedLayerFilters ( const QStringList& layerList ) const
2490
2499
{
2491
- QMap<QString , QString> filterMap;
2500
+ QHash<QgsMapLayer* , QString> filterMap;
2492
2501
2493
2502
if ( layerList.isEmpty () )
2494
2503
{
@@ -2539,7 +2548,7 @@ QMap<QString, QString> QgsWMSServer::applyRequestedLayerFilters( const QStringLi
2539
2548
QgsVectorLayer* filteredLayer = dynamic_cast <QgsVectorLayer*>( filter );
2540
2549
if ( filteredLayer )
2541
2550
{
2542
- filterMap.insert ( filteredLayer-> id () , filteredLayer->subsetString () );
2551
+ filterMap.insert ( filteredLayer, filteredLayer->subsetString () );
2543
2552
QString newSubsetString = eqSplit.at ( 1 );
2544
2553
if ( !filteredLayer->subsetString ().isEmpty () )
2545
2554
{
@@ -2556,10 +2565,10 @@ QMap<QString, QString> QgsWMSServer::applyRequestedLayerFilters( const QStringLi
2556
2565
if ( mMapRenderer && mMapRenderer ->extent ().isEmpty () )
2557
2566
{
2558
2567
QgsRectangle filterExtent;
2559
- QMap<QString , QString>::const_iterator filterIt = filterMap.constBegin ();
2568
+ QHash<QgsMapLayer* , QString>::const_iterator filterIt = filterMap.constBegin ();
2560
2569
for ( ; filterIt != filterMap.constEnd (); ++filterIt )
2561
2570
{
2562
- QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance ()-> mapLayer ( filterIt.key () );
2571
+ QgsMapLayer* mapLayer = filterIt.key ();
2563
2572
if ( !mapLayer )
2564
2573
{
2565
2574
continue ;
@@ -2582,7 +2591,7 @@ QMap<QString, QString> QgsWMSServer::applyRequestedLayerFilters( const QStringLi
2582
2591
}
2583
2592
2584
2593
#ifdef HAVE_SERVER_PYTHON_PLUGINS
2585
- void QgsWMSServer::applyAccessControlLayersFilters ( const QStringList& layerList, QMap<QString , QString>& originalLayerFilters ) const
2594
+ void QgsWMSServer::applyAccessControlLayersFilters ( const QStringList& layerList, QHash<QgsMapLayer* , QString>& originalLayerFilters ) const
2586
2595
{
2587
2596
Q_FOREACH ( const QString& layerName, layerList )
2588
2597
{
0 commit comments