Bug report #11077

Segfault when using QgsComposition().exportAsPdf() in python

Added by Michael Douchin over 10 years ago. Updated almost 8 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Map Composer/Printing
Affected QGIS version:2.4.0 Regression?:No
Operating System:Ubuntu Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:Yes Copied to github as #:19410

Description

Since QGIS 2.4, the following steps crashes QGIS

  • Open QGIS
  • Open the python console and run :
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *

c = QgsComposition(QgsMapSettings())
c.setPaperSize(290, 210)
c.setPrintResolution(100)
c.setSnapGridOffsetX(3.5)
c.setSnapGridOffsetY(0)
c.setSnapGridResolution(2.5)
c.setNumPages(1)

cl = QgsComposerLabel(c)
cl.setItemPosition(0, 10, 100, 100)
content = 'test'
cl.setText(content)
cl.setFrameEnabled(False)
c.addItem(cl)

c.exportAsPDF('/tmp/a.pdf')

When running QGIs with gdb, I get

sudo gdb qgis.bin
[sudo] password for kimaidou: 
GNU gdb (Ubuntu 7.7-0ubuntu3.2) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying" 
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from qgis.bin...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/qgis.bin 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Warning: QGraphicsScene::addItem: item has already been added to this scene
[New Thread 0x7fffd2072700 (LWP 12621)]
[New Thread 0x7fff885af700 (LWP 12622)]
[New Thread 0x7fff878b3700 (LWP 12623)]
# EasyCustomLabeling debug trace: plugin loaded at 2014-08-19 18:41:32.264560
[New Thread 0x7fff636db700 (LWP 12632)]
[New Thread 0x7fff62eda700 (LWP 12633)]
visible
[New Thread 0x7fff6156b700 (LWP 12635)]
[Thread 0x7fff62eda700 (LWP 12633) exited]
[Thread 0x7fff6156b700 (LWP 12635) exited]

Program received signal SIGSEGV, Segmentation fault.
0x000000000055b25a in QBasicAtomicInt::ref() ()
(gdb) 

By running QGIS without gdb, I get :

qgis
Warning: QGraphicsScene::addItem: item has already been added to this scene
# EasyCustomLabeling debug trace: plugin loaded at 2014-08-19 18:45:16.662509
visible
QGIS died on signal 11Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Opération non permise.
No thread selected
No stack.
gdb returned 0
Abandon (core dumped)

This bug did not occur with previous 2.X versions.

Associated revisions

Revision a188d14f
Added by Nyall Dawson almost 8 years ago

Remove map settings parameter from QgsComposition

Breaks the hard link between canvas and compositions!

Fix #11077

History

#1 Updated by Michael Douchin over 10 years ago

Running QGIS as root I get more information on console

