Bug report #9578

QGIS Crashes when incorrect plot style for programmatically created composer

Added by Tim Sutton about 10 years ago. Updated almost 10 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Map Composer/Printing
Affected QGIS version:2.0.1 Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:invalid
Crashes QGIS or corrupts data:No Copied to github as #:18161

Description

This issue replaces #9562

We have been trying to track down the cause of a crash under windows. We use some code similar to this to load a template (can be pasted directly into the python console in QGIS).

from qgis.core import QgsComposition
from PyQt4 import QtCore, QtXml

path = 'c:/temp/test.qpt'
template_file = QtCore.QFile(path)
template_file.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text)
template_content = template_file.readAll()
template_file.close()
document = QtXml.QDomDocument()
document.setContent(template_content)

canvas = iface.mapCanvas()
renderer = canvas.mapRenderer()
composition = QgsComposition(renderer)
composition.setPlotStyle(QgsComposition.Print) # or preview   <--- will cause a crash
composition.setPrintResolution(300)
composition.setPrintAsRaster(True)
composition.loadFromTemplate(document)

composer = iface.createNewComposer()
composer.setComposition(composition)

It seems that we were erroneously using print plot style instead of preview when loading the template. After the composer is loaded at some point a crash will occur under windows if you interact with the canvas. One way to replicate this seems to be if you add another map to the layout and then zoom to full.

test.qpt - The Template (2.44 KB) Akbar Gumbira, 2014-02-16 11:59 PM

qgis-20140217-155605-3216-1640-d94c044.zip - Mini dump (3.43 MB) Akbar Gumbira, 2014-02-17 12:58 AM

History

#1 Updated by Tim Sutton about 10 years ago

  • Priority changed from High to Normal

#2 Updated by Akbar Gumbira about 10 years ago

Attached file is the template we used.

#3 Updated by Akbar Gumbira about 10 years ago

Attached is the minidump file

#4 Updated by Nyall Dawson almost 10 years ago

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

I can't reproduce this crash under master, but setting the plot style in this way isn't supported in any case. The composer will be basically unusable. Print and Postscript styles are only designed for outputting compositions, not working with them in a composer.

Also available in: Atom PDF