[PyKDE] destructor not getting called?

Greg Fortune lists at gregfortune.com
Fri Nov 8 10:36:01 GMT 2002


On Friday 08 November 2002 12:44 am, you wrote:
> 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

????  ack, where did you find information implying that __del__ might not get 
called on program exit?  From my understanding, __del__ just wouldn't be 
called until the reference count reaches 0 and the garbage collection cycle 
executes.  That, of course, should happen for every object at program exit... 
 If it doesn't, that would seem like a Python bug.

Greg


> __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
>
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.gmd.de
> http://mats.gmd.de/mailman/listinfo/pykde




More information about the PyQt mailing list