https://bugs.kde.org/show_bug.cgi?id=525600

Christoph Cullmann <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from Christoph Cullmann <[email protected]> ---
(In reply to Thomas Lindroth from comment #0)
> I run an X11 XFCE desktop and whenever xfce4-session tries to restore a
> previous XSMP session Kate opens an empty session instead of the one that
> was saved previously.
> 
> Here are the events that result in this behavior:
> * On shutdown, xfce4-session tells all open programs to save their state.
> * Kate saves its state to a file in ~/.config/session.
> * On the next login xfce4-session relaunches each program with an argument
> like "kate -session 200db0653-536d-4fb4-9756-5c59eff20416_1789070401_763692".
> * Kate launches and immediately runs daemon() to fork into the background
> and the process launched by xfce4-session exits before registering with the
> session manager.
> * xfce4-session treats this as "died while starting up"
> (xfce4-session/xfsm-startup.c:xfsm_startup_child_watch()) and performs
> cleanup by executing the "DiscardCommand" which removes the saved session
> file in ~/.config/session.
> * KateApp::restoreKate() is now unable to restore and
> KMainWindow::canBeRestored will be false, resulting in "oh, no mainwindow,
> create one, should not happen, but make sure ;)"
> 
> I'm not sure who is at fault here, Kate or xfce4-session? Even if this is
> caused by xfce4 I would prefer if KateApp::restoreKate() fell back to the
> normal Kate session (what a plain kate start restores) instead of showing an
> empty window.
> 
> This functionality has been broken for many years but I've never bothered to
> debug it until now. It probably broke back in 2023 when the detach
> functionality was added in b4b31d27d6.
> 
> If I apply the following patch to Kate to prevent detach the session restore
> works again:
> 
> diff --git a/apps/kate/main.cpp b/apps/kate/main.cpp
> index 1413b545ab..792fee2da0 100644
> --- a/apps/kate/main.cpp
> +++ b/apps/kate/main.cpp
> @@ -90,6 +90,24 @@ int main(int argc, char **argv)
>              detach = false;
>              break;
>          }
> +
> +        if (!strcmp(argv[i], "-session") || !strcmp(argv[i], "--session")
> || !strcmp(argv[i], "--sm-client-id")) {
> +            detach = false;
> +            break;
> +        }
>      }
>  
>      /**

That is an interesting insight!

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to