This is a discussion on Re: KDE shutdown does not wait till queryExit() returns true - KDE ; On Tuesday 21 February 2006 00:23, Sven Burmeister wrote: > Hello! > > I had a look at the docs because there were some problems with kvpnc > interrupting KDE shtting down. The problem was that closeEvent() was > re-implemented ...
On Tuesday 21 February 2006 00:23, Sven Burmeister wrote:
> I had a look at the docs because there were some problems with kvpnc
> interrupting KDE shtting down. The problem was that closeEvent() was
> re-implemented without any e->accept().
> I read that it is not recommended to re-implement closeEvent() but rather
> queryClose und queryExit. Further the docs say that if one has serious
> things to do, one should connect aboutToQuit to queryExit.
> I did all that. As a result, everything works as expected, if the window is
> open. However, if the application is only in tray KDE shuts down without
> waiting for queryExit to return true. The closeEvent does not seem to be
> called at all.
> My question is, whether this is expected behaviour, or whether KDE should
> wait until queryExit returns true.
KMainWindow::queryExit() is flawed, and you can read in the comment in
kmainwindow.h why I think that. Both queryClose() and queryExit() are meant
to be simpler API than closeEvent() and are both called from there. Which is
why queryExit() doesn't work for you, as there's no window to close and hence
> If it is expected behaviour, how can I make KDE wait on shutdown, if the
> application is only in the tray?
If you want to do something specific to a window, use queryClose() (or
closeEvent() for non-KMainWindow cases), and pay attention to
KApplication::sessionSaving() if you do something that could break logout. If
you want to do just a cleanup for the window, use a destructor of course.
If you want to do something when the app exits, use
QApplication::aboutToQuit() or simply a destructor again.
As for logout, there are two parts of the logout process: Session saving and
shutdown and they're independent. First ksmserver asks all apps to perform a
session save, which leads to calling of closeEvent() etc. , any app can
cancel the logout at this phase e.g. by returning false from queryClose().
After a successful save ksmserver tells all apps to quit, waits a short
moment and then shuts down KDE without asking anybody.
For session management, with KMainWindow you can use its saveProperties() and
queryClose(), again, pay attention to KApplication::sessionSaving() and keep
in mind that it's session save and not shutdown - don't do cleanup in
queryClose() or anything like that. If you don't have KMainWindow you can use
closeEvent() or KSessionManaged.
And to answer your question, I can't actually do that because I don't know
what you need (you know, people, it'd be much simpler to help you didn't just
say what you think you need but also mentioned why you need it).
If you want to do a cleanup at exit, use a dtor or aboutToQuit(). If you want
to display something like "shutting down KDE will cause XYZ", then a) first
consider if the user really needs to be told that, b) use
> KDE seems to only respect closeEvent(), yet that one seems to be not
> triggered when apps are only in tray.
Hmm, am I already boring to say again that hidding windows to the tray is a
SuSE CR, s.r.o. e-mail: email@example.com , firstname.lastname@example.org
Drahobejlova 27 tel: +420 2 9654 2373
190 00 Praha 9 fax: +420 2 9654 2374
Czech Republic http://www.suse.cz/
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<