Opened 17 years ago
Closed 17 years ago
#775 closed defect (fixed)
CreateVectorLayer(), setDataProvider("ogr") segfault
Reported by: | crschmidt | Owned by: | wonder |
---|---|---|---|
Priority: | minor: annoyance | Milestone: | |
Component: | Data Provider | Version: | Trunk |
Keywords: | Cc: | ||
Must Fix for Release: | No | Platform: | OS X |
Platform Version: | OS X 10.4 | Awaiting user input: | no |
Description
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.
Change History (2)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in r7263.
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...
Note:
See TracTickets
for help on using tickets.
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