Bug report #10482
QGIS master crashes when loading composer template
| Status: | Closed | ||
|---|---|---|---|
| Priority: | Severe/Regression | ||
| Assignee: | |||
| Category: | Map Composer/Printing | ||
| Affected QGIS version: | master | Regression?: | No |
| Operating System: | Linux | Easy fix?: | No |
| Pull Request or Patch supplied: | No | Resolution: | |
| Crashes QGIS or corrupts data: | No | Copied to github as #: | 18894 |
Description
On Master (8c513f9), when we try to load the template on attachment using this snippet below, QGIS will crash.
from PyQt4 import QtCore, QtXml
canvas = iface.mapCanvas()
renderer = canvas.mapRenderer()
composition = QgsComposition(renderer)
composer = iface.createNewComposer()
composer.setComposition(composition)
template_file = QtCore.QFile('/tmp/basic.qpt')
template_file.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text)
template_content = template_file.readAll()
template_file.close()
document = QtXml.QDomDocument()
document.setContent(template_content)
status_load = composition.loadFromTemplate(document)
Here is the backtrace of QGIS:
#2 0x000000000055f9b5 in qgisCrash (signal=-1) at /home/gumbia/dev/cpp/QGIS/src/app/main.cpp:303
#3 0x000000000055fb8c in myMessageOutput (type=QtFatalMsg, msg=0x7f1ff28 "ASSERT failure in QVector<T>::operator[]: \\"index out of range\\", file /usr/include/qt4/QtCore/qvector.h, line 355")
at /home/gumbia/dev/cpp/QGIS/src/app/main.cpp:356
#4 0x00007ffff34f93d0 in qt_message_output(QtMsgType, char const*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff34f9838 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#6 0x00007ffff34f99c4 in qFatal(char const*, ...) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#7 0x00000000005c5a07 in QVector<QgsFields::Field>::operator[] (this=0x68811d8, i=4) at /usr/include/qt4/QtCore/qvector.h:355
#8 0x00000000005accb8 in QgsFields::operator[] (this=0x68811d8, i=4) at /home/gumbia/dev/cpp/QGIS/src/app/../core/qgsfield.h:207
#9 0x00007ffff4bbfaaf in QgsComposerAttributeTable::setDisplayAttributes (this=0x7f197b0, attr=..., refresh=false) at /home/gumbia/dev/cpp/QGIS/src/core/composer/qgscomposerattributetable.cpp:279
#10 0x00007ffff4bc1eda in QgsComposerAttributeTable::readXML (this=0x7f197b0, itemElem=..., doc=...) at /home/gumbia/dev/cpp/QGIS/src/core/composer/qgscomposerattributetable.cpp:656
#11 0x00007ffff4bfd64d in QgsComposition::addItemsFromXML (this=0x8c79040, elem=..., doc=..., mapsToRestore=0x0, addUndoCommands=false, pos=0x0, pasteInPlace=false) at /home/gumbia/dev/cpp/QGIS/src/core/composer/qgscomposition.cpp:1103
#12 0x00007ffff4bfaa5f in QgsComposition::loadFromTemplate (this=0x8c79040, doc=..., substitutionMap=0x0, addUndoCommands=false) at /home/gumbia/dev/cpp/QGIS/src/core/composer/qgscomposition.cpp:803
#13 0x00007fff86187f2c in meth_QgsComposition_loadFromTemplate (sipSelf=0x6652560, sipArgs=0x5ad8850, sipKwds=0x0) at /home/gumbia/dev/cpp/QGIS/build/python/core/sip_corepart2.cpp:18504
It is OK in QGIS 2.2
Associated revisions
[composer] Check if attribute index is valid when reading attribute table fields from pre 2.4 projects (refs #10482)
History
#1
Updated by Tim Sutton over 11 years ago
- Assignee changed from Tim Sutton to Nyall Dawson
#2
Updated by Giovanni Manghi over 11 years ago
- Priority changed from Normal to Severe/Regression
- Target version set to Version 2.4
- Affected QGIS version changed from 2.2.0 to master
#3
Updated by Nyall Dawson over 11 years ago
I can't reproduce this, but I've pushed a potential fix. Can you please test and confirm? Thanks!
#4
Updated by Nyall Dawson over 11 years ago
- Status changed from Open to Feedback
#5
Updated by Akbar Gumbira over 11 years ago
Hi, I just tested against 6a17538 (as of today), it is fixed now. Sorry that I forgot to tell that this issue will raise if the legend contains layer that has different CRS with other layers..
#6
Updated by Akbar Gumbira over 11 years ago
- Status changed from Feedback to Closed
#7
Updated by Amandine Sahl about 11 years ago
- Status changed from Closed to Reopened
- Target version deleted (
Version 2.4)
I have the same problem.
The command composer.setComposition(composition) work with python script. But the same code inside a plugin make Qgis Crash.
I work with Qgis 2.4
#8
Updated by Nyall Dawson about 11 years ago
- Status changed from Reopened to Closed
Amandine - that's unlikely to be the same bug. Please open a new ticket and include a full python script which demonstrates this so that I can track it down.