Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault on QgsMapCanvas() creation #22218

Closed
qgib opened this issue Feb 2, 2016 · 3 comments
Closed

Segfault on QgsMapCanvas() creation #22218

qgib opened this issue Feb 2, 2016 · 3 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption High Priority Plugins

Comments

@qgib
Copy link
Contributor

qgib commented Feb 2, 2016

Author Name: D. Hiepler (D. Hiepler)
Original Redmine Issue: 14217
Affected QGIS version: master
Redmine category:python_plugins


I modified the example code from http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/canvas.html#writing-custom-map-canvas-items
and ended up with

import sys
from qgis.core import QgsApplication, QgsProject
from qgis.gui import QgsMapCanvas

1. install prefix - optional, if QGIS_PREFIX_PATH is set
QgsApplication.setPrefixPath('/usr', True)  
1. where the auth database is - optional, if QGIS_AUTH_DB_DIR_PATH is set 
QgsApplication.setAuthDbDirPath('.')  

1. init application context
app = QgsApplication(sys.argv, False)
app.initQgis()

1. Map canvas
canvas = QgsMapCanvas()    # <- segfault
canvas.show()

app.exec_()

QgsApplication.exitQgis()

But with current master, it crashes (i suppose there's some Qt initialization missing):

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff2e9c88c in QCursor::pos() () from /usr/lib64/qt4/libQtGui.so.4
(gdb) bt
#_0  0x00007ffff2e9c88c in QCursor::pos() () from /usr/lib64/qt4/libQtGui.so.4
#_1  0x00007ffff2e2fd57 in QMouseEvent::QMouseEvent(QEvent::Type, QPoint const&, Qt::MouseButton, QFlags<Qt::MouseButton>, QFlags<Qt::KeyboardModifier>) () from /usr/lib64/qt4/libQtGui.so.4
#_2  0x00007ffff340bbaa in QGraphicsViewPrivate::QGraphicsViewPrivate() () from /usr/lib64/qt4/libQtGui.so.4
#_3  0x00007ffff340bedf in QGraphicsView::QGraphicsView(QWidget*) () from /usr/lib64/qt4/libQtGui.so.4
#_4  0x00007fffe328fa0b in QgsMapCanvas::QgsMapCanvas(QWidget*, char const*) () from /usr/lib64/libqgis_gui.so.2.13.0
#_5  0x00007fffe3c7ce63 in sipQgsMapCanvas::sipQgsMapCanvas(QWidget*, char const*) ()
   from /usr/lib64/python2.7/site-packages/qgis/_gui.so
#_6  0x00007fffe3c8addf in init_type_QgsMapCanvas () from /usr/lib64/python2.7/site-packages/qgis/_gui.so
#_7  0x00007ffff6684733 in sipSimpleWrapper_init () from /usr/lib64/python2.7/site-packages/sip.so
#_8  0x00007ffff7aae8ef in type_call () from /usr/lib64/libpython2.7.so.1.0
#_9  0x00007ffff7a5b533 in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#_10 0x00007ffff7aedb8a in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#_11 0x00007ffff7af0ac0 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#_12 0x00007ffff7af0bb9 in PyEval_EvalCode () from /usr/lib64/libpython2.7.so.1.0
#_13 0x00007ffff7b0961f in run_mod () from /usr/lib64/libpython2.7.so.1.0
#_14 0x00007ffff7b0a772 in PyRun_FileExFlags () from /usr/lib64/libpython2.7.so.1.0
#_15 0x00007ffff7b0b877 in PyRun_SimpleFileExFlags () from /usr/lib64/libpython2.7.so.1.0
#_16 0x00007ffff7b1c6da in Py_Main () from /usr/lib64/libpython2.7.so.1.0
#_17 0x00007ffff747a7b0 in __libc_start_main () from /lib64/libc.so.6
#_18 0x0000000000400759 in _start ()

@qgib
Copy link
Contributor Author

qgib commented Feb 2, 2016

Author Name: D. Hiepler (D. Hiepler)


PS: I forgot to mention, that I modified the example code to work around #21539

@qgib
Copy link
Contributor Author

qgib commented Feb 2, 2016

Author Name: Giovanni Manghi (@gioman)


  • fixed_version_id was configured as Future Release - High Priority
  • priority_id was changed from Normal to High

@qgib
Copy link
Contributor Author

qgib commented Jun 26, 2016

Author Name: Matthias Kuhn (@m-kuhn)


Make it a gui application and it will work:

app = QgsApplication(sys.argv, True)

  • resolution was changed from to invalid
  • status_id was changed from Open to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Plugins Crash/Data Corruption labels May 25, 2019
@qgib qgib added this to the Future Release - High Priority milestone May 25, 2019
@qgib qgib closed this as completed May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption High Priority Plugins
Projects
None yet
Development

No branches or pull requests

1 participant