Skip to content

Commit

Permalink
Use setFlags() in QgsMapLayer when reading style from xml
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Sep 11, 2018
1 parent b8197ed commit 4756f3e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/qgsmaplayer.cpp
Expand Up @@ -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 );
Expand All @@ -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
Expand Down

0 comments on commit 4756f3e

Please sign in to comment.