From b2f3b566c0c0edd41b0314fcbf516a3d7876e14b Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 29 Jan 2023 17:54:14 +0100 Subject: Fix concurrent edit, tests --- whiteboard.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'whiteboard.cpp') diff --git a/whiteboard.cpp b/whiteboard.cpp index fcfdca8..8736726 100644 --- a/whiteboard.cpp +++ b/whiteboard.cpp @@ -167,12 +167,14 @@ std::string Whiteboard::handle_request(Whiteboard::connection& c, const std::str pt::ptree ptree; ptree.put_child("diff", xml.get_child("request.diff")); Diff d{ptree}; - std::string data {m_storage->getDocument(id)}; - data = d.apply(data); + if (!d.empty()) { + std::string data {m_storage->getDocument(id)}; + data = d.apply(data); - m_storage->setDocument(id, data); - m_registry.setId(c, id); - notify_other_connections_diff(c, id, d); + m_storage->setDocument(id, data); + m_registry.setId(c, id); + notify_other_connections_diff(c, id, d); + } int pos {xml.get("request.pos")}; if (m_storage->getCursorPos(id) != pos) { -- cgit v1.2.3