summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-02-15 09:23:58 -0500
committerAndras Timar <andras.timar@collabora.com>2019-03-05 10:40:00 +0100
commit09a0b496ae3c6c4fb4b9ce2645c65c7c031941c1 (patch)
treeaf14afa33d0c89670f1ea27667f67b9724dad92e /desktop
parent926b4fe7d84fa3aaaddb1a6a8bd1cb943b72aea6 (diff)
LOK: always update the payload string via the cache
Change-Id: I090ceb7d214d0809e86b023a8806b6655627918a Reviewed-on: https://gerrit.libreoffice.org/68271 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/inc/lib/init.hxx2
-rw-r--r--desktop/source/lib/init.cxx15
2 files changed, 13 insertions, 4 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index be96814820ce..2ba5595d8b46 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -102,6 +102,8 @@ namespace desktop {
/// Parse and set the RectangleAndPart object and return it. Clobbers PayloadString.
RectangleAndPart& setRectangleAndPart(const std::string& payload);
+ /// Set a RectangleAndPart object and update PayloadString.
+ void setRectangleAndPart(const RectangleAndPart& rRectAndPart);
/// Return the parsed RectangleAndPart instance.
const RectangleAndPart& getRectangleAndPart() const;
/// Parse and set the JSON object and return it. Clobbers PayloadString.
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 45a68a2a6703..b621f134b5f4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -459,12 +459,18 @@ RectangleAndPart RectangleAndPart::Create(const std::string& rPayload)
RectangleAndPart& CallbackFlushHandler::CallbackData::setRectangleAndPart(const std::string& payload)
{
- PayloadString = payload;
+ setRectangleAndPart(RectangleAndPart::Create(payload));
- PayloadObject = RectangleAndPart::Create(payload);
+ // Return reference to the cached object.
return boost::get<RectangleAndPart>(PayloadObject);
}
+void CallbackFlushHandler::CallbackData::setRectangleAndPart(const RectangleAndPart& rRectAndPart)
+{
+ PayloadString = rRectAndPart.toString().getStr();
+ PayloadObject = rRectAndPart;
+}
+
const RectangleAndPart& CallbackFlushHandler::CallbackData::getRectangleAndPart() const
{
assert(PayloadObject.which() == 1);
@@ -480,6 +486,7 @@ boost::property_tree::ptree& CallbackFlushHandler::CallbackData::setJson(const s
// Let boost normalize the payload so it always matches the cache.
setJson(aTree);
+ // Return reference to the cached object.
return boost::get<boost::property_tree::ptree>(PayloadObject);
}
@@ -916,7 +923,7 @@ void CallbackFlushHandler::callback(const int type, const char* payload, void* d
void CallbackFlushHandler::queue(const int type, const char* data)
{
CallbackData aCallbackData(type, (data ? data : "(nil)"));
- std::string& payload = aCallbackData.PayloadString;
+ const std::string& payload = aCallbackData.PayloadString;
SAL_INFO("lok", "Queue: " << type << " : " << payload);
#ifdef DBG_UTIL
@@ -1205,7 +1212,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
}
}
- payload = rcNew.toString().getStr();
+ aCallbackData.setRectangleAndPart(rcNew);
}
break;