Skip to content

Commit 8d1ee93

Browse files
committedJul 31, 2017
Datasource path are relatives in embedded qgs project
1 parent f155030 commit 8d1ee93

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎src/core/qgsproject.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,8 @@ void QgsProject::dumpProperties() const
16501650
QgsPathResolver QgsProject::pathResolver() const
16511651
{
16521652
bool absolutePaths = readBoolEntry( QStringLiteral( "Paths" ), QStringLiteral( "/Absolute" ), false );
1653-
return QgsPathResolver( absolutePaths ? QString() : fileName() );
1653+
QString baseName = mPathResolverBaseName.isEmpty() ? fileName() : mPathResolverBaseName;
1654+
return QgsPathResolver( absolutePaths ? QString() : baseName );
16541655
}
16551656

16561657
QString QgsProject::readPath( const QString &src ) const
@@ -2091,15 +2092,18 @@ bool QgsProject::unzip( const QString &filename )
20912092

20922093
// read the project file
20932094
mUnzipping = true;
2095+
mPathResolverBaseName = filename;
20942096
if ( ! read( archive->projectFile() ) )
20952097
{
2098+
mPathResolverBaseName = QString();
20962099
mUnzipping = false;
20972100
setError( tr( "Cannot read unzipped qgs project file" ) );
20982101
return false;
20992102
}
21002103

21012104
// keep the archive
21022105
mUnzipping = false;
2106+
mPathResolverBaseName = QString();
21032107
mArchive.reset( archive.release() );
21042108

21052109
return true;
@@ -2129,7 +2133,9 @@ bool QgsProject::zip( const QString &filename )
21292133
const QString originalFilename = mFile.fileName();
21302134
mFile.setFileName( qgsFile.fileName() );
21312135

2136+
mPathResolverBaseName = filename;
21322137
writeOk = write();
2138+
mPathResolverBaseName = QString();
21332139

21342140
mFile.setFileName( originalFilename );
21352141
qgsFile.close();

‎src/core/qgsproject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,8 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
10731073

10741074
QVariantMap mCustomVariables;
10751075

1076+
QString mPathResolverBaseName;
1077+
10761078
std::unique_ptr<QgsArchive> mArchive;
10771079
bool mUnzipping;
10781080

0 commit comments

Comments
 (0)
Please sign in to comment.