Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Don't restart the blocking process on session restore

Summary:
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.

 [1] http://doc.qt.io/qt-5/qsessionmanager.html#details

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: https://phabricator.kde.org/D11818
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...
KStartupInfo::appStarted();
// 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) {
session.setRestartHint(QSessionManager::RestartNever);
},
Qt::DirectConnection
);
}
// this will wait until exiting is emitted by the used instance, if wanted...
return needToBlock ? app.exec() : 0;
}
......
Markdown is supported
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