Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix crash when project has no groups and project OWS name equals to
... first layer short name

Manually backported from master
  • Loading branch information
elpaso committed Apr 5, 2019
1 parent 260e9ad commit c1cec89
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 13 deletions.
16 changes: 13 additions & 3 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -3182,9 +3182,18 @@ namespace QgsWms
QStringList _result;
if ( mLayerGroups.contains( name ) )
{
for ( const auto &l : mLayerGroups[ name ] )
const auto &layers { mLayerGroups[ name ] };
for ( const auto &l : layers )
{
_result.append( findLeaves( l->shortName().isEmpty() ? l->name() : l->shortName() ) );
const auto nick { layerNickname( *l ) };
if ( mLayerGroups.contains( nick ) )
{
_result.append( name );
}
else
{
_result.append( findLeaves( nick ) );
}
}
}
else
Expand All @@ -3193,7 +3202,8 @@ namespace QgsWms
}
return _result;
};
for ( const auto &name : mWmsParameters.queryLayersNickname() )
const auto constNicks { mWmsParameters.queryLayersNickname() };
for ( const auto &name : constNicks )
{
result.append( findLeaves( name ) );
}
Expand Down
18 changes: 8 additions & 10 deletions tests/testdata/qgis_server/getprojectsettings.txt
@@ -1,7 +1,6 @@
Response:
*****

Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="utf-8"?>
<WMS_Capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:qgs="http://www.qgis.org/wms" xmlns="http://www.opengis.net/wms" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd https://www.qgis.org/?*****" version="1.3.0" xmlns:sld="http://www.opengis.net/sld">
<Service>
Expand Down Expand Up @@ -132,7 +131,7 @@ Content-Type: text/xml; charset=utf-8
<southBoundLatitude>44.9012</southBoundLatitude>
<northBoundLatitude>44.9016</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60604e+6" maxx="913283" miny="5.60599e+6" CRS="EPSG:3857" minx="913171"/>
<BoundingBox maxy="5.60604e+06" maxx="913283" miny="5.60599e+06" CRS="EPSG:3857" minx="913171"/>
<BoundingBox maxy="8.20416" maxx="44.9016" miny="8.20315" CRS="EPSG:4326" minx="44.9012"/>
<Name>QGIS Test Project</Name>
<KeywordList>
Expand All @@ -152,7 +151,7 @@ Content-Type: text/xml; charset=utf-8
<southBoundLatitude>44.9014</southBoundLatitude>
<northBoundLatitude>44.9015</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60603e+6" maxx="913215" miny="5.60601e+6" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="5.60603e+06" maxx="913215" miny="5.60601e+06" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="8.20355" maxx="44.9015" miny="8.20346" CRS="EPSG:4326" minx="44.9014"/>
<Style>
<Name>default</Name>
Expand Down Expand Up @@ -182,7 +181,7 @@ Content-Type: text/xml; charset=utf-8
<southBoundLatitude>44.9014</southBoundLatitude>
<northBoundLatitude>44.9015</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60603e+6" maxx="913215" miny="5.60601e+6" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="5.60603e+06" maxx="913215" miny="5.60601e+06" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="8.20355" maxx="44.9015" miny="8.20346" CRS="EPSG:4326" minx="44.9014"/>
<Style>
<Name>default</Name>
Expand Down Expand Up @@ -212,7 +211,7 @@ Content-Type: text/xml; charset=utf-8
<southBoundLatitude>44.9014</southBoundLatitude>
<northBoundLatitude>44.9015</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60603e+6" maxx="913215" miny="5.60601e+6" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="5.60603e+06" maxx="913215" miny="5.60601e+06" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="8.20355" maxx="44.9015" miny="8.20346" CRS="EPSG:4326" minx="44.9014"/>
<TreeName>groupwithshortname</TreeName>
<Layer geometryType="Point" queryable="1" displayField="id" visible="1">
Expand All @@ -227,7 +226,7 @@ Content-Type: text/xml; charset=utf-8
<southBoundLatitude>44.9014</southBoundLatitude>
<northBoundLatitude>44.9015</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60603e+6" maxx="913215" miny="5.60601e+6" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="5.60603e+06" maxx="913215" miny="5.60601e+06" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="8.20355" maxx="44.9015" miny="8.20346" CRS="EPSG:4326" minx="44.9014"/>
<Style>
<Name>default</Name>
Expand Down Expand Up @@ -257,7 +256,7 @@ Content-Type: text/xml; charset=utf-8
<southBoundLatitude>44.9014</southBoundLatitude>
<northBoundLatitude>44.9015</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60603e+6" maxx="913215" miny="5.60601e+6" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="5.60603e+06" maxx="913215" miny="5.60601e+06" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="8.20355" maxx="44.9015" miny="8.20346" CRS="EPSG:4326" minx="44.9014"/>
<TreeName>groupwithoutshortname</TreeName>
<Layer geometryType="Point" queryable="0" displayField="id" visible="1">
Expand All @@ -272,7 +271,7 @@ Content-Type: text/xml; charset=utf-8
<southBoundLatitude>44.9014</southBoundLatitude>
<northBoundLatitude>44.9015</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60603e+6" maxx="913215" miny="5.60601e+6" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="5.60603e+06" maxx="913215" miny="5.60601e+06" CRS="EPSG:3857" minx="913205"/>
<BoundingBox maxy="8.20355" maxx="44.9015" miny="8.20346" CRS="EPSG:4326" minx="44.9014"/>
<Style>
<Name>default</Name>
Expand All @@ -294,4 +293,3 @@ Content-Type: text/xml; charset=utf-8
<LayerDrawingOrder>testlayer3,testlayer2,testlayer èé,layer_with_short_name</LayerDrawingOrder>
</Capability>
</WMS_Capabilities>

@@ -0,0 +1,32 @@
*****
Content-Type: text/plain; charset=utf-8

GetFeatureInfo results

Layer 'as_symbols'

Layer 'as-areas-short-name'
Feature 18
fid = '18'
gid = '34'
datum = '2013-06-11'
bearbeiter = 'scholle-b'
veranstaltung = ''
beschriftung = ''
name = ''
flaechentyp = 'Schraffur'
farbe = '255 0 0'
schraff_width = '2'
schraff_width_prt = '6.00'
schraff_size = '10'
schraff_size_prt = '30.00'
schraff_winkel = '45'
umrissfarbe = '0 0 0'
umrisstyp = 'durchgezogen'
umrissstaerke = '1'
umrissstaerke_prt = '3.00'
umfang = '758.4703'
flaeche = '12879'
bemerkung = ''
last_change = '2013-06-11 10:03:45.52301+02'

@@ -0,0 +1,30 @@
*****
Content-Type: text/plain; charset=utf-8

GetFeatureInfo results

Layer 'as-areas-short-name'
Feature 18
fid = '18'
gid = '34'
datum = '2013-06-11'
bearbeiter = 'scholle-b'
veranstaltung = ''
beschriftung = ''
name = ''
flaechentyp = 'Schraffur'
farbe = '255 0 0'
schraff_width = '2'
schraff_width_prt = '6.00'
schraff_size = '10'
schraff_size_prt = '30.00'
schraff_winkel = '45'
umrissfarbe = '0 0 0'
umrisstyp = 'durchgezogen'
umrissstaerke = '1'
umrissstaerke_prt = '3.00'
umfang = '758.4703'
flaeche = '12879'
bemerkung = ''
last_change = '2013-06-11 10:03:45.52301+02'

0 comments on commit c1cec89

Please sign in to comment.