sudo qgis
Warning: QGraphicsScene::addItem: item has already been added to this scene
# EasyCustomLabeling debug trace: plugin loaded at 2014-08-19 18:50:47.048904
visible
QGIS died on signal 11[New LWP 12763]
[New LWP 12762]
[New LWP 12752]
[New LWP 12751]
[New LWP 12750]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f6bea8d79e9 in __libc_waitpid (pid=12767, stat_loc=0x7fffe6b20f24, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
40    ../sysdeps/unix/sysv/linux/waitpid.c: Aucun fichier ou dossier de ce type.
[Current thread is 1 (Thread 0x7f6bf2736800 (LWP 12748))]
#0  0x00007f6bea8d79e9 in __libc_waitpid (pid=12767, stat_loc=0x7fffe6b20f24, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
        resultvar = 0
        oldtype = 0
#1  0x00000000005570d4 in qgisCrash(int) ()
No symbol table info available.
#2  <signal handler called>
No locals.
#3  0x000000000055b25a in QBasicAtomicInt::ref() ()
No symbol table info available.
#4  0x000000000055bc07 in QList<QString>::QList(QList<QString> const&) ()
No symbol table info available.
#5  0x000000000055b8db in QStringList::QStringList(QStringList const&) ()
No symbol table info available.
#6  0x00007f6bee921887 in QgsMapSettings::QgsMapSettings(QgsMapSettings const&) () from /usr/lib/libqgis_core.so.2.4.0
No symbol table info available.
#7  0x00007f6beea79184 in QgsPaperItem::paint(QPainter*, QStyleOptionGraphicsItem const*, QWidget*) () from /usr/lib/libqgis_core.so.2.4.0
No symbol table info available.
#8  0x00007f6bece6ede7 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#9  0x00007f6bece2dc52 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#10 0x00007f6beced892d in QGraphicsEffectSource::draw(QPainter*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#11 0x00007f6beea5f7ba in QgsComposerEffect::draw(QPainter*) () from /usr/lib/libqgis_core.so.2.4.0
No symbol table info available.
#12 0x00007f6bece6fb3e in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#13 0x00007f6bece70488 in QGraphicsScene::drawItems(QPainter*, int, QGraphicsItem**, QStyleOptionGraphicsItem const*, QWidget*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#14 0x00007f6b6cc229c5 in sipQgsComposition::drawItems(QPainter*, int, QGraphicsItem**, QStyleOptionGraphicsItem const*, QWidget*) () from /usr/lib/python2.7/dist-packages/qgis/_core.so
No symbol table info available.
#15 0x00007f6bece5e55c in QGraphicsScene::render(QPainter*, QRectF const&, QRectF const&, Qt::AspectRatioMode) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#16 0x00007f6beea90ea5 in QgsComposition::renderPage(QPainter*, int) () from /usr/lib/libqgis_core.so.2.4.0
No symbol table info available.
#17 0x00007f6beea90880 in QgsComposition::doPrint(QPrinter&, QPainter&) () from /usr/lib/libqgis_core.so.2.4.0
No symbol table info available.
#18 0x00007f6beea90971 in QgsComposition::print(QPrinter&) () from /usr/lib/libqgis_core.so.2.4.0
No symbol table info available.
#19 0x00007f6beea906a2 in QgsComposition::exportAsPDF(QString const&) () from /usr/lib/libqgis_core.so.2.4.0
No symbol table info available.
#20 0x00007f6b6cc319db in ?? () from /usr/lib/python2.7/dist-packages/qgis/_core.so
No symbol table info available.
#21 0x00007f6b6e56a0d4 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#22 0x00007f6b6e56c17d in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#23 0x00007f6b6e56c462 in PyEval_EvalCode () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#24 0x00007f6b6e56ab3e in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#25 0x00007f6b6e56c17d in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#26 0x00007f6b6e569dd8 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#27 0x00007f6b6e56c17d in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#28 0x00007f6b6e569dd8 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#29 0x00007f6b6e56a059 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#30 0x00007f6b6e56a059 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#31 0x00007f6b6e56c17d in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#32 0x00007f6b6e56c310 in ?? () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#33 0x00007f6b6e533e23 in PyObject_Call () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#34 0x00007f6b6e48730d in ?? () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#35 0x00007f6b6e533e23 in PyObject_Call () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#36 0x00007f6b6e4f2837 in PyEval_CallObjectWithKeywords () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
No symbol table info available.
#37 0x00007f6b6e1fc5a4 in ?? () from /usr/lib/python2.7/dist-packages/sip.so
No symbol table info available.
#38 0x00007f6b6d55aa99 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
No symbol table info available.
#39 0x00007f6b67b134fc in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/Qsci.so
No symbol table info available.
#40 0x00007f6bec8df3d4 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#41 0x00007f6becc80fce in QFrame::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#42 0x00007f6beccfd42b in QAbstractScrollArea::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#43 0x00007f6b675f5e22 in QsciScintilla::event(QEvent*) () from /usr/lib/libqscintilla2.so.11
No symbol table info available.
#44 0x00007f6b67b152eb in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/Qsci.so
No symbol table info available.
#45 0x00007f6bec88fe2c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#46 0x00007f6bec8976f1 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#47 0x00007f6bee84755f in QgsApplication::notify(QObject*, QEvent*) () from /usr/lib/libqgis_core.so.2.4.0
No symbol table info available.
#48 0x00007f6bed4f64dd in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
No symbol table info available.
#49 0x00007f6bec92eff7 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#50 0x00007f6bec92f399 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#51 0x00007f6bec9093f7 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#52 0x00007f6bec931b02 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#53 0x00007f6be86a5e04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#54 0x00007f6be86a6048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#55 0x00007f6be86a60ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#56 0x00007f6bed5237a1 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
No symbol table info available.
#57 0x00007f6bec931bb6 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
No symbol table info available.
#58 0x00007f6bed4f50af in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
No symbol table info available.
#59 0x00007f6bed4f53a5 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
No symbol table info available.
#60 0x00007f6bed4fab79 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
No symbol table info available.
#61 0x000000000055a14e in main ()
No symbol table info available.
gdb returned 0

#2 Updated by Michael Douchin over 10 years ago

  • % Done changed from 0 to 50
  • Target version changed from Future Release - High Priority to Future Release - Lower Priority
  • Priority changed from High to Normal

Nyall Dawson found a way around. By replacing

c = QgsComposition(QgsMapSettings())

by

ms=QgsMapSettings()
c=QgsComposition(ms)

QGIS 2.4 does not segfault anymore.

#3 Updated by Martin Dobias over 10 years ago

My comments on qgis-dev list:

I think this is really API problem rather than Python-specific issue.
The QgsComposition is designed in a way that it always had
QgsMapRenderer from map canvas accessible (now changed to
QgsMapSettings). Worst of all, it is supposed to be the same instance
as used by map canvas - so it keeps just reference/pointer to
QgsMapSettings/QgsMapRenderer. The QgsComposition should be fixed so
that it does not require QgsMapSettings/QgsMapRenderer - after all, it
does not make much sense, there may be several composer map items with
different configuration. Each QgsComposerMap should have its own
QgsMapSettings instance.

The root of the problem here is that the QgsMapSettings() will create
an instance and then destroy it - while QgsComposition just keeps
blindly using dead reference. /Transfer/ or other annotations will
IMHO not solve the problem. I would consider is as a known issue and
live with it until API is not fixed.

Btw. using "c = QgsComposition( QgsMapRenderer() )" is also wrong
because of the same reasons. If it worked, it was just luck :-)

