Skip to content
Permalink
Browse files

back to a more safe const method

  • Loading branch information
luipir committed Feb 12, 2019
1 parent ee18eb5 commit a5866dfa208001037dd2702ecb3fef5601251e2a
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/core/qgsmaplayer.cpp
@@ -1470,9 +1470,11 @@ void QgsMapLayer::exportSldStyle( QDomDocument &doc, QString &errorMsg ) const

QString QgsMapLayer::saveSldStyle( const QString &uri, bool &resultFlag ) const
{
const QgsMapLayer *mlayer = qobject_cast<const QgsMapLayer *>( this );

QString errorMsg;
QDomDocument myDocument;
exportSldStyle( myDocument, errorMsg );
mlayer->exportSldStyle( myDocument, errorMsg );
if ( !errorMsg.isNull() )
{
resultFlag = false;
@@ -1481,17 +1483,17 @@ QString QgsMapLayer::saveSldStyle( const QString &uri, bool &resultFlag ) const
// check if the uri is a file or ends with .sld,
// which indicates that it should become one
QString filename;
if ( providerType() == QLatin1String( "ogr" ) )
if ( mlayer->providerType() == QLatin1String( "ogr" ) )
{
QStringList theURIParts = uri.split( '|' );
filename = theURIParts[0];
}
else if ( providerType() == QLatin1String( "gpx" ) )
else if ( mlayer->providerType() == QLatin1String( "gpx" ) )
{
QStringList theURIParts = uri.split( '?' );
filename = theURIParts[0];
}
else if ( providerType() == QLatin1String( "delimitedtext" ) )
else if ( mlayer->providerType() == QLatin1String( "delimitedtext" ) )
{
filename = QUrl::fromEncoded( uri.toLatin1() ).toLocalFile();
// toLocalFile() returns an empty string if theURI is a plain Windows-path, e.g. "C:/style.qml"

0 comments on commit a5866df

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