Bug report #16761

QGIS randomly crashing when writing vector from Oracle sdo layer

Added by Jean-Louis Stanus about 3 years ago. Updated over 2 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Data Provider/Oracle
Affected QGIS version:2.18.9 Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:invalid
Crashes QGIS or corrupts data:Yes Copied to github as #:24660

Description

I made an uri instance and
Adding a vector layer from SDO to a QGIS project instance is working well.

@uri = QgsDataSourceURI()
uri.setConnection("svdbocsva003.XXXXX.lan", "1521", "POPO_RO", "USER", "pWD")
uri.setSrid ('31370');
uri.setWkbType(QGis.WKBMultiPolygon)
uri.setDataSource("OSIRIS", "OSI_SITES" , "SHAPE", b1query ,"OBJECTID")
uri.uri()
sdoLayer = QgsVectorLayer(uri.uri(), "requete", 'oracle')

sdoLayer.setCrs(QgsCoordinateReferenceSystem(31370))
QgsMapLayerRegistry.instance().addMapLayer(sdoLayer)
sdoFeatures = sdoLayer.getFeatures()
That works without any problem to this step.
But the following step is generating an empty layer:
Try 1:
@error = QgsVectorFileWriter.writeAsVectorFormat(sdoLayer, "C:\\9_Q_GIS\\4_Analyses\\Test\\requete\\test.shp", 'utf-8',QgsCoordinateReferenceSystem(31370), "ESRI Shapefile", False ,"erreur!!")
if error == QgsVectorFileWriter.NoError:
print "success!"
else :
print "error"
del error

Try 2 . The following step is crashing randomly if not generating empty table or sometimes a feature with fielf FID:

writer = QgsVectorFileWriter("C:\\Test\\requete\\test0.shp",'utf-8', fields, QGis.WKBMultiPolygon, QgsCoordinateReferenceSystem(31370), "ESRI Shapefile")
for attr in attributes :
print(attr[0])
exp = QgsExpression('ID_WS = {}' .format(attr[0]))
request = QgsFeatureRequest(exp)
request.setLimit(1)
#print(sdoLayer.getFeatures(request).next().geometry().isGeosValid())
feat = QgsFeature()
feat.setGeometry(sdoLayer.getFeatures(request).next().geometry())
print()
#feat.setAttributes([1, "text","toto"])
writer.addFeature(feat)
del writer

Thanks for help

History

#1 Updated by Giovanni Manghi about 3 years ago

  • Priority changed from Normal to High

#3 Updated by Jürgen Fischer about 3 years ago

  • Assignee deleted (Jürgen Fischer)

#4 Updated by Nyall Dawson over 2 years ago

  • Resolution set to invalid
  • Status changed from Open to Closed

Answers were provided on stackexchange

Also available in: Atom PDF