Opened 13 years ago

Closed 13 years ago

#3286 closed bug (invalid)

Qgis segfaults instanciating QgsComposition from python

Reported by: elpaso Owned by: mhugent
Priority: critical: causes crash or data corruption Milestone: Version 1.7.0
Component: Python plugins and bindings Version: Trunk
Keywords: QgsComposition Cc: cavallini@…
Must Fix for Release: No Platform: Linux
Platform Version: ubuntu lucid 64bit Awaiting user input: no

Description

crashes immediately after:

composition = core.QgsComposition(render)

Tested with trunk, 1.5 and 1.6

Attachments (2)

qgis_crash.py (812 bytes ) - added by elpaso 13 years ago.
Test script
qgis_crash.txt (2.5 KB ) - added by elpaso 13 years ago.
gdb bt

Download all attachments as: .zip

Change History (6)

by elpaso, 13 years ago

Attachment: qgis_crash.py added

Test script

by elpaso, 13 years ago

Attachment: qgis_crash.txt added

gdb bt

comment:1 by mhugent, 13 years ago

Owner: changed from borysiasty to mhugent

comment:2 by mhugent, 13 years ago

Hm, it does not crash for me here when repeating the steps. Could you try to replace line 30 in qgscomposition.sip with the following:

QgsComposition( QgsMapRenderer* mapRenderer /TransferThis/ );

Then please recompile QGIS, repeat your script and report back if it fixed the crash

comment:3 by elpaso, 13 years ago

Hi, I tested your patch but it still crashes. BTW I suspect it's a bug in QT and I found a way to make it work, it seems like QGraphicsScene (from which QgsComposition inherits, needs a QApplication instance, so this line needs to be added before the call to QgsComposition constructor.

app = QtGui.QApplication(sys.argv, QtGui.QApplication.Tty)

I thought having called QgsApplication.initQgis would have been enough to have a QApplication instance.

You can probably close this bug.

comment:4 by wonder, 13 years ago

Resolution: invalid
Status: newclosed

Indeed you have to construct a QApplication instance prior to doing any drawing. Closing the bug...

Note: See TracTickets for help on using tickets.