I have noticed in the QGIS source code that the map layers gets added in two different places, in the Canvas and in the registry as follow:

    QgsMapLayerRegistry::instance()->addMapLayers(theMapLayers, TRUE);

    //! Create the Map Canvas
    m_pMapCanvas = new QgsMapCanvas(0, 0);
    // Set the Map Canvas Layer Set

It seems like two separate copies of the map layers is being added to two different places, is there is away to make this more efficient?

1 Answer 1


There's no inefficiency here. They are only c++ pointers to the same layer instance -- it's not two instances in separate memory of the same map layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.