1

I'm currently writing a plugin in QGIS. Through an action, I want all the selected Features and a specific Layer to be be removed.

def deleteLayer(self):

    #remove Selection
    for layer in layerlist:
        if layer.type() == QgsMapLayer.VectorLayer:
            layer.removeSelection()

    #deletes Layer
    self.mapRegistry.removeMapLayer(self.layer)

Both sections work fine, if run while the other is commented out. Yet, the moment the code is like above it runs as it should... But I get this message from QGIS:

In German: Layer20171201140534272 :: Layer nicht registriert.

English_Translation: Layer20171201140534272 :: Layer is not registered.

Does anyone know what the message means and why it appears?

Edit: Maybe this additional code is important - layerlist does not include self.layer, because it was removed.

if self.layer in layerlist:
        layerlist.remove(self.layer)

And the message also appears when removeMapLayer() is given the layer.id().

1

Solution:

I delete the Layer first, then remove the Selection. I still do not know why the message appeared, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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