#812 closed bug (fixed)
QGIS crashes while loading PostGIS layer with insufficient permissions
Reported by: | horst.duester | Owned by: | jef |
---|---|---|---|
Priority: | major: does not work as expected | Milestone: | |
Component: | Data Provider | Version: | Trunk |
Keywords: | Cc: | ||
Must Fix for Release: | Yes | Platform: | RedHat |
Platform Version: | Awaiting user input: | yes |
Description
When you try to load a PostGIS Layer with insufficient permissions, a message box appears and after clicking OK QGIS crashes.
Change History (7)
comment:1 by , 15 years ago
Awaiting user input: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 15 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.
comment:3 by , 15 years ago
After creating an instance of a layer, you must ensure that vector layer is loaded correctly - if not, further behaviour is undefined.
if not vlayer.isValid(): print "Couldn't load layer!"
comment:4 by , 15 years ago
wonder thank you for the workaround. Isn't it better to ensure the correct load of the layer at the provider?
comment:5 by , 15 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.
Martin
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?