Bug 367447 - Having one konsole window open at logout opens two at next login
Summary: Having one konsole window open at logout opens two at next login
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
: 367737 367957 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-17 18:41 UTC by Wolfgang Bauer
Modified: 2018-11-14 19:55 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
session file (396 bytes, text/plain)
2016-08-17 19:03 UTC, Wolfgang Bauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bauer 2016-08-17 18:41:53 UTC
If I leave a konsole window open at logout (with session management configured to "Restart the previous session"), I get two konsole windows at next login.

What's even more strange, they seem to be "clones", if I type something in the one window, the text also appears in the other window.

Reproducible: Always

Steps to Reproduce:
1. Open konsole
2. Logout with konsole open
3. login again

Actual Results:  
Two konsole windows appear.

Expected Results:  
Only one konsole window should appear.

This is a regression in 16.08.0, it worked fine with 15.04.3.

Also, it only happens with konsole, other applications are not affected.
So it's unlikely to be a problem with ksmserver, which I haven't updated anyway.
Comment 1 Wolfgang Bauer 2016-08-17 18:45:19 UTC
Additional info:
Even if I have two tabs open, the superfluous window only has one tab (which is a "clone" of one of the tabs in the original window).
Comment 2 Wolfgang Bauer 2016-08-17 19:03:38 UTC
Created attachment 100649 [details]
session file

This is reproducible by putting the attached file to ~/.config/session and running:
konsole --session 10c26d6967000147146005100000224800009_1471460063_520208

I don't see anything wrong in that session file.
So it's probably some bug in the session restoration code, I suppose.
Comment 3 Alex Sidorenko 2016-08-19 12:51:37 UTC
I started seeing the same problem on three PCs I have upgraded yesterday from KDE-applications 16.04.3 to 16.08.0 (using Neon repositories on Ubuntu). Everything worked fine on 16.04.3

If I create a new user with an empty directory  and login (this recreates all KDE settings), everything works fine - after logout/login only one konsole window is restored.

Another interesting thing: if I specify a bogus session, e.g.

$ konsole --session aaa
Attempted to re-run an already running session.

it always opens two konsole windows!

Alex
Comment 4 Alex Sidorenko 2016-08-19 12:57:33 UTC
I said in my post:

"If I create a new user with an empty directory  and login (this recreates all KDE settings), everything works fine - after logout/login only one konsole window is restored."

I tried this (logout/loging several times) yesterday and everything worked fine - but I have just tried to login as that 'new' user again, and this time two konsole windows are restored!

Alex
Comment 5 Wolfgang Bauer 2016-08-19 13:39:19 UTC
(In reply to asid from comment #3)
> Another interesting thing: if I specify a bogus session, e.g.
> 
> $ konsole --session aaa
> Attempted to re-run an already running session.
> 
> it always opens two konsole windows!

Indeed, I can confirm that.
So even easier to reproduce... ;-)

The problem does occur on a fresh user account (with a completely empty home directory) too.

The message about "Attempted to re-run an already running session." seems to be unrelated though, this is also displayed when I run the KDE4 version with "--session xxx" (which only opens one window as it should).
Comment 6 John Stanley 2016-08-27 05:56:04 UTC
This bug is due to'konsoleApp.newInstance() being called always, even when session Restoration is in effect. As a workaround, I've patched as follows:

--- konsole-16.08.0.old/src/main.cpp    2016-08-09 19:01:34.000000000 -0400
+++ konsole-16.08.0.new/src/main.cpp    2016-08-25 20:58:20.973978896 -0400
@@ -158,15 +158,13 @@ extern "C" int Q_DECL_EXPORT kdemain(int
     // of Konsole is started.
     QObject::connect(&dbusService, &KDBusService::activateRequested, &konsoleApp, &Application::slotActivateRequested);

-    if (!konsoleApp.newInstance()) {
+    if (app->isSessionRestored())
+        restoreSession(konsoleApp);
+    else if (!konsoleApp.newInstance()) {
         // An argument that printed something and mean we should just quit was passed.
         delete app;
         return 0;
     }
-
-    if (app->isSessionRestored())
-        restoreSession(konsoleApp);
-
     // Since we've allocated the QApplication on the heap for the KDBusService workaround,
     // we need to delete it manually before returning from main().
     int ret = app->exec();
Comment 7 Kurt Hindenburg 2016-08-28 13:10:55 UTC
Git commit 5b11fd593b954504343bdb418c54a8e7913d9c7c by Kurt Hindenburg.
Committed on 28/08/2016 at 13:08.
Pushed by hindenburg into branch 'master'.

Prevent 2 windows from opening upon session restore

Session management would start 2 konsole windows upon login.

Thanks John Stanley (jpsinthemix gmail com) for patch

M  +3    -4    src/main.cpp

http://commits.kde.org/konsole/5b11fd593b954504343bdb418c54a8e7913d9c7c
Comment 8 Wolfgang Bauer 2016-08-29 16:01:09 UTC
*** Bug 367957 has been marked as a duplicate of this bug. ***
Comment 9 Kurt Hindenburg 2016-08-31 12:49:01 UTC
Git commit 17cf652a9cd2f2c2c35b20c42cfcbfad8b83cb43 by Kurt Hindenburg.
Committed on 31/08/2016 at 12:36.
Pushed by hindenburg into branch 'Applications/16.08'.

Prevent 2 windows from opening upon session restore

Session management would start 2 konsole windows upon login.

Thanks John Stanley (jpsinthemix gmail com) for patch
(cherry picked from commit 5b11fd593b954504343bdb418c54a8e7913d9c7c)

M  +3    -4    src/main.cpp

http://commits.kde.org/konsole/17cf652a9cd2f2c2c35b20c42cfcbfad8b83cb43
Comment 10 Wolfgang Bauer 2018-11-14 19:55:23 UTC
*** Bug 367737 has been marked as a duplicate of this bug. ***