Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateVectorLayer(), setDataProvider("ogr") segfault #10834

Closed
qgib opened this issue Oct 5, 2007 · 2 comments
Closed

CreateVectorLayer(), setDataProvider("ogr") segfault #10834

qgib opened this issue Oct 5, 2007 · 2 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers

Comments

@qgib
Copy link
Contributor

qgib commented Oct 5, 2007

Author Name: crschmidt - (crschmidt -)
Original Redmine Issue: 775

Redmine category:data_provider
Assignee: Martin Dobias


The following commands in the Python console will crash qgis:

import qgis.core as c
l = c.QgsVectorLayer()
l.setDataProvider("ogr")

Backtrace:


Thread 0 Crashed:
0   libstdc++.6.dylib   	0x90b2f9de std::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(char const*) + 20
1   org.gdal.gdal       	0x0250d7e9 OGRILI1DataSource::Open(char const*, int) + 105
2   org.gdal.gdal       	0x0250dc94 OGRILI1Driver::Open(char const*, int) + 60
3   org.gdal.gdal       	0x0248f325 OGRSFDriverRegistrar::Open(char const*, int, OGRSFDriver**) + 85
4   libogrprovider.so   	0x1c2920de [[QgsOgrProvider]]::QgsOgrProvider[in-charge](QString const&) + 1742
5   libogrprovider.so   	0x1c292495 classFactory + 37
6   libqgis_core.dylib  	0x01d45284 [[QgsProviderRegistry]]::getProvider(QString const&, QString const&) + 230
7   libqgis_core.dylib  	0x01d607ab [[QgsVectorLayer]]::setDataProvider(QString const&) + 89
8   core.so             	0x1db235f8 meth_QgsVectorLayer_setDataProvider + 156

The problem is presumably the null qstring provided as the second arg to getProvider, which should be a filename, but isn't.

@qgib
Copy link
Contributor Author

qgib commented Oct 6, 2007

Author Name: Martin Dobias (@wonder-sk)


Hi,

I can replicate the problem and I'll fix it later, however this is not the way how the layers should be instantiated. In fact setDataProvider() should be protected function. You can find here how to open layers:

http://wiki.qgis.org/qgiswiki/PythonBindings

Martin

@qgib
Copy link
Contributor Author

qgib commented Oct 11, 2007

Author Name: Martin Dobias (@wonder-sk)


Fixed in .

setDataProvider() is now private.

I guess your intent was to create a new layer here. It's stupid but there's no straightforward way to do it in QGIS. But it's possible to create an empty shapefile with [[QgsVectorFileWriter]] and then use it to construct a [[QgsVectorLayer]]...


  • resolution was changed from to fixed
  • status_id was changed from Open to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers labels May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers
Projects
None yet
Development

No branches or pull requests

1 participant