Skip to content

Commit 1f9c378

Browse files
committed
Fix #8727
1 parent 5c307b7 commit 1f9c378

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/mapserver/qgsprojectparser.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -1543,9 +1543,7 @@ void QgsProjectParser::addLayerProjectSettings( QDomElement& layerElem, QDomDocu
15431543
{
15441544
QgsVectorLayer* vLayer = static_cast<QgsVectorLayer*>( currentLayer );
15451545
const QSet<QString>& excludedAttributes = vLayer->excludeAttributesWMS();
1546-
1547-
//displayfield
1548-
layerElem.setAttribute( "displayField", vLayer->displayField() );
1546+
QString displayField = vLayer->displayField();
15491547

15501548
//attributes
15511549
QDomElement attributesElem = doc.createElement( "Attributes" );
@@ -1557,6 +1555,11 @@ void QgsProjectParser::addLayerProjectSettings( QDomElement& layerElem, QDomDocu
15571555
{
15581556
continue;
15591557
}
1558+
// field alias in case of displayField
1559+
if ( field.name() == displayField )
1560+
{
1561+
displayField = vLayer->attributeDisplayName( idx );
1562+
}
15601563
QDomElement attributeElem = doc.createElement( "Attribute" );
15611564
attributeElem.setAttribute( "name", vLayer->attributeDisplayName( idx ) );
15621565
attributeElem.setAttribute( "type", QVariant::typeToName( field.type() ) );
@@ -1569,6 +1572,8 @@ void QgsProjectParser::addLayerProjectSettings( QDomElement& layerElem, QDomDocu
15691572
attributeElem.setAttribute( "precision", field.precision() );
15701573
attributesElem.appendChild( attributeElem );
15711574
}
1575+
//displayfield
1576+
layerElem.setAttribute( "displayField", displayField );
15721577
layerElem.appendChild( attributesElem );
15731578
}
15741579
}

0 commit comments

Comments
 (0)