[Libreoffice-commits] online.git: loolwsd/ClientSession.cpp loolwsd/ClientSession.hpp loolwsd/DocumentBroker.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue May 17 13:57:54 UTC 2016


 loolwsd/ClientSession.cpp  |   15 ++++++++-------
 loolwsd/ClientSession.hpp  |    2 +-
 loolwsd/DocumentBroker.cpp |    2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)

New commits:
commit 76991dd325f5b90ab1d7ceb6a9f55d952154f701
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue May 17 08:17:21 2016 -0400

    loolwsd: disable editlock in multiview
    
    Change-Id: I4df2d8a321e160ce226c2e22aa754cd6e5b2c755
    Reviewed-on: https://gerrit.libreoffice.org/25063
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/ClientSession.cpp b/loolwsd/ClientSession.cpp
index 33615ed..49ba399 100644
--- a/loolwsd/ClientSession.cpp
+++ b/loolwsd/ClientSession.cpp
@@ -40,7 +40,7 @@ ClientSession::ClientSession(const std::string& id,
     LOOLSession(id, Kind::ToClient, ws),
     _docBroker(docBroker),
     _queue(queue),
-    _haveEditLock(false),
+    _haveEditLock(std::getenv("LOK_VIEW_CALLBACK")),
     _loadFailed(false),
     _loadPart(-1)
 {
@@ -222,10 +222,9 @@ bool ClientSession::getStatus(const char *buffer, int length)
         sendTextFrame(status);
 
         // And let clients know if they hold the edit lock.
-        std::string message = "editlock: ";
-        message += std::to_string(isEditLocked());
-        Log::debug("Forwarding [" + message + "] in response to status.");
-        sendTextFrame(message);
+        const auto msg = "editlock: " + std::to_string(isEditLocked());
+        Log::debug("Returning [" + msg + "] in response to status.");
+        sendTextFrame(msg);
 
         return true;
     }
@@ -243,8 +242,10 @@ bool ClientSession::getStatus(const char *buffer, int length)
 void ClientSession::setEditLock(const bool value)
 {
     // Update the sate and forward to child.
-    _haveEditLock = value;
-    const auto msg = std::string("editlock: ") + (value ? "1" : "0");
+    markEditLock(value);
+    const auto msg = "editlock: " + std::to_string(isEditLocked());
+    const auto mv = std::getenv("LOK_VIEW_CALLBACK") ? "1" : "0";
+    Log::debug("Forwarding [" + msg + "] to set editlock to " + std::to_string(value) + ". MultiView: " + mv);
     forwardToPeer(msg.data(), msg.size());
 }
 
diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index 65891f7..2b5d0f0 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -27,7 +27,7 @@ public:
     virtual ~ClientSession();
 
     void setEditLock(const bool value);
-    void markEditLock(const bool value) { _haveEditLock = value; }
+    void markEditLock(const bool value) { _haveEditLock = (value || std::getenv("LOK_VIEW_CALLBACK")); }
     bool isEditLocked() const { return _haveEditLock; }
 
     void setPeer(const std::shared_ptr<PrisonerSession>& peer) { _peer = peer; }
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index a7abd38..3bb2bcc 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -275,7 +275,7 @@ bool DocumentBroker::sendUnoSave()
     Log::info("Autosave triggered for doc [" + _docKey + "].");
     Util::assertIsLocked(_mutex);
 
-    // Save using session holding the edit-lock
+    // Save using session holding the edit-lock (or first if multview).
     for (auto& sessionIt: _sessions)
     {
         if (sessionIt.second->isEditLocked())


More information about the Libreoffice-commits mailing list