summaryrefslogtreecommitdiffstats
path: root/wsd
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2021-08-26 08:05:29 -0400
committerAshod Nakashian <Ashod@users.noreply.github.com>2021-09-26 17:02:01 -0400
commit965e5cb37decccca54a3b0fee65528b3db2b4524 (patch)
tree4431578911dc4e19228d5f134a7d50c8062a1033 /wsd
parentwsd: autosave using the last editing session (diff)
downloadonline-965e5cb37decccca54a3b0fee65528b3db2b4524.tar.gz
online-965e5cb37decccca54a3b0fee65528b3db2b4524.zip
wsd: verify that the last-editing-session can save
The last-editing-session could still be valid, but waiting disconnection, in which case the kit might have already discarded it, and so saving would fail (silently, and thereby leaving docbroker waiting for the save response). To avoid this, we always validate the last-editing-session before using, and not just when setting it. Change-Id: I60cd219d8e5a9945396110c8f8d194e87f81afba Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk> (cherry picked from commit e1fc6adbfef7ee0678c7a563fd6142c32f2da4a6)
Diffstat (limited to 'wsd')
-rw-r--r--wsd/DocumentBroker.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index aa7ea4ec26..63e0e5608a 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1749,9 +1749,13 @@ bool DocumentBroker::autoSave(const bool force, const bool dontSaveIfUnmodified)
// Which session to use when auto saving ?
// Prefer the last editing view, if still valid, otherwise, find the first writable sessionId.
- const std::string savingSessionId = (_sessions.find(_lastEditingSessionId) != _sessions.end())
- ? _lastEditingSessionId
- : getWriteableSessionId();
+ // Note: a loaded view cannot be disconnecting.
+ const auto itLastEditingSession = _sessions.find(_lastEditingSessionId);
+ const std::string savingSessionId =
+ (itLastEditingSession != _sessions.end() && itLastEditingSession->second->isReadOnly() &&
+ itLastEditingSession->second->isViewLoaded())
+ ? _lastEditingSessionId
+ : getWriteableSessionId();
// Remember the last save time, since this is the predicate.
LOG_TRC("Checking to autosave [" << _docKey << "] using session [" << savingSessionId << ']');