loolwsd/ChildSession.cpp | 22 ++++++++++++++++------ loolwsd/LOOLKit.cpp | 2 ++ loolwsd/LibreOfficeKit.hpp | 1 + 3 files changed, 19 insertions(+), 6 deletions(-)
New commits: commit eb38d7697bd5fbe7a982c80297c37ba41bbddfb8 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Wed Aug 17 19:51:34 2016 -0400 loolwsd: don't unload views not loaded yet Change-Id: Iee676849cc2b9ac4f0e518e5730e921687c3a42d Reviewed-on: https://gerrit.libreoffice.org/28286 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp index dd0d361..51b445f 100644 --- a/loolwsd/ChildSession.cpp +++ b/loolwsd/ChildSession.cpp @@ -39,7 +39,7 @@ ChildSession::ChildSession(const std::string& id, LOOLSession(id, Kind::ToMaster, ws), _multiView(std::getenv("LOK_VIEW_CALLBACK")), _jailId(jailId), - _viewId(0), + _viewId(-1), _docManager(docManager) { Log::info("ChildSession ctor [" + getName() + "]."); @@ -60,10 +60,17 @@ void ChildSession::disconnect() sendTextFrame("remview: " + std::to_string(_viewId)); - if (_multiView && _loKitDocument) - _loKitDocument->setView(_viewId); + if (_viewId >= 0) + { + if (_multiView && _loKitDocument) + _loKitDocument->setView(_viewId); - _docManager.onUnload(getId()); + _docManager.onUnload(getId()); + } + else + { + Log::warn("Skipping unload on incomplete view."); + } LOOLSession::disconnect(); } @@ -87,7 +94,7 @@ bool ChildSession::_handleInput(const char *buffer, int length) // Client is getting active again. // Send invalidation and other sync-up messages. - std::unique_lock<std::recursive_mutex> lock(Mutex); + std::unique_lock<std::recursive_mutex> lock(Mutex); //TODO: Move to top of function? if (_multiView) _loKitDocument->setView(_viewId); @@ -322,7 +329,9 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT if (_multiView) { _viewId = _loKitDocument->getView(); - sendTextFrame("addview: " + std::to_string(_viewId)); + const auto viewId = std::to_string(_viewId); + Log::info("Created new view: " + viewId); + sendTextFrame("addview: " + viewId); } _docType = LOKitHelper::getDocumentTypeAsString(_loKitDocument->get()); @@ -1018,6 +1027,7 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload) break; case LOK_CALLBACK_ERROR: { + Log::error("CALLBACK_ERROR: " + rPayload); Parser parser; Poco::Dynamic::Var var = parser.parse(rPayload); Object::Ptr object = var.extract<Object::Ptr>(); diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index 2b9117c..9e6b6d5 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -600,6 +600,7 @@ public: void renderTile(StringTokenizer& tokens, const std::shared_ptr<Poco::Net::WebSocket>& ws) { + assert(ws && "Expected a non-null websocket."); auto tile = TileDesc::parse(tokens); // Send back the request with all optional parameters given in the request. @@ -655,6 +656,7 @@ public: void renderCombinedTiles(StringTokenizer& tokens, const std::shared_ptr<Poco::Net::WebSocket>& ws) { + assert(ws && "Expected a non-null websocket."); auto tileCombined = TileCombined::parse(tokens); auto& tiles = tileCombined.getTiles(); diff --git a/loolwsd/LibreOfficeKit.hpp b/loolwsd/LibreOfficeKit.hpp index 4e2aab0..ff557d6 100644 --- a/loolwsd/LibreOfficeKit.hpp +++ b/loolwsd/LibreOfficeKit.hpp @@ -432,6 +432,7 @@ public: { std::unique_lock<std::mutex> lock(_mutex); Log::trace() << "lok::Document: setView: " << nId << Log::end; + assert(nId >= 0 && "ViewID must be non-negative."); _pDoc->pClass->setView(_pDoc, nId); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits