Bug report #12743

SegFault on adding composer map on a composition

Added by Evan GAROT--ADRIAN almost 9 years ago. Updated almost 9 years ago.

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

Description

I've a segfault on adding a QgsComposerMap to a QgsComposition

Code (last line):

template_document = QtXml.QDomDocument()
template_document.setContent(QtCore.QFile(Printer.printing_template_file_path), False)
composition = QgsComposition(QgsMapSettings())
composition.loadFromTemplate(template_document)
composer_map = QgsComposerMap(composition, 0, 0, composition.paperWidth(), composition.paperHeight())
composer_map.setLayerSet(printable_layers)
composer_map.setNewExtent(QgsMapLayerRegistry.instance().mapLayer(printable_layers[0]).extent())
composition.addComposerMap(composer_map)

Trace:

src/core/qgsscalecalculator.cpp: 42: (setMapUnits) [12948ms] Map units set to 2
src/core/symbology-ng/qgssymbollayerv2utils.cpp: 2606: (parseProperties) [503ms] unknown tag effect
src/core/composer/qgscomposerlegend.cpp: 147: (adjustBoxSize) [66ms] width = 57.7 height = 19.1
src/providers/ogr/qgsogrprovider.cpp: 877: (extent) [1134ms] Starting get extent
src/providers/ogr/qgsogrprovider.cpp: 915: (extent) [0ms] Finished get extent
src/core/qgsvectorlayer.cpp: 846: (extent) [0ms] Extent of layer: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsscalecalculator.cpp: 42: (setMapUnits) [702ms] Map units set to 2
src/core/qgsscalecalculator.cpp: 131: (calculateGeographicDistance) [0ms] Distance across map extent (m): 4.28394e+08
src/core/qgsscalecalculator.cpp: 88: (calculate) [0ms] scale = 5.45161e+09 conversionFactor = 39.3701
src/core/qgsmapsettings.cpp: 186: (updateDerived) [0ms] Map units per pixel (x,y) : 19.08961896062191599, 19.16476592283273561
src/core/qgsmapsettings.cpp: 187: (updateDerived) [0ms] Pixmap dimensions (x,y) : 297, 194
src/core/qgsmapsettings.cpp: 188: (updateDerived) [0ms] Extent dimensions (x,y) : 5669.61683130470919423, 3717.96458902955055237
src/core/qgsmapsettings.cpp: 189: (updateDerived) [0ms] 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 190: (updateDerived) [0ms] Adjusted map units per pixel (x,y) : 19.16476592283273916, 19.16476592283273561
src/core/qgsmapsettings.cpp: 191: (updateDerived) [0ms] Recalced pixmap dimensions (x,y) : 297.00000000000005684, 194
src/core/qgsmapsettings.cpp: 192: (updateDerived) [0ms] Scale (assuming meters as map units) = 1:5451608664.28005218505859375
src/core/qgsmapsettings.cpp: 193: (updateDerived) [0ms] Rotation: 0 degrees
src/core/qgsscalecalculator.cpp: 131: (calculateGeographicDistance) [0ms] Distance across map extent (m): 4.28394e+08
src/core/qgsscalecalculator.cpp: 88: (calculate) [0ms] scale = 1.41969e+09 conversionFactor = 39.3701
src/core/qgsmapsettings.cpp: 186: (updateDerived) [1ms] Map units per pixel (x,y) : 19.08961896062191599, 19.16476592283273561
src/core/qgsmapsettings.cpp: 187: (updateDerived) [0ms] Pixmap dimensions (x,y) : 297, 194
src/core/qgsmapsettings.cpp: 188: (updateDerived) [0ms] Extent dimensions (x,y) : 5669.61683130470919423, 3717.96458902955055237
src/core/qgsmapsettings.cpp: 189: (updateDerived) [0ms] 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 190: (updateDerived) [0ms] Adjusted map units per pixel (x,y) : 19.16476592283273916, 19.16476592283273561
src/core/qgsmapsettings.cpp: 191: (updateDerived) [0ms] Recalced pixmap dimensions (x,y) : 297.00000000000005684, 194
src/core/qgsmapsettings.cpp: 192: (updateDerived) [0ms] Scale (assuming meters as map units) = 1:1419689756.32293009757995605
src/core/qgsmapsettings.cpp: 193: (updateDerived) [0ms] Rotation: 0 degrees
src/core/qgsscalecalculator.cpp: 42: (setMapUnits) [0ms] Map units set to 0
src/core/qgsscalecalculator.cpp: 88: (calculate) [0ms] scale = 18863 conversionFactor = 39.3701
src/core/qgsmapsettings.cpp: 186: (updateDerived) [0ms] Map units per pixel (x,y) : 19.08961896062191599, 19.16476592283273561
src/core/qgsmapsettings.cpp: 187: (updateDerived) [0ms] Pixmap dimensions (x,y) : 297, 194
src/core/qgsmapsettings.cpp: 188: (updateDerived) [0ms] Extent dimensions (x,y) : 5669.61683130470919423, 3717.96458902955055237
src/core/qgsmapsettings.cpp: 189: (updateDerived) [1ms] 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 190: (updateDerived) [0ms] Adjusted map units per pixel (x,y) : 19.16476592283273916, 19.16476592283273561
src/core/qgsmapsettings.cpp: 191: (updateDerived) [0ms] Recalced pixmap dimensions (x,y) : 297.00000000000005684, 194
src/core/qgsmapsettings.cpp: 192: (updateDerived) [0ms] Scale (assuming meters as map units) = 1:18862.95856622507562861
src/core/qgsmapsettings.cpp: 193: (updateDerived) [0ms] Rotation: 0 degrees
Erreur de segmentation

Version de QGIS 2.9.0-Master
Révision du code 06180fe
Compilé avec Qt 4.8.6
Utilisant Qt 4.8.6
Compilé avec GDAL/OGR 1.10.1
Utilisé avec GDAL/OGR 1.10.1
Compilé avec GEOS 3.4.2-CAPI-1.8.2
Utilisé avec GEOS 3.4.2-CAPI-1.8.2 r3921
Version du client PostgreSQL 9.4.1
Version de SpatiaLite 4.1.1
Version de QWT 6.0.0-svn
Version de PROJ.4 : 480
Version de QScintilla2 2.8.4
Cette copie de QGIS dispose d'une sortie de débogage.

History

#1 Updated by Nyall Dawson almost 9 years ago

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

This line:

composition = QgsComposition(QgsMapSettings())

Creates a temporary QgsMapSettings which immediately goes out of scope and is deleted.

You need to keep a reference to it for as long as the composition exists:

ms=QgsMapSettings()
composition = QgsComposition(ms)

That will fix the crash.

#2 Updated by Evan GAROT--ADRIAN almost 9 years ago

  • % Done changed from 0 to 100

Hi Nyall.

Im really sorry because i found this solution, i test it and that don't work the first time. That's why i open this issue here. But i retest it just now to be sure and it works. Maybe i needed to get out of my problem and my rude journey...

Really thanks for your fast answer.
I hope this post will not be useless and help someone later.

Best regards.
Axiiom

Also available in: Atom PDF