QgsVectorLayer::writeSymbology(): fix crash when called with invalid data provider

This commit is contained in:
Even Rouault 2016-10-18 22:32:56 +02:00
parent a70d42802f
commit 9ae156970a

View File

@ -1947,7 +1947,14 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
mConditionalStyles->writeXml( node, doc );
// save expression fields
mExpressionFieldBuffer->writeXml( node, doc );
if ( !mExpressionFieldBuffer )
{
// can happen when saving style on a invalid layer
QgsExpressionFieldBuffer dummy;
dummy.writeXml( node, doc );
}
else
mExpressionFieldBuffer->writeXml( node, doc );
// save readonly state
node.toElement().setAttribute( QStringLiteral( "readOnly" ), mReadOnly );