Bug report #21856
QGIS crashed while using QgsVectorFileWriter
| Status: | Closed | ||
|---|---|---|---|
| Priority: | High | ||
| Assignee: | |||
| Category: | Vectors | ||
| Affected QGIS version: | 3.7(master) | Regression?: | No |
| Operating System: | Easy fix?: | No | |
| Pull Request or Patch supplied: | Yes | Resolution: | fixed/implemented |
| Crashes QGIS or corrupts data: | No | Copied to github as #: | 29671 |
Description
QGIS consistently crashes when I run the following script in the Python console.
from qgis.core import (
QgsVectorLayer,
QgsField, QgsFields,
# QgsFeatureSource,
# QgsFeatureSink,
# QgsProject,
QgsWkbTypes,
QgsVectorFileWriter,
)
baseDir = "/Users/mitchell/Dropbox/python/import_gpx"
gpxFile = f"{baseDir}/../gps/Waypoints_01-MAR-18.gpx"
sourceLayer = QgsVectorLayer(gpxFile, "testFile", "GPX")
error, errormsg = QgsVectorFileWriter.writeAsVectorFormat(
layer=sourceLayer,
fileName="test.gpkg",
fileEncoding="utf-8",
destCRS=QgsCoordinateReferenceSystem('EPSG:4326'),
driverName="GPKG",
)
if error:
print(f"{error} --- {errormsg}")
I have attached the crash report.
Associated revisions
Guard vector file writer against invalid layers
instead of crashing.
Fixes #21856
Funded by: QCooperative.net
Guard vector file writer against invalid layers
instead of crashing.
Fixes #21856
Funded by: QCooperative.net
Guard vector file writer against invalid layers
instead of crashing.
Fixes #21856
Funded by: QCooperative.net
Guard vector file writer against invalid layers
instead of crashing.
Fixes #21856
Funded by: QCooperative.net
Guard vector file writer against invalid layers
instead of crashing.
Fixes #21856
Funded by: QCooperative.net
History
#1
Updated by Giovanni Manghi over 6 years ago
- Priority changed from Normal to High
#2
Updated by Alessandro Pasotti over 6 years ago
- Operating System deleted (
mac osx mohave (10.14.4)) - Affected QGIS version changed from 3.6.1 to 3.7(master)
- Assignee set to Alessandro Pasotti
- Status changed from Open to In Progress
- Category changed from Python bindings / sipify to Vectors
- Crashes QGIS or corrupts data changed from Yes to No
This is wrong and will produce an invalid layer (there is not "GPX" provider, use "ogr" instead):
sourceLayer = QgsVectorLayer(gpxFile, "testFile", "GPX")
btw, a crash is not nice.
#3
Updated by Alessandro Pasotti over 6 years ago
- Resolution set to fixed/implemented
- Pull Request or Patch supplied changed from No to Yes
#4
Updated by Alessandro Pasotti over 6 years ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
Applied in changeset qgis|e8a7d0e979057e055efd6bf023bf076c2721a3cd.
