Skip to content
Permalink
Browse files

[BUGFIX] Embedded groups are empty

  • Loading branch information
pblottiere authored and wonder-sk committed Mar 12, 2017
1 parent 7293c05 commit d10d67728ab024c2ba3507514c1b7b99ab5129bf
@@ -876,14 +876,14 @@ bool QgsProject::read()
vl->resolveReferences( this );
}

// now that layers are loaded, we can resolve layer tree's references to the layers
mRootGroup->resolveReferences( this );

mLayerTreeRegistryBridge->setEnabled( true );

// load embedded groups and layers
loadEmbeddedNodes( mRootGroup );

// now that layers are loaded, we can resolve layer tree's references to the layers
mRootGroup->resolveReferences( this );

// make sure the are just valid layers
QgsLayerTreeUtils::removeInvalidLayers( mRootGroup );

@@ -158,6 +158,24 @@ def testReadEntry(self):
# invalid key
self.assertEqual(prj.readNumEntry("SpatialRefSys", "/InvalidKey", -1)[0], -1)

def testEmbeddedGroup(self):
testdata_path = unitTestDataPath('embedded_groups') + '/'

prj_path = os.path.join(testdata_path, "project2.qgs")
prj = QgsProject()
prj.read(prj_path)

layer_tree_group = prj.layerTreeRoot()
layers_ids = layer_tree_group.findLayerIds()

layers_names = []
for layer_id in layers_ids:
name = prj.mapLayer(layer_id).name()
layers_names.append(name)

expected = ['polys', 'lines']
self.assertEqual(sorted(layers_names), sorted(expected))


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

0 comments on commit d10d677

Please sign in to comment.
You can’t perform that action at this time.