Skip to content
Permalink
Browse files

Let the test for presence of root element be the first step.

  • Loading branch information
SebDieBln committed Nov 21, 2015
1 parent efeacaa commit ef4b5ead5a367d03e447ec005e085ffc08df7912
Showing with 8 additions and 10 deletions.
  1. +8 −10 src/core/qgsmaplayer.cpp
@@ -1147,8 +1147,15 @@ QString QgsMapLayer::loadNamedStyle( const QString &theURI, bool &theResultFlag

bool QgsMapLayer::importNamedStyle( QDomDocument& myDocument, QString& myErrorMessage )
{
QDomElement myRoot = myDocument.firstChildElement( "qgis" );
if ( myRoot.isNull() )
{
myErrorMessage = tr( "Root <qgis> element could not be found" );
return false;
}

// get style file version string, if any
QgsProjectVersion fileVersion( myDocument.firstChildElement( "qgis" ).attribute( "version" ) );
QgsProjectVersion fileVersion( myRoot.attribute( "version" ) );
QgsProjectVersion thisVersion( QGis::QGIS_VERSION );

if ( thisVersion > fileVersion )
@@ -1164,15 +1171,6 @@ bool QgsMapLayer::importNamedStyle( QDomDocument& myDocument, QString& myErrorMe
// styleFile.dump();
}

// now get the layer node out and pass it over to the layer
// to deserialise...
QDomElement myRoot = myDocument.firstChildElement( "qgis" );
if ( myRoot.isNull() )
{
myErrorMessage = tr( "Root <qgis> element could not be found" );
return false;
}

//Test for matching geometry type on vector layers when applying, if geometry type is given in the style
if ( type() == QgsMapLayer::VectorLayer && !myRoot.firstChildElement( "layerGeometryType" ).isNull() )
{

0 comments on commit ef4b5ea

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