Kaydet (Commit) 5f978a3b authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

LOK: always update the payload string via the cache

Change-Id: I090ceb7d214d0809e86b023a8806b6655627918a
Reviewed-on: https://gerrit.libreoffice.org/67894
Tested-by: Jenkins
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 75be2ba9
...@@ -102,6 +102,8 @@ namespace desktop { ...@@ -102,6 +102,8 @@ namespace desktop {
/// Parse and set the RectangleAndPart object and return it. Clobbers PayloadString. /// Parse and set the RectangleAndPart object and return it. Clobbers PayloadString.
RectangleAndPart& setRectangleAndPart(const std::string& payload); RectangleAndPart& setRectangleAndPart(const std::string& payload);
/// Set a RectangleAndPart object and update PayloadString.
void setRectangleAndPart(const RectangleAndPart& rRectAndPart);
/// Return the parsed RectangleAndPart instance. /// Return the parsed RectangleAndPart instance.
const RectangleAndPart& getRectangleAndPart() const; const RectangleAndPart& getRectangleAndPart() const;
/// Parse and set the JSON object and return it. Clobbers PayloadString. /// Parse and set the JSON object and return it. Clobbers PayloadString.
......
...@@ -456,12 +456,18 @@ RectangleAndPart RectangleAndPart::Create(const std::string& rPayload) ...@@ -456,12 +456,18 @@ RectangleAndPart RectangleAndPart::Create(const std::string& rPayload)
RectangleAndPart& CallbackFlushHandler::CallbackData::setRectangleAndPart(const std::string& payload) 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); return boost::get<RectangleAndPart>(PayloadObject);
} }
void CallbackFlushHandler::CallbackData::setRectangleAndPart(const RectangleAndPart& rRectAndPart)
{
PayloadString = rRectAndPart.toString().getStr();
PayloadObject = rRectAndPart;
}
const RectangleAndPart& CallbackFlushHandler::CallbackData::getRectangleAndPart() const const RectangleAndPart& CallbackFlushHandler::CallbackData::getRectangleAndPart() const
{ {
assert(PayloadObject.which() == 1); assert(PayloadObject.which() == 1);
...@@ -477,6 +483,7 @@ boost::property_tree::ptree& CallbackFlushHandler::CallbackData::setJson(const s ...@@ -477,6 +483,7 @@ boost::property_tree::ptree& CallbackFlushHandler::CallbackData::setJson(const s
// Let boost normalize the payload so it always matches the cache. // Let boost normalize the payload so it always matches the cache.
setJson(aTree); setJson(aTree);
// Return reference to the cached object.
return boost::get<boost::property_tree::ptree>(PayloadObject); return boost::get<boost::property_tree::ptree>(PayloadObject);
} }
...@@ -913,7 +920,7 @@ void CallbackFlushHandler::callback(const int type, const char* payload, void* d ...@@ -913,7 +920,7 @@ void CallbackFlushHandler::callback(const int type, const char* payload, void* d
void CallbackFlushHandler::queue(const int type, const char* data) void CallbackFlushHandler::queue(const int type, const char* data)
{ {
CallbackData aCallbackData(type, (data ? data : "(nil)")); CallbackData aCallbackData(type, (data ? data : "(nil)"));
std::string& payload = aCallbackData.PayloadString; const std::string& payload = aCallbackData.PayloadString;
SAL_INFO("lok", "Queue: " << type << " : " << payload); SAL_INFO("lok", "Queue: " << type << " : " << payload);
#ifdef DBG_UTIL #ifdef DBG_UTIL
...@@ -1202,7 +1209,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -1202,7 +1209,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
} }
} }
payload = rcNew.toString().getStr(); aCallbackData.setRectangleAndPart(rcNew);
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment