Skip to content

Commit 9f7c329

Browse files
committed
layer definition: always use relative paths regardless whether or not the file already exists (fixes #14340)
1 parent f9d6905 commit 9f7c329

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/app/qgisapp.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5650,7 +5650,6 @@ void QgisApp::saveAsFile()
56505650

56515651
void QgisApp::saveAsLayerDefinition()
56525652
{
5653-
56545653
QString path = QFileDialog::getSaveFileName( this, "Save as Layer Definition File", QDir::home().path(), "*.qlr" );
56555654
QgsDebugMsg( path );
56565655
if ( path.isEmpty() )

src/core/qgslayerdefinition.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,22 @@ bool QgsLayerDefinition::exportLayerDefinition( QString path, const QList<QgsLay
151151
path = path.append( ".qlr" );
152152

153153
QFile file( path );
154-
QFileInfo fileinfo( file );
155154

156-
QDomDocument doc( "qgis-layer-definition" );
157-
if ( !exportLayerDefinition( doc, selectedTreeNodes, errorMessage, fileinfo.canonicalFilePath() ) )
158-
return false;
159-
if ( file.open( QFile::WriteOnly | QFile::Truncate ) )
160-
{
161-
QTextStream qlayerstream( &file );
162-
doc.save( qlayerstream, 2 );
163-
return true;
164-
}
165-
else
155+
if ( !file.open( QFile::WriteOnly | QFile::Truncate ) )
166156
{
167157
errorMessage = file.errorString();
168158
return false;
169159
}
160+
161+
QFileInfo fileinfo( file );
162+
163+
QDomDocument doc( "qgis-layer-definition" );
164+
if ( !exportLayerDefinition( doc, selectedTreeNodes, errorMessage, fileinfo.canonicalFilePath() ) )
165+
return false;
166+
167+
QTextStream qlayerstream( &file );
168+
doc.save( qlayerstream, 2 );
169+
return true;
170170
}
171171

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

0 commit comments

Comments
 (0)