mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Fix QgsProjectLayerGroupDialog with qgz project
Maybe also fix #20134 - crash when trying to set exluded layer in QGIS Server WMS capabilities I could not reproduce the crash but QgsProjectLayerGroupDialog was broken and it was probably the root of the crash.
This commit is contained in:
parent
a42bf80185
commit
6b917e09e1
@ -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 errorMesssage;
|
||||
int errorLine;
|
||||
if ( !projectDom.setContent( &projectFile, &errorMesssage, &errorLine ) )
|
||||
{
|
||||
QgsDebugMsg( QStringLiteral( "Error reading the project file %1 at line %2: %3" )
|
||||
.arg( projectFile.fileName() )
|
||||
.arg( errorLine )
|
||||
.arg( errorMesssage ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
mRootGroup->removeAllChildren();
|
||||
|
||||
QDomElement layerTreeElem = projectDom.documentElement().firstChildElement( QStringLiteral( "layer-tree-group" ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user