[PyKDE] destructor not getting called?

Fredrik Juhlin laz at strakt.com
Fri Nov 8 09:45:01 GMT 2002


On Fri, 2002-11-08 at 01:50, Kaleb Pederson wrote:
> I'm using a global QSettings object throughout my application.  For some 
> reason, when the program closes, the destructor on my QSettings object is not 
> getting called.  As it is the destructor that actually writes everything to 
> disk (in order to cache the data), none of my settings are getting saved. Can 
> I manually call it?  I'm pretty sure that this used to work on previous 
> PyQt/Qt versions.
The reason you're having problems is most likely because there is no
such thing as a destructor in Python. I assume that you, like many
before you, are treating the __del__() method as a destructor but the
reality is there is no guarantee that __del__() will be called on
program exit. The Python Language Reference recommends that you only use
__del__() methods to "do the absolute minimum needed to maintain
external invariants". See
http://www.python.org/doc/current/ref/customization.html for more
information.

//Fredrik





More information about the PyQt mailing list