[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Apr 24 17:41:21 UTC 2017


 wsd/ClientSession.cpp  |    4 +++-
 wsd/ClientSession.hpp  |   10 +++++++++-
 wsd/DocumentBroker.cpp |    1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

New commits:
commit f3bea4d5343900f9fd347ea99fd84232a7a8e3e7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri Apr 21 00:00:44 2017 -0400

    wsd: rely only on loaded sessions for saving
    
    Change-Id: I6afdca2f514a5d3f4f71f7b3f5598073fe877635
    Reviewed-on: https://gerrit.libreoffice.org/36767
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 414f8b94..11db33af 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -37,7 +37,8 @@ ClientSession::ClientSession(const std::string& id,
     _docBroker(docBroker),
     _uriPublic(uriPublic),
     _isDocumentOwner(false),
-    _isAttached(false)
+    _isAttached(false),
+    _isViewLoaded(false)
 {
     const size_t curConnections = ++LOOLWSD::NumConnections;
     LOG_INF("ClientSession ctor [" << getName() << "], current number of connections: " << curConnections);
@@ -631,6 +632,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
         }
         else if (tokens[0] == "status:")
         {
+            setViewLoaded();
             docBroker->setLoaded();
 
             // Forward the status response to the client.
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 9cd67533..d5ea76df 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -34,10 +34,14 @@ public:
 
     void setReadOnly() override;
 
-    /// Returns true if a document is loaded (i.e. we got status message).
+    /// Returns true if this session is added to a DocBroker.
     bool isAttached() const { return _isAttached; }
     void setAttached() { _isAttached = true; }
 
+    /// Returns true if this session has loaded a view (i.e. we got status message).
+    bool isViewLoaded() const { return _isViewLoaded; }
+    void setViewLoaded() { _isViewLoaded = true; }
+
     const std::string getUserId() const { return _userId; }
     void setUserId(const std::string& userId) { _userId = userId; }
     void setUserName(const std::string& userName) { _userName = userName; }
@@ -139,8 +143,12 @@ private:
     /// The socket to which the converted (saveas) doc is sent.
     std::shared_ptr<StreamSocket> _saveAsSocket;
 
+    /// If we are added to a DocBroker.
     bool _isAttached;
 
+    /// If we have loaded a view.
+    bool _isViewLoaded;
+
     /// Wopi FileInfo object
     std::unique_ptr<WopiStorage::WOPIFileInfo> _wopiFileInfo;
 
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 94a49a1d..461fd045 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1218,6 +1218,7 @@ void DocumentBroker::destroyIfLastEditor(const std::string& id)
         for (const auto& it : _sessions)
         {
             if (it.second->getId() != id &&
+                it.second->isViewLoaded() &&
                 !it.second->isReadOnly())
             {
                 // Found another editable.


More information about the Libreoffice-commits mailing list