Bug report #3286

Qgis segfaults instanciating QgsComposition from python

Added by Alessandro Pasotti almost 14 years ago. Updated almost 14 years ago.

Status:Closed
Priority:Low
Assignee:Marco Hugentobler
Category:Python plugins
Affected QGIS version: Regression?:No
Operating System:Linux Easy fix?:No
Pull Request or Patch supplied: Resolution:invalid
Crashes QGIS or corrupts data: Copied to github as #:13346

Description

crashes immediately after:

composition = core.QgsComposition(render)

Tested with trunk, 1.5 and 1.6

qgis_crash.py Magnifier - Test script (812 Bytes) Alessandro Pasotti, 2010-12-03 12:01 AM

qgis_crash.txt Magnifier - gdb bt (2.47 KB) Alessandro Pasotti, 2010-12-03 12:01 AM

History

#1 Updated by Marco Hugentobler almost 14 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

#2 Updated by Alessandro Pasotti almost 14 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.

#3 Updated by Martin Dobias almost 14 years ago

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

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

Also available in: Atom PDF