Skip to content

Commit

Permalink
Datasource path are relatives in embedded qgs project
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Jul 31, 2017
1 parent f155030 commit 8d1ee93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,8 @@ void QgsProject::dumpProperties() const
QgsPathResolver QgsProject::pathResolver() const
{
bool absolutePaths = readBoolEntry( QStringLiteral( "Paths" ), QStringLiteral( "/Absolute" ), false );
return QgsPathResolver( absolutePaths ? QString() : fileName() );
QString baseName = mPathResolverBaseName.isEmpty() ? fileName() : mPathResolverBaseName;
return QgsPathResolver( absolutePaths ? QString() : baseName );
}

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

// read the project file
mUnzipping = true;
mPathResolverBaseName = filename;
if ( ! read( archive->projectFile() ) )
{
mPathResolverBaseName = QString();
mUnzipping = false;
setError( tr( "Cannot read unzipped qgs project file" ) );
return false;
}

// keep the archive
mUnzipping = false;
mPathResolverBaseName = QString();
mArchive.reset( archive.release() );

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

mPathResolverBaseName = filename;
writeOk = write();
mPathResolverBaseName = QString();

mFile.setFileName( originalFilename );
qgsFile.close();
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,8 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera

QVariantMap mCustomVariables;

QString mPathResolverBaseName;

std::unique_ptr<QgsArchive> mArchive;
bool mUnzipping;

Expand Down

0 comments on commit 8d1ee93

Please sign in to comment.