[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp
Pranav Kant
pranavk at collabora.co.uk
Fri Feb 19 21:56:08 UTC 2016
loolwsd/LOOLKit.cpp | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
New commits:
commit 7ecde2342246274d4f5564fd13511856e7533921
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Sun Feb 7 14:38:03 2016 +0530
loolwsd: Remove superfluous registration of callback
Our DocumentCallback is smart enough which checks all the
running connections, and send the callback notification to all of
them. Registering the callback only during the first loadDocument
call should be enough.
Change-Id: I82bcb9525814dae14def3bfb6c088337d0d0ea3c
Reviewed-on: https://gerrit.libreoffice.org/22202
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 9c55ff3..00847da 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -516,10 +516,12 @@ private:
if (_loKitDocument == nullptr)
{
+ // This is the first time we are loading the document
Log::info("Loading new document from URI: [" + uri + "] for session [" + sessionId + "].");
if ( LIBREOFFICEKIT_HAS(_loKit, registerCallback))
{
+ // TODO: Separate the global callback from document callback
_loKit->pClass->registerCallback(_loKit, DocumentCallback, this);
_loKit->pClass->setOptionalFeatures(_loKit, LOK_FEATURE_DOCUMENT_PASSWORD |
LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY);
@@ -527,6 +529,7 @@ private:
// documentLoad will trigger callback, which needs to take the lock.
lock.unlock();
+
if ((_loKitDocument = _loKit->pClass->documentLoad(_loKit, uri.c_str())) == nullptr)
{
Log::error("Failed to load: " + uri + ", error: " + _loKit->pClass->getError(_loKit));
@@ -535,22 +538,22 @@ private:
// Retake the lock.
lock.lock();
- }
- if (_multiView)
- {
- Log::info("Loading view to document from URI: [" + uri + "] for session [" + sessionId + "].");
- const auto viewId = _loKitDocument->pClass->createView(_loKitDocument);
+ if (_multiView)
+ {
+ Log::info("Loading view to document from URI: [" + uri + "] for session [" + sessionId + "].");
+ const auto viewId = _loKitDocument->pClass->createView(_loKitDocument);
- _loKitDocument->pClass->registerCallback(_loKitDocument, ViewCallback, reinterpret_cast<void*>(intSessionId));
+ _loKitDocument->pClass->registerCallback(_loKitDocument, ViewCallback, reinterpret_cast<void*>(intSessionId));
- Log::info() << "Document [" << _url << "] view ["
- << viewId << "] loaded, leaving "
- << (_clientViews + 1) << " views." << Log::end;
- }
- else
- {
- _loKitDocument->pClass->registerCallback(_loKitDocument, DocumentCallback, this);
+ Log::info() << "Document [" << _url << "] view ["
+ << viewId << "] loaded, leaving "
+ << (_clientViews + 1) << " views." << Log::end;
+ }
+ else
+ {
+ _loKitDocument->pClass->registerCallback(_loKitDocument, DocumentCallback, this);
+ }
}
++_clientViews;
More information about the Libreoffice-commits
mailing list