Skip to content

Commit

Permalink
Merge pull request #8291 from elpaso/bugfix-20134-maybe
Browse files Browse the repository at this point in the history
Fix QgsProjectLayerGroupDialog with qgz project
  • Loading branch information
elpaso committed Oct 24, 2018
2 parents 8e4d5d5 + be92b21 commit 1ab7dec
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/app/qgsprojectlayergroupdialog.cpp
Expand Up @@ -168,38 +168,43 @@ void QgsProjectLayerGroupDialog::changeProjectFile()
return;
}

std::unique_ptr<QgsProjectArchive> archive;

QDomDocument projectDom;
if ( QgsZipUtils::isZipFile( mProjectFileWidget->filePath() ) )
{
QgsProjectArchive archive;

archive = qgis::make_unique<QgsProjectArchive>();

// unzip the archive
if ( !archive.unzip( mProjectFileWidget->filePath() ) )
if ( !archive->unzip( mProjectFileWidget->filePath() ) )
{
return;
}

// test if zip provides a .qgs file
if ( archive.projectFile().isEmpty() )
if ( archive->projectFile().isEmpty() )
{
return;
}

projectFile.setFileName( archive.projectFile() );
projectFile.setFileName( archive->projectFile() );
if ( !projectFile.exists() )
{
return;
}
}

if ( !projectDom.setContent( &projectFile ) )
QString errorMessage;
int errorLine;
if ( !projectDom.setContent( &projectFile, &errorMessage, &errorLine ) )
{
QgsDebugMsg( QStringLiteral( "Error reading the project file %1 at line %2: %3" )
.arg( projectFile.fileName() )
.arg( errorLine )
.arg( errorMessage ) );
return;
}




mRootGroup->removeAllChildren();

QDomElement layerTreeElem = projectDom.documentElement().firstChildElement( QStringLiteral( "layer-tree-group" ) );
Expand Down

0 comments on commit 1ab7dec

Please sign in to comment.