Commit 35e5dc95 authored by David Edmundson's avatar David Edmundson
Browse files

Remove pointless QDBusServiceWatcher

Summary:
KActivitymanagerd's ksmserver has a QDBusServiceWatcher in order to
recreate a QDBusInterface when the service goes away. There is no need
to do this, a call to a given method to a given service will work
regardless, dispatching to the correct client is all internal to
dbus-daemon.

QDBusAbstractInterface has it's own internal QDBusServiceWatcher anyway
so we don't get any behavioural differences if we check isValid.

This is worth fixing as this class is moved threads and we end up with
newly created children in a mess.

CCBUG: 413940

Test Plan:

Reviewers: #plasma, apol

Reviewed By: apol

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D25205
parent facfb445
......@@ -42,52 +42,10 @@
#define KWIN_SERVICE QStringLiteral("org.kde.KWin")
KSMServer::Private::Private(KSMServer *parent)
: serviceWatcher(new QDBusServiceWatcher(this))
, kwin(nullptr)
: kwin(new QDBusInterface(KWIN_SERVICE, QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QDBusConnection::sessionBus(), this))
, processing(false)
, q(parent)
{
serviceWatcher->setConnection(KDBusConnectionPool::threadConnection());
serviceWatcher->addWatchedService(KWIN_SERVICE);
connect(serviceWatcher.get(), &QDBusServiceWatcher::serviceOwnerChanged,
this, &Private::serviceOwnerChanged);
serviceOwnerChanged(KWIN_SERVICE, QString(), QString());
}
void KSMServer::Private::serviceOwnerChanged(const QString &service,
const QString &oldOwner,
const QString &newOwner)
{
Q_UNUSED(oldOwner);
Q_UNUSED(newOwner);
if (service == KWIN_SERVICE) {
// Delete the old object, just in case
delete kwin;
kwin = nullptr;
if (KDBusConnectionPool::threadConnection().interface()->isServiceRegistered(KWIN_SERVICE)) {
// Creating the new dbus interface
// TODO: in multi-head environment there are multiple kwin instances
// running and they will export different dbus name on different
// root window. We have no support for that currently.
// In future, the session management for Wayland may also need to be
// reimplemented in some way.
kwin = new QDBusInterface(KWIN_SERVICE, QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"));
// If the service is valid, initialize it
// otherwise delete the object
if (kwin->isValid()) {
kwin->setParent(this);
} else {
delete kwin;
kwin = nullptr;
}
}
}
}
KSMServer::KSMServer(QObject *parent)
......@@ -112,7 +70,7 @@ void KSMServer::stopActivitySession(const QString &activity)
void KSMServer::Private::processLater(const QString &activity, bool start)
{
if (kwin) {
if (kwin->isValid()) {
for (const auto &item: queue) {
if (item.first == activity) {
return;
......@@ -151,7 +109,7 @@ void KSMServer::Private::process()
void KSMServer::Private::makeRunning(bool value)
{
if (!kwin) {
if (!kwin->isValid()) {
qCDebug(KAMD_LOG_ACTIVITIES) << "Activities KSM: No kwin, marking activity as: " << value;
subSessionSendEvent(value ? KSMServer::Started : KSMServer::Stopped);
return;
......
......@@ -43,8 +43,6 @@ public:
void processLater(const QString &activity, bool start);
private Q_SLOTS:
void serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner);
void process();
void makeRunning(bool value);
......@@ -54,7 +52,6 @@ private Q_SLOTS:
void subSessionSendEvent(int event);
private:
std::unique_ptr<QDBusServiceWatcher> serviceWatcher;
QDBusInterface *kwin;
bool processing;
......
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