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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -168,38 +168,43 @@ void QgsProjectLayerGroupDialog::changeProjectFile()
return; return;
} }


std::unique_ptr<QgsProjectArchive> archive;

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


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


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


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

QString errorMessage;
if ( !projectDom.setContent( &projectFile ) ) 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; return;
} }





mRootGroup->removeAllChildren(); mRootGroup->removeAllChildren();


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

0 comments on commit 1ab7dec

Please sign in to comment.