Skip to content

Commit

Permalink
Fix reloading project with embedded layers from qgz
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Nov 18, 2019
1 parent e5eb23e commit 9a9778a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
7 changes: 0 additions & 7 deletions src/app/qgisapp.cpp
Expand Up @@ -11597,13 +11597,6 @@ void QgisApp::embedLayers()

QString projectFile = d.selectedProjectFile();

QgsProjectArchive archive;
if ( projectFile.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) )
{
archive.unzip( projectFile );
projectFile = archive.projectFile();
}

//groups
QStringList groups = d.selectedGroups();
QStringList::const_iterator groupIt = groups.constBegin();
Expand Down
10 changes: 9 additions & 1 deletion src/core/qgslayerdefinition.cpp
Expand Up @@ -442,8 +442,16 @@ QgsLayerDefinition::DependencySorter::DependencySorter( const QString &fileName
: mHasCycle( false )
, mHasMissingDependency( false )
{
QString qgsProjectFile = fileName;
QgsProjectArchive archive;
if ( fileName.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) )
{
archive.unzip( fileName );
qgsProjectFile = archive.projectFile();
}

QDomDocument doc;
QFile pFile( fileName );
QFile pFile( qgsProjectFile );
( void )pFile.open( QIODevice::ReadOnly );
( void )doc.setContent( &pFile );
init( doc );
Expand Down
10 changes: 9 additions & 1 deletion src/core/qgsproject.cpp
Expand Up @@ -2475,13 +2475,21 @@ bool QgsProject::createEmbeddedLayer( const QString &layerId, const QString &pro
static QDateTime sPrevProjectFileTimestamp;
static QDomDocument sProjectDocument;

QString qgsProjectFile = projectFilePath;
QgsProjectArchive archive;
if ( projectFilePath.endsWith( QLatin1String( ".qgz" ), Qt::CaseInsensitive ) )
{
archive.unzip( projectFilePath );
qgsProjectFile = archive.projectFile();
}

QDateTime projectFileTimestamp = QFileInfo( projectFilePath ).lastModified();

if ( projectFilePath != sPrevProjectFilePath || projectFileTimestamp != sPrevProjectFileTimestamp )
{
sPrevProjectFilePath.clear();

QFile projectFile( projectFilePath );
QFile projectFile( qgsProjectFile );
if ( !projectFile.open( QIODevice::ReadOnly ) )
{
return false;
Expand Down

0 comments on commit 9a9778a

Please sign in to comment.