Is there an easy way to check if a layer created in pyqgis and addet to layers panel have been removed? I tried to use the layers = QgsProject.instance().mapLayersByName('my layer name'), but I don't nessesarely know the layer name, and if I use layer.name() after it hase been removed from layers panel, I get an error message.
Edit:
Error message: RuntimeError: wrapped C/C++ object of type QgsVectorLayer has been deleted
This message comes when i try to use any of the layer objects functions, but the layer is stil registerd as a QgsVectorLayer
This is for QGIS 2.18