Skip to content
Permalink
Browse files

Use setFlags() in QgsMapLayer when reading style from xml

  • Loading branch information
wonder-sk committed Sep 11, 2018
1 parent b8197ed commit 4756f3ed81aca9430b20a29be35e7c4d38a0d527
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/core/qgsmaplayer.cpp
@@ -406,6 +406,7 @@ bool QgsMapLayer::readLayerXml( const QDomElement &layerElement, QgsReadWriteCo
// flags
QDomElement flagsElem = layerElement.firstChildElement( QStringLiteral( "flags" ) );
QMetaEnum metaEnum = QMetaEnum::fromType<QgsMapLayer::LayerFlag>();
LayerFlags flags = mFlags;
for ( int idx = 0; idx < metaEnum.keyCount(); ++idx )
{
const char *enumKey = metaEnum.key( idx );
@@ -414,11 +415,12 @@ bool QgsMapLayer::readLayerXml( const QDomElement &layerElement, QgsReadWriteCo
continue;
bool flagValue = flagNode.toElement().text() == "1" ? true : false;
QgsMapLayer::LayerFlag enumValue = static_cast<QgsMapLayer::LayerFlag>( metaEnum.keyToValue( enumKey ) );
if ( mFlags.testFlag( enumValue ) && !flagValue )
mFlags &= ~enumValue;
else if ( !mFlags.testFlag( enumValue ) && flagValue )
mFlags |= enumValue;
if ( flags.testFlag( enumValue ) && !flagValue )
flags &= ~enumValue;
else if ( !flags.testFlag( enumValue ) && flagValue )
flags |= enumValue;
}
setFlags( flags );

return true;
} // bool QgsMapLayer::readLayerXML

0 comments on commit 4756f3e

Please sign in to comment.
You can’t perform that action at this time.