Skip to content
Permalink
Browse files

Datasource path are relatives in embedded qgs project

  • Loading branch information
pblottiere committed Jul 11, 2017
1 parent f155030 commit 8d1ee93800d660e95bb8f9d38fbe823249d86b49
Showing with 9 additions and 1 deletion.
  1. +7 −1 src/core/qgsproject.cpp
  2. +2 −0 src/core/qgsproject.h
@@ -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
@@ -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;
@@ -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();
@@ -1073,6 +1073,8 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera

QVariantMap mCustomVariables;

QString mPathResolverBaseName;

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

0 comments on commit 8d1ee93

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