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

Commit 8c85bfa6 authored by David Edmundson's avatar David Edmundson

[ksmserver] Simplify call to kcminit

Summary:
kcminit had a slot to start processing something and a signal to emit
when it's finished.

For DBus that's quite bad practice as it can leave you hanging in the
case of a kcminit crashing. It's better to use the return of the
original call to signal when something is done.

From ksmserver we can then just use DBus timeouts set on the interface
than a secondary timer.

We also remove a pointless blocking call to kcminit introspecting
everything, if kcminit is not running it will return with an error
immediately which is no slower than checking first if it's not running
and faster if it is.

Test Plan:
Logged in
Session logs showed kcminit ran

Reviewers: #plasma, broulik

Reviewed By: #plasma, broulik

Subscribers: zzag, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D16587
parent ca92fb82
......@@ -232,38 +232,20 @@ KCMInitJob::KCMInitJob(int phase)
}
void KCMInitJob::start() {
//FIXME - replace all this with just a DBus call with a timeout and make kcminit delay the reply till it's done
auto kcminitSignals = new QDBusInterface( QStringLiteral( "org.kde.kcminit"),
QStringLiteral( "/kcminit" ),
QStringLiteral( "org.kde.KCMInit" ),
QDBusConnection::sessionBus(), this );
if( !kcminitSignals->isValid()) {
qCWarning(KSMSERVER) << "kcminit not running? If we are running with mobile profile or in another platform other than X11 this is normal.";
QTimer::singleShot(0, this, &KCMInitJob::done);
return;
}
if (m_phase == 1) {
connect( kcminitSignals, SIGNAL(phase1Done()), this, SLOT(done()));
} else {
connect( kcminitSignals, SIGNAL(phase2Done()), this, SLOT(done()));
}
QTimer::singleShot( 10000, this, &KCMInitJob::done); // protection
org::kde::KCMInit kcminit(QStringLiteral("org.kde.kcminit"),
QStringLiteral("/kcminit"),
QDBusConnection::sessionBus());
kcminit.setTimeout(10 * 1000);
QDBusPendingReply<void> pending;
if (m_phase == 1) {
kcminit.runPhase1();
pending = kcminit.runPhase1();
} else {
kcminit.runPhase2();
pending = kcminit.runPhase2();
}
}
void KCMInitJob::done()
{
emitResult();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this]() {emitResult();});
connect(watcher, &QDBusPendingCallWatcher::finished, watcher, &QObject::deleteLater);
}
KDEDInitJob::KDEDInitJob()
......
......@@ -53,8 +53,6 @@ Q_OBJECT
public:
KCMInitJob(int phase);
void start() override;
public Q_SLOTS:
void done();
private:
int m_phase;
};
......
......@@ -197,13 +197,11 @@ KCMInit::~KCMInit()
void KCMInit::runPhase1()
{
runModules( 1 );
emit phase1Done();
}
void KCMInit::runPhase2()
{
runModules( 2 );
emit phase2Done();
qApp->exit( 0 );
}
......
......@@ -34,9 +34,6 @@ class KCMInit : public QObject
public Q_SLOTS: //dbus
Q_SCRIPTABLE void runPhase1();
Q_SCRIPTABLE void runPhase2();
Q_SIGNALS: //dbus signal
Q_SCRIPTABLE void phase1Done();
Q_SCRIPTABLE void phase2Done();
public:
explicit KCMInit( const QCommandLineParser& args );
~KCMInit() override;
......
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