[PyQt] Exit crash after creating QGraphicsViews

Luke Campagnola lcampagn at email.unc.edu
Fri Apr 26 14:50:50 BST 2013

I am getting an error at exit for the following example:

from PyQt4 import QtGui
app = QtGui.QApplication([])
v1 = QtGui.QGraphicsView()
s1 = QtGui.QGraphicsScene()
v2 = QtGui.QGraphicsView()
s2 = QtGui.QGraphicsScene()

The error is this:

QPixmap: Must construct a QApplication before a QPaintDevice
Program received signal SIGABRT, Aborted.

My interpretation is that, as python is cleaning up, it somehow calls
QApplication.quit() before destroying the graphicsview / scene objects. Is
there any way to ensure these things happen in the correct order?

Here is the backtrace:

0x00007ffff6f1a425 in __GI_raise (sig=<optimized out>) at
64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) backtr
#0  0x00007ffff6f1a425 in __GI_raise (sig=<optimized out>) at
#1  0x00007ffff6f1db8b in __GI_abort () at abort.c:91
#2  0x00007ffff48b04c2 in qt_message_output (msgType=msgType at entry=QtFatalMsg,
buf=0xca59b8 "QPixmap: Must construct a QApplication before a
QPaintDevice") at global/qglobal.cpp:2290
#3  0x00007ffff48b0838 in qt_message(QtMsgType, const char *, typedef
__va_list_tag __va_list_tag *) (msgType=msgType at entry=QtFatalMsg, msg=
    0x7ffff555d470 "QPixmap: Must construct a QApplication before a
QPaintDevice", ap=ap at entry=0x7fffffffd888) at global/qglobal.cpp:2336
#4  0x00007ffff48b09c4 in qFatal (msg=<optimized out>) at
#5  0x00007ffff4faf1de in qt_pixmap_thread_test () at image/qpixmap.cpp:102
#6  0x00007ffff4fb0751 in QPixmap::QPixmap (this=0xd01ba8) at
#7  0x00007fffea2991c6 in Oxygen::Helper::Helper(QByteArray const&) () from
#8  0x00007fffea52a5f0 in ?? () from /usr/lib/kde4/plugins/styles/oxygen.so
#9  0x00007fffea511805 in ?? () from /usr/lib/kde4/plugins/styles/oxygen.so
#10 0x00007fffea528c5c in ?? () from /usr/lib/kde4/plugins/styles/oxygen.so
#11 0x00007ffff51d2c66 in QStyleFactory::create (key=...) at
#12 0x00007ffff4edf9f3 in QApplication::style () at
#13 0x00007ffff4f1b5c8 in QWidget::isActiveWindow (this=0xcd1770) at
#14 0x00007ffff54e921c in QGraphicsView::setScene (this=0xcd1770,
scene=0x0) at graphicsview/qgraphicsview.cpp:1621
#15 0x00007ffff54c1081 in QGraphicsScene::~QGraphicsScene (this=0xd651d0,
__in_chrg=<optimized out>) at graphicsview/qgraphicsscene.cpp:1653
#16 0x00007ffff5df2db9 in sipQGraphicsScene::~sipQGraphicsScene
(this=0xd651d0, __in_chrg=<optimized out>) at sipQtGuipart6.cpp:23630
#17 0x00007ffff5de2e96 in release_QGraphicsScene (sipCppV=0xd651d0) at
#18 0x00007ffff1439044 in forgetObject (sw=sw at entry=0x7ffff7e515f0) at
#19 0x00007ffff143a939 in sipWrapper_dealloc (self=0x7ffff7e515f0) at
#20 0x000000000048aae0 in subtype_dealloc.25740 (self=<QGraphicsScene at
remote 0x7ffff7e515f0>) at ../Objects/typeobject.c:1026
#21 0x00000000004c9c47 in insertdict_by_entry.18488 (mp=mp at entry=0x8d6e30,
key=key at entry='s2', hash=hash at entry=14720088435132841, ep=<optimized out>,
value=<optimized out>)
    at ../Objects/dictobject.c:519
#22 0x00000000004a10c0 in insertdict (value=None, hash=14720088435132841,
key='s2', mp=0x8d6e30) at ../Objects/dictobject.c:556
#23 dict_set_item_by_hash_or_entry (value=None, ep=0x0,
hash=14720088435132841, key='s2', op=
    {'QtGui': None, 'save_history': None, 'v1': None, '__builtins__':
<module at remote 0x7ffff7f8bad0>, 'rlcompleter': None, 'app': None,
'historyPath': None, '__package__': None, 'atexit': None, 'v2': None, 's2':
None, '__name__': '__main__', 'readline': <module at remote
0x7ffff7ec3868>, 'os': <module at remote 0x7ffff7f52c90>, '__doc__': None,
's1': <QGraphicsScene at remote 0x7ffff7e514d0>}) at
#24 PyDict_SetItem (op=
    {'QtGui': None, 'save_history': None, 'v1': None, '__builtins__':
<module at remote 0x7ffff7f8bad0>, 'rlcompleter': None, 'app': None,
'historyPath': None, '__package__': None, 'atexit': None, 'v2': None, 's2':
None, '__name__': '__main__', 'readline': <module at remote
0x7ffff7ec3868>, 'os': <module at remote 0x7ffff7f52c90>, '__doc__': None,
's1': <QGraphicsScene at remote 0x7ffff7e514d0>}, key='s2', value=None) at
#25 0x00000000004a1337 in _PyModule_Clear (m=<optimized out>) at
#26 0x00000000004e5b54 in PyImport_Cleanup () at ../Python/import.c:473
#27 0x0000000000434429 in Py_Finalize () at ../Python/pythonrun.c:454
#28 0x000000000044b74d in Py_Main (argc=<optimized out>,
argv=0x7fffffffe068) at ../Modules/main.c:664
#29 0x00007ffff6f0576d in __libc_start_main (main=0x44b77b <main>, argc=1,
ubp_av=0x7fffffffe068, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=
    0x7fffffffe058) at libc-start.c:226
#30 0x00000000004ce0ad in _start ()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130426/8af9e700/attachment.html>

More information about the PyQt mailing list