From 90dbda90711898637e8174eccc0549dbe6f089eb Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Fri, 17 Dec 2010 13:05:24 +0000 Subject: [PATCH] return false if anyone tries to start/stop an activity during logout svn path=/trunk/KDE/kdebase/workspace/; revision=1207295 --- org.kde.KWin.xml | 2 ++ sm.cpp | 39 +++++++++++++++++++++++++-------------- workspace.h | 4 ++-- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/org.kde.KWin.xml b/org.kde.KWin.xml index 25afc0dcff..bd993ed90f 100644 --- a/org.kde.KWin.xml +++ b/org.kde.KWin.xml @@ -75,9 +75,11 @@ + + diff --git a/sm.cpp b/sm.cpp index 163fd403d4..b00de8b8a4 100644 --- a/sm.cpp +++ b/sm.cpp @@ -205,11 +205,17 @@ void Workspace::storeSubSession(const QString &name, QSet sessionIds //cg.writeEntry( "desktop", currentDesktop()); } -void Workspace::stopActivity(const QString &id) - { - //ugly hack to avoid dbus deadlocks - QMetaObject::invokeMethod(this, "reallyStopActivity", Qt::QueuedConnection, Q_ARG(QString, id)); +bool Workspace::stopActivity(const QString &id) +{ + if (sessionSaving()) { + return false; //ksmserver doesn't queue requests (yet) + //FIXME what about session *loading*? } + //ugly hack to avoid dbus deadlocks + QMetaObject::invokeMethod(this, "reallyStopActivity", Qt::QueuedConnection, Q_ARG(QString, id)); + //then lie and assume it worked. + return true; +} void Workspace::reallyStopActivity(const QString &id) { @@ -335,25 +341,30 @@ void Workspace::loadSubSessionInfo(const QString &name) addSessionInfo(cg); } -void Workspace::startActivity(const QString &id) - { - if (!allActivities_.contains(id)) - return; //bogus id +bool Workspace::startActivity(const QString &id) +{ + if (sessionSaving()) { + return false; //ksmserver doesn't queue requests (yet) + } + if (!allActivities_.contains(id)) { + return false; //bogus id + } loadSubSessionInfo(id); QDBusInterface ksmserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface"); - if (ksmserver.isValid()) - { + if (ksmserver.isValid()) { QDBusMessage reply = ksmserver.call("restoreSubSession", id); - if (reply.type() == QDBusMessage::ErrorMessage) + if (reply.type() == QDBusMessage::ErrorMessage) { kDebug() << "dbus error:" << reply.errorMessage(); - else - kDebug() << "dbus succeeded"; + return false; } - else + } else { kDebug() << "couldn't get ksmserver interface"; + return false; } + return true; +} /*! Returns a SessionInfo for client \a c. The returned session diff --git a/workspace.h b/workspace.h index 0eec15df34..eec1b2e904 100644 --- a/workspace.h +++ b/workspace.h @@ -450,8 +450,8 @@ class Workspace : public QObject, public KDecorationDefines void toggleTiling(); void nextTileLayout(); void previousTileLayout(); - void stopActivity( const QString &id ); - void startActivity( const QString &id ); + bool stopActivity( const QString &id ); + bool startActivity( const QString &id ); void setCurrentScreen( int new_screen );