Bug report #9578
QGIS Crashes when incorrect plot style for programmatically created composer
|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|
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.
#4 Updated by Nyall Dawson almost 6 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.