Bug report #812
QGIS crashes while loading PostGIS layer with insufficient permissions
|Affected QGIS version:||Regression?:||No|
|Operating System:||RedHat||Easy fix?:||No|
|Pull Request or Patch supplied:||Resolution:||fixed|
|Crashes QGIS or corrupts data:||Copied to github as #:||10871|
When you try to load a PostGIS Layer with insufficient permissions, a message box appears and after clicking OK QGIS crashes.
#1 Updated by Jürgen Fischer almost 13 years ago
- Status changed from Open to In Progress
Actually I get two dialogs, the first informs about the insufficient privileges on teh selected table (ie. permission denied on relation) and the second about the layer being invalid. But no crash.
Anything special to reproduce this?
#2 Updated by horst-duester - almost 13 years ago
OK you are right when you load the layer via standard PostGIS loader in GUI. I load the layer via Python Script with the following lines:
... snip uri = [[QgsDataSourceURI]]() uri.setConnection(hostname, port, dbname, username, "") uri.setDataSource(schema, table, geom_col, "") vlayer = [[QgsVectorLayer]](uri.text(), layerName, "postgres") canvas = self.iface.getMapCanvas() [[QgsMapLayerRegistry]].instance().addMapLayer(vlayer) snip ...
Try to load a layer with insufficient permissions. You will get a different message box (white with PostgreSQL error message). After click on OK QGIS crash.
#5 Updated by Martin Dobias almost 13 years ago
Well, this check is not really a workaround, it's the thing you have to do always when loading a layer. The problem here is that all the initialization happens in constructor and constructors can't return any value to tell you whether the initialization went fine, so you need to call isValid() to find it out. Once we will be free to do some bigger modification to QGIS API it's likely that this will be changed somehow.
However it's true that QGIS shouldn't crash even if you're trying to access invalid layer.