Session restoration and autostart

Lubos Lunak l.lunak at suse.cz
Thu Sep 8 13:34:54 BST 2005


On Tuesday 06 of September 2005 02:58, David Jarvie wrote:
> On Monday 05 Sep 2005 11:29, Christian Esken wrote:
> > Am Montag, 5. September 2005 01:19 schrieb David Jarvie:
> > > On Friday 02 Sep 2005 12:09, Waldo Bastian wrote:
> > > > On Tuesday 30 August 2005 23:34, David Jarvie wrote:
> > > > > Currently, session restoration and autostart are not compatible for
> > > > > a KUniqueApplication, since there is no guarantee that the
> > > > > application
> >
> > will
> >
> > > > > be activated by session restoration before it is autostarted. If it
> > > > > is activated by session restoration after it has been autostarted,
> > > > > it cannot detect that it is supposed to restore the session.
> > > > >
> > > > > 1) Provide a means to guarantee that autostart will only occur once
> > > > > the application has been restored (if it actually is scheduled to
> > > > > be restored).
> > > > >
> > > > > This would allow the application to be configured to use both
> > > > > methods without having to take any special precautions.
> > > >
> > > > That's what we have the different autostart phases for already.
> > >
> > > Yes, I know - I was involved in implementing them. But unfortunately
> > > they don't (any longer) work. I use autostart phase 2 for kalarm, but
> > > it is often autostarted before session restoration. It happens to me on
> > > KDE 3.4.1/2, and others have reported it on KDE 3.4.0. My assumption in
> > > writing my last email was that the actual order in which program
> > > activations occur is not entirely predictable - that it can differ from
> > > the order in which the activations were
> > > initiated. If that assumption is wrong, then it may only be a bug which
> > > has been introduced in ksmserver for after KDE 3.3, rather than a
> > > design problem.

 I've already said it, and I will repeat it: Sessions and autostart are not 
meant to be used together. Use either one or the other one, not both. If you 
use sessions, just handle saving and restoring of the data, the system will 
take care of everything else. If you want to use autostart for some reason, 
take care of everything yourself. End of story. Why would you need both?

 If I'm not mistaken, you just use session saving for storing window 
positions. So either just use session saving (boy, do I hate all those "are 
you really really sure you don't want this app next time?" dialogs), or just 
use autostart if you want it that way for some reason and save the positions 
yourself.

> >
> > That is an interesting observation. Thanks for digging this up. This
> > could also be the reason for KMix showing up on the desktop of some users
> > on *every* Login. The bug https://bugs.kde.org/show_bug.cgi?id=58901
> > would then be triggered like this:
> >
> > - KMix Autostart : does not show KMix main window
> > - KMix Restore : The KUniqueApplication KMix sees, that an instance is
> > already running and explicitely calls show() to show its Main Window =>
> > Bug triggered .
>
> It seems very likely that this is the cause.
>
> > Possibly I could add an extra isRestored() check:
> > - if ( m_kmix )    /*there-is-an-instance-running*/
> > + if ( m_kmix && !isRestored() ) /*there-is-an-instance-running */
> > {
> >     m_kmix.show()
> > }
> >
> > But I don't know wheteher this will work.
>
> Unfortunately, this will not work, because if an application is initially
> started by autostart, isRestored() always returns false, even during the
> activation by the session manager.
>
> > I also believe this is only a
> > workaround, and that there is something low-level broken, because I got
> > very strange comments on workaround for the noted bug, e.g.: "I noticed
> > that it docks well when no netwrok connection is active"
>
> I have found that the behaviour is not consistent. Sometimes the fault
> occurs, other times it doesn't. I suspect that it may have something to do
> with system load at login (including the number of applications to be
> restored), but I'm not sure.

 Yes. Basically, first goes autostart phase 1, then session restoration, then 
autostart phase2. However application register with the session manager 
rather soon in their startup process for a couple of reasons, the most 
relevant here being that it's sometimes quite difficult to say when 
application is fully started. So it's possible that phase2-started instance 
may get lucky and be ready sooner then a session-restored one.

-- 
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o.  e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/




More information about the kde-core-devel mailing list