[PyQt] Cleaning up when unloading embedded Python + PyQt

Paul A. Giannaros paul at giannaros.org
Thu Dec 18 15:21:49 GMT 2008

I have a plugin that is loaded and unloaded by a KDE-based application
on will. The plugin hosts Python and exposes the application's
interface to Python scripts.
I'm having a problem with a crash when unloading the plugin. From the
traceback[1] it looks like events are being routed to PyQt even though
I've successfully called Py_Finalize() and unloaded the Python

Is there a standard way to clean up PyQt? The Designer plugin doesn't
do any cleaning up, and I couldn't find any other examples to go on.


[1] Traceback:
Application: Kate (kate), signal SIGSEGV
[Thread debugging using libthread_db enabled]
[New Thread 0x7fc50e7fb700 (LWP 8090)]
[New Thread 0x41ecc950 (LWP 8091)]
[KCrash handler]
#5  0x00007fc501eed75d in PyThreadState_New ()
   from /usr/lib64/libpython2.5.so.1.0
#6  0x00007fc501eed7cc in PyGILState_Ensure ()
   from /usr/lib64/libpython2.5.so.1.0
#7  0x00007fc5017c0dbd in ?? ()
   from /usr/lib64/python2.5/site-packages/PyQt4/QtCore.so
#8  0x00007fc50a868f6d in QObject::event () from /usr/lib64/libQtCore.so.4
#9  0x00007fc50b30e17d in QApplicationPrivate::notify_helper ()
   from /usr/lib64/libQtGui.so.4
#10 0x00007fc50b315f2a in QApplication::notify () from /usr/lib64/libQtGui.so.4
#11 0x00007fc50c801d9b in KApplication::notify () from /usr/lib64/libkdeui.so.5
#12 0x00007fc50a859e81 in QCoreApplication::notifyInternal ()
   from /usr/lib64/libQtCore.so.4
#13 0x00007fc50a85ab3a in QCoreApplicationPrivate::sendPostedEvents ()
   from /usr/lib64/libQtCore.so.4
#14 0x00007fc50a882723 in ?? () from /usr/lib64/libQtCore.so.4
#15 0x00007fc50589393a in g_main_context_dispatch ()
   from /usr/lib64/libglib-2.0.so.0
#16 0x00007fc505897040 in ?? () from /usr/lib64/libglib-2.0.so.0
#17 0x00007fc5058971dc in g_main_context_iteration ()
   from /usr/lib64/libglib-2.0.so.0
#18 0x00007fc50a8823af in QEventDispatcherGlib::processEvents ()
   from /usr/lib64/libQtCore.so.4
#19 0x00007fc50b39eccf in ?? () from /usr/lib64/libQtGui.so.4
#20 0x00007fc50a858782 in QEventLoop::processEvents ()
   from /usr/lib64/libQtCore.so.4
#21 0x00007fc50a85890d in QEventLoop::exec () from /usr/lib64/libQtCore.so.4
#22 0x00007fc50a85adfd in QCoreApplication::exec ()
   from /usr/lib64/libQtCore.so.4
#23 0x00007fc50e419e9d in kdemain (argc=3, argv=0x7fff168386e8)
    at /usr/src/debug/kdesdk-4.1.3/kate/app/katemain.cpp:252
#24 0x00007fc506e83436 in __libc_start_main () from /lib64/libc.so.6
#25 0x00000000004008c9 in _start ()
#0  0x00007fc506f07261 in nanosleep () from /lib64/libc.so.6

More information about the PyQt mailing list