Skip to content

Commit 49730ed

Browse files
committed
Archive has to be cleared when clear() is called
1 parent 92bad92 commit 49730ed

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/core/qgsproject.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,13 @@ void QgsProject::clear()
494494
mRootGroup->clear();
495495

496496
mLabelingEngineSettings->clear();
497+
498+
// unzip action use read() method to read the embedded qgs project file.
499+
// And read() clear everything in a first step. But we don't want to reset
500+
// the current archive while unzipping...
501+
if ( !mUnzipping )
502+
mArchive->clear();
503+
497504
emit labelingEngineSettingsChanged();
498505

499506
// reset some default project properties
@@ -765,9 +772,6 @@ bool QgsProject::read()
765772
{
766773
clearError();
767774

768-
if ( ! mUnzipping )
769-
mArchive->clear();
770-
771775
std::unique_ptr<QDomDocument> doc( new QDomDocument( QStringLiteral( "qgis" ) ) );
772776

773777
if ( !mFile.open( QIODevice::ReadOnly | QIODevice::Text ) )

tests/src/python/test_qgsproject.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,9 @@ def test_zip_unzip(self):
750750
self.assertTrue(layers[l0.id()].isValid(), True)
751751
self.assertTrue(layers[l1.id()].isValid(), True)
752752

753+
project2.clear()
754+
self.assertFalse(project2.unzipped())
755+
753756

754757
if __name__ == '__main__':
755758
unittest.main()

0 commit comments

Comments
 (0)