Skip to content

Commit 6b917e0

Browse files
committedOct 23, 2018
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.
1 parent a42bf80 commit 6b917e0

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed
 

‎src/app/qgsprojectlayergroupdialog.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,38 +168,43 @@ void QgsProjectLayerGroupDialog::changeProjectFile()
168168
return;
169169
}
170170

171+
std::unique_ptr<QgsProjectArchive> archive;
172+
171173
QDomDocument projectDom;
172174
if ( QgsZipUtils::isZipFile( mProjectFileWidget->filePath() ) )
173175
{
174-
QgsProjectArchive archive;
176+
177+
archive = qgis::make_unique<QgsProjectArchive>();
175178

176179
// unzip the archive
177-
if ( !archive.unzip( mProjectFileWidget->filePath() ) )
180+
if ( !archive->unzip( mProjectFileWidget->filePath() ) )
178181
{
179182
return;
180183
}
181184

182185
// test if zip provides a .qgs file
183-
if ( archive.projectFile().isEmpty() )
186+
if ( archive->projectFile().isEmpty() )
184187
{
185188
return;
186189
}
187190

188-
projectFile.setFileName( archive.projectFile() );
191+
projectFile.setFileName( archive->projectFile() );
189192
if ( !projectFile.exists() )
190193
{
191194
return;
192195
}
193196
}
194-
195-
if ( !projectDom.setContent( &projectFile ) )
197+
QString errorMesssage;
198+
int errorLine;
199+
if ( !projectDom.setContent( &projectFile, &errorMesssage, &errorLine ) )
196200
{
201+
QgsDebugMsg( QStringLiteral( "Error reading the project file %1 at line %2: %3" )
202+
.arg( projectFile.fileName() )
203+
.arg( errorLine )
204+
.arg( errorMesssage ) );
197205
return;
198206
}
199207

200-
201-
202-
203208
mRootGroup->removeAllChildren();
204209

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

0 commit comments

Comments
 (0)
Please sign in to comment.