[PyKDE] destructor not getting called?
Boudewijn Rempt
boud at valdyas.org
Fri Nov 8 08:48:00 GMT 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 08 November 2002 07:42, Kaleb Pederson wrote:
> On Thursday 07 November 2002 10:14 pm, Boudewijn Rempt wrote:
> >
> > It might be my Java heritage, but I've never trusted destructors...
> > Couldn't you just connect the LastWindowClosed signal to the save method?
> > Why I personally to is to write the settings whenever a main window is
> > closed, from the closeEvent.
>
> For efficiency reasons, QSettings caches all changes that are made using
> write[Num]Entry(...). The only time that it gets written to disk is when
> the destructor is called (which calls sync(), the method they have defined
> for writing to disk). The destructor is the only publicly accessible
> function for writing to disk.
>
Hmmm... What I do is to create a Python class with the settings as member
variables. That makes it easier. But still, the Qt documentation says:
A typical usage pattern for application exit or 'save preferences':
QSettings settings;
settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
// No search path needed for Unix; see notes further on.
settings.writeEntry( "/MyApplication/background color", bgColor );
settings.writeEntry( "/MyApplication/geometry/width", width );
// ...
So, depending on the destructor is not the only way to go.
- --
Boudewijn Rempt | http://www.valdyas.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9y2tCdaCcgCmN5d8RAllgAJwNaatvf8nJbMbqWf5mZCsFmaY66ACeP0EZ
y2q/UDQ3/SqQfyXFuPAVLX0=
=8GFE
-----END PGP SIGNATURE-----
More information about the PyQt
mailing list