#4 Updated by Giovanni Manghi about 10 years ago

  • Priority changed from Normal to High

#5 Updated by Evan GAROT--ADRIAN over 9 years ago

Hi men.

I think my problem is related...

map_settings = QgsMapSettings()
        map_settings.setLayers(printable_layers_ids)
        map_settings.setExtent(bigger_printable_layer.extent())

        composition = QgsComposition(map_settings)
        composition.loadFromTemplate(template_document)

        composer_map = QgsComposerMap(composition)#, 0, 0, composition.paperWidth(), composition.paperHeight())
        composer_map.setNewExtent(map_settings.fullExtent())

        composition.addComposerMap(composer_map)

        # add created map to composition layers list
        composition.refreshZList()

        # not working
        # composition.moveItemToBottom(composer_map)
        # must do that instead
        composition.setAllUnselected()
        composition.setSelectedItem(composer_map)
        composition.moveSelectedItemsToBottom()

        # must refresh
        composition.refreshZList()
        composition.refreshItems()

        # create image
        picture = QImage(QSize(800, 600), QImage.Format_ARGB32_Premultiplied)
        color = QColor(255, 255, 255)
        picture.fill(color.rgb())
        painter = QPainter()
        painter.begin(picture)
        painter.setRenderHint(QPainter.Antialiasing)
        composition.render(painter)
        painter.end()

        picture.save(printed_image_file_path, ".png","png")
