Skip to content

Commit a059c36

Browse files
authoredNov 14, 2019
Merge pull request #32854 from nirvn/loadstylefix
Followup 64949d : fix failure to load provider-provided style
2 parents 852d6cd + 7cb9e04 commit a059c36

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed
 

‎src/core/qgsvectorlayer.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4677,20 +4677,26 @@ QString QgsVectorLayer::loadNamedStyle( const QString &theURI, bool &resultFlag,
46774677
{
46784678
QgsDataSourceUri dsUri( theURI );
46794679
QString returnMessage;
4680+
QString qml, errorMsg;
46804681
if ( !loadFromLocalDB && mDataProvider && mDataProvider->isSaveAndLoadStyleToDatabaseSupported() )
46814682
{
4682-
QString qml, errorMsg;
46834683
qml = QgsProviderRegistry::instance()->loadStyle( mProviderKey, mDataSource, errorMsg );
4684-
if ( !qml.isEmpty() )
4685-
{
4686-
QDomDocument myDocument( QStringLiteral( "qgis" ) );
4687-
myDocument.setContent( qml );
4688-
resultFlag = importNamedStyle( myDocument, errorMsg );
4689-
returnMessage = QObject::tr( "Loaded from Provider" );
4690-
}
46914684
}
4692-
returnMessage = QgsMapLayer::loadNamedStyle( theURI, resultFlag, categories );
4693-
emit styleLoaded( categories );
4685+
if ( !qml.isEmpty() )
4686+
{
4687+
QDomDocument myDocument( QStringLiteral( "qgis" ) );
4688+
myDocument.setContent( qml );
4689+
resultFlag = importNamedStyle( myDocument, errorMsg );
4690+
returnMessage = QObject::tr( "Loaded from Provider" );
4691+
}
4692+
else
4693+
{
4694+
returnMessage = QgsMapLayer::loadNamedStyle( theURI, resultFlag, categories );
4695+
}
4696+
4697+
if ( resultFlag )
4698+
emit styleLoaded( categories );
4699+
46944700
return returnMessage;
46954701
}
46964702

0 commit comments

Comments
 (0)
Please sign in to comment.