diff --git a/kdecore/kernel/ktoolinvocation.cpp b/kdecore/kernel/ktoolinvocation.cpp index ff4cbb4d..98bea3dc 100644 --- a/kdecore/kernel/ktoolinvocation.cpp +++ b/kdecore/kernel/ktoolinvocation.cpp @@ -27,10 +27,7 @@ #include "kurl.h" #include "kmessage.h" #include "kservice.h" -#include -#include - -#include +#include "klocale.h" #include #include @@ -38,6 +35,8 @@ #include #include +#include + KToolInvocation *KToolInvocation::self() { K_GLOBAL_STATIC(KToolInvocation, s_self) @@ -59,7 +58,16 @@ org::kde::KLauncher *KToolInvocation::klauncher() { if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(QString::fromLatin1("org.kde.klauncher"))) { kDebug(180) << "klauncher not running... launching kdeinit"; - KToolInvocation::startKdeinit(); + // Try to launch kdeinit. + QString srv = KStandardDirs::findExe(QLatin1String("kdeinit4")); + if (srv.isEmpty()) { + kError() << "kdeinit4 not available"; + // NOTE: this will crash any users not checking the pointer + return nullptr; + } + QStringList args; + args += QString::fromLatin1("--suicide"); + QProcess::execute(srv, args); } return ::klauncherIface(); } @@ -302,28 +310,4 @@ void KToolInvocation::invokeMailer(const KUrl &mailtoURL, const QByteArray& star invokeMailer( address, cc, bcc, subject, body, QString(), attachURLs, startup_id ); } -void KToolInvocation::startKdeinit() -{ - KComponentData inst( "startkdeinitlock" ); - KLockFile lock( KStandardDirs::locateLocal("tmp", QString::fromLatin1("startkdeinitlock"), inst )); - if( lock.lock( KLockFile::NoBlockFlag ) != KLockFile::LockOK ) { - lock.lock(); - if( QDBusConnection::sessionBus().interface()->isServiceRegistered(QString::fromLatin1("org.kde.klauncher"))) - return; // whoever held the lock has already started it - } - // Try to launch kdeinit. - QString srv = KStandardDirs::findExe(QLatin1String("kdeinit4")); - if (srv.isEmpty()) - return; -// this is disabled because we are in kdecore -// const bool gui = qApp && qApp->type() != QApplication::Tty; -// if ( gui ) -// qApp->setOverrideCursor( Qt::WaitCursor ); - QStringList args; - args += QString::fromLatin1("--suicide"); - QProcess::execute(srv, args); -// if ( gui ) -// qApp->restoreOverrideCursor(); -} - #include "moc_ktoolinvocation.cpp"