src/core/qgsmessagelog.cpp: 45: (logMessage) [100ms] 2015-05-13T22:22:00 Qt[1] QSpiAccessible::accessibleEvent not handled:  "8008"  obj:  QObject(0x0)  " invalid interface!" 
src/gui/qgsmapcanvas.cpp: 410: (setLayerSet) [284ms] Layers changed to: clipped__414466_bike_amenities20150513222159914, clipped__414466_roads20150513222157030
src/gui/qgsmapcanvas.cpp: 446: (setLayerSet) [0ms] Layers have changed, refreshing
src/core/qgsmaprenderer.cpp: 1004: (setLayerSet) [0ms] Entering: clipped__414466_bike_amenities20150513222159914, clipped__414466_roads20150513222157030
src/core/qgsmaprenderer.cpp: 929: (updateFullExtent) [0ms] called.
src/core/qgsmaprenderer.cpp: 939: (updateFullExtent) [0ms] Layer count: 2
src/core/qgsmaprenderer.cpp: 949: (updateFullExtent) [0ms] Updating extent using clipped--414466-bike_amenities
src/providers/ogr/qgsogrprovider.cpp: 877: (extent) [0ms] Starting get extent
src/providers/ogr/qgsogrprovider.cpp: 915: (extent) [0ms] Finished get extent
src/core/qgsvectorlayer.cpp: 846: (extent) [0ms] Extent of layer: Empty
src/core/qgsmaprenderer.cpp: 950: (updateFullExtent) [0ms] Input extent: Empty
src/core/qgsmaprenderer.cpp: 949: (updateFullExtent) [0ms] Updating extent using clipped--414466-roads
src/core/qgsmaprenderer.cpp: 950: (updateFullExtent) [0ms] Input extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmaprenderer.cpp: 804: (layerExtentToOutputExtent) [0ms] proj extent = 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmaprenderer.cpp: 962: (updateFullExtent) [1ms] Output extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmaprenderer.cpp: 993: (updateFullExtent) [0ms] Full extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/gui/qgsmapcanvas.cpp: 638: (refresh) [0ms] CANVAS refresh scheduling
src/core/qgsmapsettings.cpp: 485: (fullExtent) [0ms] called.
src/core/qgsmapsettings.cpp: 496: (fullExtent) [0ms] Layer count: 2
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-bike_amenities
src/core/qgsmapsettings.cpp: 507: (fullExtent) [0ms] Input extent: Empty
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-roads
src/core/qgsmapsettings.cpp: 507: (fullExtent) [0ms] Input extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 366: (layerExtentToOutputExtent) [0ms] proj extent = 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 519: (fullExtent) [0ms] Output extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 550: (fullExtent) [0ms] Full extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/gui/qgsmapcanvas.cpp: 648: (refreshMap) [9ms] CANVAS refresh!
src/core/qgsmaprendererjob.cpp: 149: (prepareJobs) [1ms] CACHE VALID: 1
src/core/qgsmaprendererjob.cpp: 159: (prepareJobs) [0ms] Rendering at layer item clipped__414466_roads20150513222157030
src/core/qgsmaprendererjob.cpp: 175: (prepareJobs) [0ms] layer clipped--414466-roads:  minscale:0  maxscale:1e+08  scaledepvis:0  blendmode:0
src/core/qgsmaprendererjob.cpp: 159: (prepareJobs) [0ms] Rendering at layer item clipped__414466_bike_amenities20150513222159914
src/core/qgsmaprendererjob.cpp: 175: (prepareJobs) [0ms] layer clipped--414466-bike_amenities:  minscale:0  maxscale:1e+08  scaledepvis:0  blendmode:0
src/core/qgsvectorlayerrenderer.cpp: 87: (QgsVectorLayerRenderer) [1ms] rendering v2:
  SINGLE: LINE SYMBOL (1 layers) color 129,61,2,255
