Bug report #11790

Python bindings for QgsDxfExport.addLayers causes crash

Added by Laurent debomy almost 10 years ago. Updated over 6 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Python plugins
Affected QGIS version:2.18.13 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:Yes Copied to github as #:20016

Description

I try to use QgsDxfExport from python but failed adding vector layers using addLayers method. I tried passing argument as a list of lists or a list of tuples, but both makes qgis crashes.

It seems like SIP doesn't like QList<QPair<QgsVectorLayer*,int>> argument type : help(QgsDxfExport) in python console reports "QgsDxfExport.addLayers(unknown-type)".

Because I don't know how to make SIP recognize this type as a python list of tuples, I simply add a "addLayer" method as :

void QgsDxfExport::addLayer( QgsVectorLayer *layer, int featureID ) {
mLayers.append(QPair< QgsVectorLayer *, int >(layer, featureID));
}

Using this method, I successfully exported in DXF from python.

Attached a patch for the 3 concerned files : QgsDxfExport.cpp, QgsDxfExport.h and QgsDxfExport.sip.

qgsdxfexport.patch Magnifier (1.54 KB) Laurent debomy, 2014-12-04 05:55 AM

Associated revisions

Revision c2baf1b9
Added by Denis Rouzaud over 6 years ago

[dxf] use struct instead of QPair for addLayers (#6323)

fix #11790

History

#1 Updated by Giovanni Manghi over 7 years ago

  • Crashes QGIS or corrupts data changed from No to Yes
  • Status changed from Open to Feedback
  • Priority changed from Normal to High
  • Target version deleted (Future Release - Nice to have)
  • Affected QGIS version changed from master to 2.4.0

Hi,
what is the status of this issue? Is the patch still necessary in the latest QGIS releases like 2.18.4 or was already submitted and committed?
I have to change the "affected version" tag because now master is used for qgis3/master, and as 2 years old issue this is likely to have affected master that then become 2.6 or something like that.

#2 Updated by Giovanni Manghi over 7 years ago

  • Status changed from Feedback to Open
  • Description updated (diff)

#3 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No
  • Regression? set to No

#4 Updated by Iain Lopata about 7 years ago

I can confirm that this is still an issue in 2.18.13

#5 Updated by Giovanni Manghi about 7 years ago

  • Affected QGIS version changed from 2.4.0 to 2.18.13

#6 Updated by Denis Rouzaud over 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

#7 Updated by Giovanni Manghi over 6 years ago

  • Resolution set to fixed/implemented

Also available in: Atom PDF