db manager: don't consider added layer w/o a dataProvider

(cherry picked from commit 28aa9ebdb75eb099b83a3596b3f3c5c6e5c6f591)
This commit is contained in:
Juergen E. Fischer 2016-08-30 11:13:52 +02:00
parent 46ea229049
commit a9464d7c94

View File

@ -78,7 +78,7 @@ class DBManagerPlugin:
self.dlg.close()
def onLayerWasAdded(self, aMapLayer):
if aMapLayer.dataProvider().name() in ['postgres', 'spatialite', 'oracle']:
if hasattr(aMapLayer, 'dataProvider') and aMapLayer.dataProvider().name() in ['postgres', 'spatialite', 'oracle']:
uri = QgsDataSourceUri(aMapLayer.source())
if re.search('^\(SELECT .+ FROM .+\)$', uri.table(), re.S):
self.iface.legendInterface().addLegendLayerActionForLayer(self.layerAction, aMapLayer)