[PyKDE] destructor not getting called?

Boudewijn Rempt boud at valdyas.org
Fri Nov 8 15:47:01 GMT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 08 November 2002 15:38, you wrote:
>
> I agree that it shouldn't be the only way to go.  I would definitely
> prefer to have a function that I can call that would write to disk.  The
> source code reveals, however, that a sync() call is only done in the
> destructor.  

I've never had a problem with lost settings, so I guess the writeEntry
method does what it needs to. I've attached the complete guiconfig.py
class.

> In fact, I have almost exactly what you mentioned.  I have
> a class that wraps it and provides some convenience functions for me.  I
> added in some print statements so I *know* that settings.write[Num]Entry
> is getting called with all the correct values.
>
> I guess my main question is, therefore, if I have a reference to a PyQt
> object, in this case QSettings, and at the close of my program the
> destructor never gets called for the PyQt object, then there _must_ be a
> memory leak if any memory whatsoever is allocated by that PyQt object.
>

No, it doesn't have to be a memory leak. If the process ends, the OS
will reclaim all the memory. It can do that without calling destructors,
after all, the process doesn't run anymore.

> Under *nix, has anyone ever seen QSettings actually write to the
> settings file upon a write[Num]Entry?  I have monitored the file for
> existence upon a new write[Num]Entry and for changes upon a
> write[Num]Entry and None have ever been made until the object goes out
> of scope.

Maybe I was just lucky, and have the QSettings object call the destructor.
Anyway, it's one part of my application where I've never had problems.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9y82BdaCcgCmN5d8RAlO6AJ4mPmNnx0sT6p+6y3w6BdrqPFUL5ACgn0s8
Cg9cuwglgc+i09DfBu6KPzs=
=mH/R
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: guiconfig.py
Type: text/x-python
Size: 4999 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20021108/9805ff47/guiconfig.py


More information about the PyQt mailing list