On branch topic-session-save Changes to be committed: (use "git reset HEAD ..." to unstage) modified: sm.cpp diff --git a/sm.cpp b/sm.cpp index 2098b7f..05a5d77 100644 --- a/sm.cpp +++ b/sm.cpp @@ -30,6 +30,7 @@ along with this program. If not, see . #include "workspace.h" #include "client.h" #include +#include #include #include @@ -64,18 +65,30 @@ void Workspace::saveState(QSessionManager &sm) // too late, as possible user interaction may change some things. // Phase2 is still needed though (ICCCM 5.2) KConfig *config = sessionConfig(sm.sessionId(), sm.sessionKey()); + if (!sm.isPhase2()) { KConfigGroup cg(config, "Session"); cg.writeEntry("AllowsInteraction", sm.allowsInteraction()); sessionSaveStarted(); if (gs_sessionManagerIsKSMServer) // save stacking order etc. before "save file?" etc. dialogs change it storeSession(config, SMSavePhase0); + // don't save it to disk + config->markAsClean(); sm.release(); // Qt doesn't automatically release in this case (bug?) sm.requestPhase2(); return; } storeSession(config, gs_sessionManagerIsKSMServer ? SMSavePhase2 : SMSavePhase2Full); config->sync(); + + // generate discard command for new file + QString localFilePath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + config->name(); + if (QFile::exists(localFilePath)) { + QStringList discard; + discard << QLatin1String("rm"); + discard << localFilePath; + sm.setDiscardCommand(discard); + } } // I bet this is broken, just like everywhere else in KDE