common/MessageQueue.hpp | 8 ++++---- kit/Kit.cpp | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-)
New commits: commit 7f08cf53876ac55f4ed4668135937c576a7c0348 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Jan 1 13:05:52 2017 -0500 wsd: cleanup TileQueue accessing in Kit Change-Id: I50ff5bea0e0b193baef2abfaa1a866a7e20f9ab8 Reviewed-on: https://gerrit.libreoffice.org/32616 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/common/MessageQueue.hpp b/common/MessageQueue.hpp index 8bbe56a..6eb07c0 100644 --- a/common/MessageQueue.hpp +++ b/common/MessageQueue.hpp @@ -100,18 +100,18 @@ public: void updateCursorPosition(int viewId, int part, int x, int y, int width, int height) { - auto cursorPosition = CursorPosition({ part, x, y, width, height }); + const auto cursorPosition = CursorPosition({ part, x, y, width, height }); auto lock = getLock(); - auto it = _cursorPositions.find(viewId); - if (it != _cursorPositions.end()) + auto it = _cursorPositions.lower_bound(viewId); + if (it != _cursorPositions.end() && it->first == viewId) { it->second = cursorPosition; } else { - _cursorPositions[viewId] = cursorPosition; + _cursorPositions.insert(it, std::make_pair(viewId, cursorPosition)); } // Move to front, so the current front view diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 286760d..4b67507 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -792,6 +792,9 @@ public: assert(pDescr && "Null callback data."); assert(pDescr->Doc && "Null Document instance."); + auto tileQueue = pDescr->Doc->getTileQueue(); + assert(tileQueue && "Null TileQueue."); + const std::string payload = pPayload ? pPayload : "(nil)"; LOG_TRC("Document::ViewCallback [" << pDescr->ViewId << "] [" << LOKitHelper::kitCallbackTypeToString(nType) << @@ -809,7 +812,7 @@ public: auto cursorWidth = std::stoi(tokens[2]); auto cursorHeight = std::stoi(tokens[3]); - pDescr->Doc->getTileQueue()->updateCursorPosition(0, 0, cursorX, cursorY, cursorWidth, cursorHeight); + tileQueue->updateCursorPosition(0, 0, cursorX, cursorY, cursorWidth, cursorHeight); } } else if (nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR || @@ -830,11 +833,11 @@ public: auto cursorWidth = std::stoi(tokens[2]); auto cursorHeight = std::stoi(tokens[3]); - pDescr->Doc->getTileQueue()->updateCursorPosition(std::stoi(viewId), std::stoi(part), cursorX, cursorY, cursorWidth, cursorHeight); + tileQueue->updateCursorPosition(std::stoi(viewId), std::stoi(part), cursorX, cursorY, cursorWidth, cursorHeight); } } - pDescr->Doc->getTileQueue()->put("callback " + std::to_string(pDescr->ViewId) + " " + std::to_string(nType) + " " + payload); + tileQueue->put("callback " + std::to_string(pDescr->ViewId) + ' ' + std::to_string(nType) + ' ' + payload); } private: @@ -843,7 +846,7 @@ private: void broadcastCallbackToClients(const int nType, const std::string& payload) { // "-1" means broadcast - _tileQueue->put("callback -1 " + std::to_string(nType) + " " + payload); + _tileQueue->put("callback -1 " + std::to_string(nType) + ' ' + payload); } /// Load a document (or view) and register callbacks. @@ -909,7 +912,6 @@ private: const auto viewId = session.getViewId(); _tileQueue->removeCursorPosition(viewId); - std::unique_lock<std::mutex> lockLokDoc(_documentMutex); if (_loKitDocument == nullptr) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits