Please sign in to comment.
Fix map layer memory leak with bad layer handling
Long story: if the store contains a layer with the same ID it silently fails to add it to the store. This is the cause of leak in case client code calls store->addLayers() within the (iterative) process of fixing bad layers by patching the XML and re-reading it. The proposed solution is to check in QgsProject::addLayer() - which creates the layer object - if the newly created layer was already in the store and delete it at the end of the layer reading process if it was. Deleting the layer from within the store->addLayers is extremely dangerous, because the caller could keep a reference to the layer and use it.
- Loading branch information