[Qgis-developer] PyQGIS Segmentation fault when reading from Spatialite data source
Martin Dobias
wonder.sk at gmail.com
Sun May 1 07:22:56 PDT 2016
Hi Eric
On Sat, Apr 30, 2016 at 12:06 AM, Eric Goddard <egoddard1010 at gmail.com> wrote:
> Hello all,
>
> I'm working on a sync script for use with IntraMaps Roam for offline
> editing. My QGIS version is 2.14.1 (Tested on Fedora 23, Ubuntu 14.04,
> and Windows 7 x64). I'm using a standalone pyqgis script that creates
> the connection to the postgis data source and the spatialite
> datasource that roam uses locally. At this step I've just checked that
> each layer is valid, which they are, but after calling the exitQgis()
> method at the end of the script I get a segmentation fault. I think it
> is related to https://github.com/qgis/QGIS/pull/2944, but that
> specifically says for invalid layers.
>
> [...]
>
> sp_layer = QgsVectorLayer(sp_uri.uri(), "Disconnected Layer", "spatialite")
>
> print sp_layer.isValid() # Prints True
>
> qgs.exitQgis() # segfault :(
I think you need to delete "sp_layer" before calling exitQgis(). The
call to exitQgis() will invalidate the whole QGIS environment, so
later when sp_layer is auto-deleted by Python at the end of the
script, that will cause segfault. So simply try to add "del sp_layer"
line before exitQgis()
Cheers
Martin
More information about the Qgis-developer
mailing list