src/core/qgsmaprendererparalleljob.cpp: 65: (start) [0ms] QThreadPool max thread count is 2
src/core/qgsmaprendererparalleljob.cpp: 211: (renderLayerStatic) [1ms] [thread:0x435afd0] job 47b9e60 start
src/providers/ogr/qgsogrfeatureiterator.cpp: 83: (QgsOgrFeatureIterator) [1ms] [thread:0x435afd0] Setting spatial filter using POLYGON((166257.75441531 6235436.95629624, 166257.75441531 6239340.81911473, 179184.91692202 6239340.81911473, 179184.91692202 6235436.95629624, 166257.75441531 6235436.95629624))
src/core/qgsmaprendererparalleljob.cpp: 231: (renderLayerStatic) [0ms] [thread:0x435afd0] job 47b9e60 end [1 ms]
src/core/qgsmaprendererjob.cpp: 293: (cleanupJobs) [3ms] caching image for clipped__414466_bike_amenities20150513222159914
src/core/qgsmaprendererparalleljob.cpp: 172: (renderLayersFinished) [1ms] PARALLEL layers finished
src/core/qgsmaprenderercustompainterjob.cpp: 250: (drawLabeling) [0ms] [thread:0x435afd0] Draw labeling start
src/core/qgsvectorlayer.cpp: 338: (drawLabels) [0ms] [thread:0x435afd0] Starting draw of labels: clipped__414466_roads20150513222157030
src/core/qgsvectorlayer.cpp: 338: (drawLabels) [0ms] [thread:0x435afd0] Starting draw of labels: clipped__414466_bike_amenities20150513222159914
src/core/qgsmaprenderercustompainterjob.cpp: 268: (drawLabeling) [0ms] [thread:0x435afd0] Draw labeling took (seconds): 0
src/core/qgsmaprendererparalleljob.cpp: 192: (renderingFinished) [11ms] PARALLEL finished
src/gui/qgsmapcanvas.cpp: 689: (rendererJobFinished) [0ms] CANVAS finish! 1
src/core/qgsscalecalculator.cpp: 42: (setMapUnits) [97ms] Map units set to 2
src/core/symbology-ng/qgssymbollayerv2utils.cpp: 2606: (parseProperties) [3ms] unknown tag effect
src/core/composer/qgscomposerlegend.cpp: 147: (adjustBoxSize) [138ms] width = 74.4 height = 25.1
src/core/qgsmapsettings.cpp: 485: (fullExtent) [24ms] called.
src/core/qgsmapsettings.cpp: 496: (fullExtent) [0ms] Layer count: 2
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-roads
src/core/qgsmapsettings.cpp: 507: (fullExtent) [0ms] Input extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 366: (layerExtentToOutputExtent) [0ms] proj extent = 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 519: (fullExtent) [0ms] Output extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-bike_amenities
src/core/qgsmapsettings.cpp: 507: (fullExtent) [0ms] Input extent: Empty
src/core/qgsmapsettings.cpp: 550: (fullExtent) [0ms] Full extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/composer/qgscomposeritem.cpp: 162: (setSelected) [0ms] entered.
Erreur de segmentation

With after # create image :

        pdf_printer = QPrinter()
        pdf_printer.setOutputFormat(QPrinter.PdfFormat)
        pdf_printer.setOutputFileName(printed_image_file_path + ".pdf")
        pdf_printer.setPaperSize(QSizeF(composition.paperWidth(), composition.paperHeight()), QPrinter.Millimeter)
        pdf_printer.setFullPage(True)
        pdf_printer.setColorMode(QPrinter.Color)
        pdf_printer.setResolution(composition.printResolution())

        pdf_painter = QPainter()
        pdf_painter.begin(pdf_printer)
        paperRectMM = pdf_printer.pageRect(QPrinter.Millimeter)
        paperRectPixel = pdf_printer.pageRect(QPrinter.DevicePixel)
        composition.render(pdf_painter, paperRectPixel, paperRectMM)
        pdf_painter.end()
