Commit 0a73e00e authored by Алексей Шилин's avatar Алексей Шилин
Browse files

Don't restart the blocking process on session restore

All blocking Kate processes were restarted on session restore which
led to launching (possibly) multiple redundant instances.

This change asks the session manager to not restart such processes.

Note: QObject::connect() is used here because the session manager
can't be accessed directly according to the documentation [1]:

    In Qt, session management requests for action are handled by
    the two signals QGuiApplication::commitDataRequest() and
    QGuiApplication::saveStateRequest(). Both provide a reference
    to a QSessionManager object as argument. The session manager
    can only be accessed in slots invoked by these signals.


BUG: 360066
FIXED-IN: 18.04

Test Plan:
  0. Make sure that Plasma is configured to restore previous session
     on startup.
  1. Open Dolphin and create 'test1' and 'test2' text files.
  2. Open 'test1' in Kate from Dolphin.
  3. Open 'test2' in the already running Kate instance from Dolphin.
  4. Log out and back in. Check that there are no redundant Kate
     instances running.

Reviewers: #kate, dhaumann

Reviewed By: #kate, dhaumann

Subscribers: ngraham, dhaumann

Tags: #kate

Differential Revision:
parent a9b36311
......@@ -44,6 +44,7 @@
#include <QDBusReply>
#include <QApplication>
#include <QDir>
#include <QSessionManager>
#include "../urlinfo.h"
......@@ -488,6 +489,17 @@ int main(int argc, char **argv)
// make the world happy, we are started, kind of...
// We don't want the session manager to restart us on next login
// if we block
if (needToBlock) {
QObject::connect(qApp, &QGuiApplication::saveStateRequest, qApp,
[](QSessionManager &session) {
// this will wait until exiting is emitted by the used instance, if wanted...
return needToBlock ? app.exec() : 0;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment