[PyQt] Crash in KMainWindow.saveProperties() [small sample C++/Python code provided]

Jim Bublitz jbublitz at nwinternet.com
Tue Aug 28 20:56:19 BST 2007


On Tuesday 28 August 2007 11:10, Adeodato Simó wrote:
> Hello.
>
> I'm getting the same backtrace as mentioned in [1]. Please find attached
> a minimal C++ example application that successfully saves its state, and
> a Python equivalent that crashes when logging out of KDE.
>
> Note that the crash is not related to using config, just providing an
> empty saveProperties() crahses as well.

It doesn't crash here (just running the simple app you attached), so I can't 
actually test a solution, but Simon Edwards ran into a similar problem with 
PyKDE4 and fixed it by globally declaring 'application' (from your example):

application = None

and then inside main(), adding:

global application

I think that should ensure that KApplication is the last object destroyed.

The other possibility is to construct the main window and KApplication in 
global space, after the "if __name__ == __main__" test, instead of putting 
them inside a function or class method. That seems to have fewer problems 
with exit crashes (but other things can cause them as well).

As has been noted, the crash probably has to do with the order in which 
objects are destroyed. PyKDE at one time tried to addressed this (probably 
with code stolen from PyQt) - it gets to be a problem as KDE/Qt change and 
possibly even as gcc/g++ changes it's exit code for C++. It also can cause 
problems with queryClose/queryExit methods in KApplication, and with session 
management.

Jim





More information about the PyQt mailing list