Navigation Menu

Skip to content

Commit

Permalink
layer definition: always use relative paths regardless whether or not…
Browse files Browse the repository at this point in the history
… the file already exists (fixes #14340)
  • Loading branch information
jef-n committed Feb 25, 2016
1 parent f9d6905 commit 9f7c329
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -5650,7 +5650,6 @@ void QgisApp::saveAsFile()

void QgisApp::saveAsLayerDefinition()
{

QString path = QFileDialog::getSaveFileName( this, "Save as Layer Definition File", QDir::home().path(), "*.qlr" );
QgsDebugMsg( path );
if ( path.isEmpty() )
Expand Down
22 changes: 11 additions & 11 deletions src/core/qgslayerdefinition.cpp
Expand Up @@ -151,22 +151,22 @@ bool QgsLayerDefinition::exportLayerDefinition( QString path, const QList<QgsLay
path = path.append( ".qlr" );

QFile file( path );
QFileInfo fileinfo( file );

QDomDocument doc( "qgis-layer-definition" );
if ( !exportLayerDefinition( doc, selectedTreeNodes, errorMessage, fileinfo.canonicalFilePath() ) )
return false;
if ( file.open( QFile::WriteOnly | QFile::Truncate ) )
{
QTextStream qlayerstream( &file );
doc.save( qlayerstream, 2 );
return true;
}
else
if ( !file.open( QFile::WriteOnly | QFile::Truncate ) )
{
errorMessage = file.errorString();
return false;
}

QFileInfo fileinfo( file );

QDomDocument doc( "qgis-layer-definition" );
if ( !exportLayerDefinition( doc, selectedTreeNodes, errorMessage, fileinfo.canonicalFilePath() ) )
return false;

QTextStream qlayerstream( &file );
doc.save( qlayerstream, 2 );
return true;
}

bool QgsLayerDefinition::exportLayerDefinition( QDomDocument doc, const QList<QgsLayerTreeNode*>& selectedTreeNodes, QString &errorMessage, const QString& relativeBasePath )
Expand Down

0 comments on commit 9f7c329

Please sign in to comment.