https://issues.qgis.org/https://issues.qgis.org/favicon.ico2007-11-16T07:41:57ZQGIS Issue TrackingQGIS Application - Bug report #812: QGIS crashes while loading PostGIS layer with insufficient permissionshttps://issues.qgis.org/issues/812?journal_id=158252007-11-16T07:41:57ZJürgen Fischerjef@norbit.de
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>In Progress</i></li></ul><p>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.</p>
<p>Anything special to reproduce this?</p> QGIS Application - Bug report #812: QGIS crashes while loading PostGIS layer with insufficient permissionshttps://issues.qgis.org/issues/812?journal_id=158262007-11-19T22:48:58Zhorst-duester -horst.duester@foo.bar
<ul></ul><p>OK you are right when you load the layer via standard <a class="wiki-page new" href="https://issues.qgis.org/projects/qgis/wiki/PostGIS">PostGIS</a> loader in GUI. I load the layer via Python Script with the following lines:</p>
<pre>
... 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 ...
</pre>
<p>Try to load a layer with insufficient permissions. You will get a different message box (white with <a class="wiki-page new" href="https://issues.qgis.org/projects/qgis/wiki/PostgreSQL">PostgreSQL</a> error message). After click on OK QGIS crash.</p> QGIS Application - Bug report #812: QGIS crashes while loading PostGIS layer with insufficient permissionshttps://issues.qgis.org/issues/812?journal_id=158272007-11-20T02:45:06ZMartin Dobiaswonder.sk@gmail.com
<ul></ul><p>After creating an instance of a layer, you must ensure that vector layer is loaded correctly - if not, further behaviour is undefined.</p>
<pre>
if not vlayer.isValid():
print "Couldn't load layer!"
</pre> QGIS Application - Bug report #812: QGIS crashes while loading PostGIS layer with insufficient permissionshttps://issues.qgis.org/issues/812?journal_id=158282007-11-20T04:19:36Zhorst-duester -horst.duester@foo.bar
<ul></ul><p>wonder thank you for the workaround. Isn't it better to ensure the correct load of the layer at the provider?</p> QGIS Application - Bug report #812: QGIS crashes while loading PostGIS layer with insufficient permissionshttps://issues.qgis.org/issues/812?journal_id=158292007-11-20T06:19:16ZMartin Dobiaswonder.sk@gmail.com
<ul></ul><p>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.</p>
<p>However it's true that QGIS shouldn't crash even if you're trying to access invalid layer.</p>
<p>Martin</p> QGIS Application - Bug report #812: QGIS crashes while loading PostGIS layer with insufficient permissionshttps://issues.qgis.org/issues/812?journal_id=158302007-11-20T07:32:44ZJürgen Fischerjef@norbit.de
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Closed</i></li><li><strong>Resolution</strong> set to <i>fixed</i></li></ul><p>fixed in <a class="changeset" href="https://issues.qgis.org/projects/qgis/repository/revisions/4dbc0bc5c7258cd5a7744bf0557729123faa4a2c" title="add only valid layers, fixes #812 git-svn-id: http://svn.osgeo.org/qgis/trunk@7624 c8812cc2-4d05...">4dbc0bc5</a> (SVN r7625)</p> QGIS Application - Bug report #812: QGIS crashes while loading PostGIS layer with insufficient permissionshttps://issues.qgis.org/issues/812?journal_id=158312009-08-21T22:52:53ZAnonymous
<ul></ul><p>Milestone Version 0.9.1 deleted</p>