src/core/qgsmessagelog.cpp: 45: (logMessage) [27ms] 2015-05-13T22:28:42 Qt[1] QSpiAccessible::accessibleEvent not handled:  "8008"  obj:  QObject(0x0)  " invalid interface!" 
src/gui/qgsmapcanvas.cpp: 410: (setLayerSet) [74ms] Layers changed to: clipped__414466_bike_amenities20150513222842318, clipped__414466_roads20150513222839781
src/gui/qgsmapcanvas.cpp: 446: (setLayerSet) [1ms] Layers have changed, refreshing
src/core/qgsmaprenderer.cpp: 1004: (setLayerSet) [0ms] Entering: clipped__414466_bike_amenities20150513222842318, clipped__414466_roads20150513222839781
src/core/qgsmaprenderer.cpp: 929: (updateFullExtent) [0ms] called.
src/core/qgsmaprenderer.cpp: 939: (updateFullExtent) [0ms] Layer count: 2
src/core/qgsmaprenderer.cpp: 949: (updateFullExtent) [0ms] Updating extent using clipped--414466-bike_amenities
src/providers/ogr/qgsogrprovider.cpp: 877: (extent) [0ms] Starting get extent
src/providers/ogr/qgsogrprovider.cpp: 915: (extent) [0ms] Finished get extent
src/core/qgsvectorlayer.cpp: 846: (extent) [0ms] Extent of layer: Empty
src/core/qgsmaprenderer.cpp: 950: (updateFullExtent) [0ms] Input extent: Empty
src/core/qgsmaprenderer.cpp: 949: (updateFullExtent) [0ms] Updating extent using clipped--414466-roads
src/core/qgsmaprenderer.cpp: 950: (updateFullExtent) [0ms] Input extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmaprenderer.cpp: 804: (layerExtentToOutputExtent) [0ms] proj extent = 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmaprenderer.cpp: 962: (updateFullExtent) [0ms] Output extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmaprenderer.cpp: 993: (updateFullExtent) [0ms] Full extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/gui/qgsmapcanvas.cpp: 638: (refresh) [0ms] CANVAS refresh scheduling
src/core/qgsmapsettings.cpp: 485: (fullExtent) [0ms] called.
src/core/qgsmapsettings.cpp: 496: (fullExtent) [0ms] Layer count: 2
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-bike_amenities
src/core/qgsmapsettings.cpp: 507: (fullExtent) [0ms] Input extent: Empty
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-roads
src/core/qgsmapsettings.cpp: 507: (fullExtent) [1ms] Input extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 366: (layerExtentToOutputExtent) [0ms] proj extent = 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 519: (fullExtent) [0ms] Output extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 550: (fullExtent) [0ms] Full extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/gui/qgsmapcanvas.cpp: 648: (refreshMap) [17ms] CANVAS refresh!
src/core/qgsmaprendererjob.cpp: 149: (prepareJobs) [1ms] CACHE VALID: 1
src/core/qgsmaprendererjob.cpp: 159: (prepareJobs) [0ms] Rendering at layer item clipped__414466_roads20150513222839781
src/core/qgsmaprendererjob.cpp: 175: (prepareJobs) [0ms] layer clipped--414466-roads:  minscale:0  maxscale:1e+08  scaledepvis:0  blendmode:0
src/core/qgsmaprendererjob.cpp: 159: (prepareJobs) [0ms] Rendering at layer item clipped__414466_bike_amenities20150513222842318
src/core/qgsmaprendererjob.cpp: 175: (prepareJobs) [0ms] layer clipped--414466-bike_amenities:  minscale:0  maxscale:1e+08  scaledepvis:0  blendmode:0
src/core/qgsvectorlayerrenderer.cpp: 87: (QgsVectorLayerRenderer) [1ms] rendering v2:
  SINGLE: LINE SYMBOL (1 layers) color 129,61,2,255
src/core/qgsmaprendererparalleljob.cpp: 65: (start) [0ms] QThreadPool max thread count is 2
src/core/qgsmaprendererparalleljob.cpp: 211: (renderLayerStatic) [0ms] [thread:0x7f31ac014150] job 6d66d30 start
src/providers/ogr/qgsogrfeatureiterator.cpp: 83: (QgsOgrFeatureIterator) [2ms] [thread:0x7f31ac014150] Setting spatial filter using POLYGON((166257.75441531 6235436.95629624, 166257.75441531 6239340.81911473, 179184.91692202 6239340.81911473, 179184.91692202 6235436.95629624, 166257.75441531 6235436.95629624))
src/core/qgsmaprendererparalleljob.cpp: 231: (renderLayerStatic) [0ms] [thread:0x7f31ac014150] job 6d66d30 end [2 ms]
src/core/qgsmaprendererjob.cpp: 293: (cleanupJobs) [4ms] caching image for clipped__414466_bike_amenities20150513222842318
src/core/qgsmaprendererparalleljob.cpp: 172: (renderLayersFinished) [1ms] PARALLEL layers finished
src/core/qgsmaprenderercustompainterjob.cpp: 250: (drawLabeling) [0ms] [thread:0x7f31ac014150] Draw labeling start
src/core/qgsvectorlayer.cpp: 338: (drawLabels) [1ms] [thread:0x7f31ac014150] Starting draw of labels: clipped__414466_roads20150513222839781
src/core/qgsvectorlayer.cpp: 338: (drawLabels) [0ms] [thread:0x7f31ac014150] Starting draw of labels: clipped__414466_bike_amenities20150513222842318
src/core/qgsmaprenderercustompainterjob.cpp: 268: (drawLabeling) [0ms] [thread:0x7f31ac014150] Draw labeling took (seconds): 0
src/core/qgsmaprendererparalleljob.cpp: 192: (renderingFinished) [10ms] PARALLEL finished
src/gui/qgsmapcanvas.cpp: 689: (rendererJobFinished) [0ms] CANVAS finish! 1
src/core/qgsscalecalculator.cpp: 42: (setMapUnits) [32ms] Map units set to 2
src/core/symbology-ng/qgssymbollayerv2utils.cpp: 2606: (parseProperties) [2ms] unknown tag effect
src/core/composer/qgscomposerlegend.cpp: 147: (adjustBoxSize) [19ms] width = 74.4 height = 25.1
src/core/qgsmapsettings.cpp: 485: (fullExtent) [2ms] called.
src/core/qgsmapsettings.cpp: 496: (fullExtent) [0ms] Layer count: 2
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-bike_amenities
src/core/qgsmapsettings.cpp: 507: (fullExtent) [0ms] Input extent: Empty
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-roads
src/core/qgsmapsettings.cpp: 507: (fullExtent) [0ms] Input extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 366: (layerExtentToOutputExtent) [0ms] proj extent = 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 519: (fullExtent) [0ms] Output extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 550: (fullExtent) [0ms] Full extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/composer/qgscomposeritem.cpp: 162: (setSelected) [1ms] entered.
Erreur de segmentation

With after # create image:

        dpi = composition.printResolution()
        dpmm = dpi / 25.4
        width = int(dpmm * composition.paperWidth())
        height = int(dpmm * composition.paperHeight())

        printed_image = QImage(QSize(800, 600), QImage.Format_ARGB32_Premultiplied)
        printed_image.setDotsPerMeterX(dpmm * 1000)
        printed_image.setDotsPerMeterY(dpmm * 1000)
        printed_image.fill(QColor(255, 255, 255).rgb())

        painter = QPainter()
        painter.begin(printed_image)
        painter.setRenderHint(QPainter.Antialiasing)

        sourceArea = QRectF(0, 0, composition.paperWidth(), composition.paperHeight())
        targetArea = QRectF(0, 0, width, height)
        composition.render(painter, targetArea, sourceArea)
        painter.end()
        printed_image.save(printed_image_file_path + ".png", "png")
src/providers/ogr/qgsogrprovider.cpp: 877: (extent) [265ms] Starting get extent
src/providers/ogr/qgsogrprovider.cpp: 915: (extent) [0ms] Finished get extent
src/core/qgsvectorlayer.cpp: 846: (extent) [0ms] Extent of layer: Empty
src/core/qgsscalecalculator.cpp: 42: (setMapUnits) [5ms] Map units set to 2
src/core/symbology-ng/qgssymbollayerv2utils.cpp: 2606: (parseProperties) [2ms] unknown tag effect
src/core/composer/qgscomposerlegend.cpp: 147: (adjustBoxSize) [19ms] width = 74.4 height = 25.1
src/core/qgsmapsettings.cpp: 485: (fullExtent) [2ms] called.
src/core/qgsmapsettings.cpp: 496: (fullExtent) [0ms] Layer count: 2
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-bike_amenities
src/core/qgsmapsettings.cpp: 507: (fullExtent) [0ms] Input extent: Empty
src/core/qgsmapsettings.cpp: 506: (fullExtent) [0ms] Updating extent using clipped--414466-roads
src/core/qgsmapsettings.cpp: 507: (fullExtent) [0ms] Input extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 366: (layerExtentToOutputExtent) [0ms] proj extent = 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 519: (fullExtent) [0ms] Output extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/qgsmapsettings.cpp: 550: (fullExtent) [0ms] Full extent: 169886.5272530100774020,6235529.9054109705612063 : 175556.1440843147865962,6239247.8700000001117587
src/core/composer/qgscomposeritem.cpp: 162: (setSelected) [0ms] entered.
Erreur de segmentation

No problem with :

composition.exportAsPDF(printed_image_file_path + ".pdf")

Hope it's help.

#6 Updated by Nyall Dawson almost 8 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF