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

Lok: compress duplicate state-changed events

STATE_CHANGED callback events that have the form
of name=value are only removed when newer ones
are identical. This is not very helpful since
often the same name (i.e. state type) changes
its value and we need to superseed older ones
with new values.

This patch makes sure that a STATE_CHANGED with
a given name has its latest value and doesn't
change multiple times while in the queue.

Change-Id: Ibfa18359464d7137411e5846b1c6d415a0aad43d
Reviewed-on: https://gerrit.libreoffice.org/31258Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
(cherry picked from commit f80140bf)
Reviewed-on: https://gerrit.libreoffice.org/31265Tested-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 7273349b
...@@ -1088,13 +1088,15 @@ void DesktopLOKTest::testNotificationCompression() ...@@ -1088,13 +1088,15 @@ void DesktopLOKTest::testNotificationCompression()
handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // Should be dropped. handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // Should be dropped.
handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // 12 handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // 12
handler->queue(LOK_CALLBACK_SET_PART, "1"); // 13 handler->queue(LOK_CALLBACK_SET_PART, "1"); // 13
handler->queue(LOK_CALLBACK_STATE_CHANGED, ".uno:AssignLayout=20"); // Superseeded
handler->queue(LOK_CALLBACK_CURSOR_VISIBLE, ""); // Should be dropped. handler->queue(LOK_CALLBACK_CURSOR_VISIBLE, ""); // Should be dropped.
handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // Should be dropped. handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // Should be dropped.
handler->queue(LOK_CALLBACK_SET_PART, "1"); // Should be dropped. handler->queue(LOK_CALLBACK_SET_PART, "1"); // Should be dropped.
handler->queue(LOK_CALLBACK_STATE_CHANGED, ".uno:AssignLayout=1"); // 14
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(13), notifs.size()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(14), notifs.size());
size_t i = 0; size_t i = 0;
CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, (int)std::get<0>(notifs[i])); CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, (int)std::get<0>(notifs[i]));
...@@ -1135,6 +1137,9 @@ void DesktopLOKTest::testNotificationCompression() ...@@ -1135,6 +1137,9 @@ void DesktopLOKTest::testNotificationCompression()
CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_SET_PART, (int)std::get<0>(notifs[i])); CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_SET_PART, (int)std::get<0>(notifs[i]));
CPPUNIT_ASSERT_EQUAL(std::string("1"), std::get<1>(notifs[i++])); CPPUNIT_ASSERT_EQUAL(std::string("1"), std::get<1>(notifs[i++]));
CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[i]));
CPPUNIT_ASSERT_EQUAL(std::string(".uno:AssignLayout=1"), std::get<1>(notifs[i++]));
} }
void DesktopLOKTest::testPartInInvalidation() void DesktopLOKTest::testPartInInvalidation()
......
...@@ -815,6 +815,24 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -815,6 +815,24 @@ void CallbackFlushHandler::queue(const int type, const char* data)
} }
} }
break; break;
// State changes with same name override previous ones with a different value.
// Ex. ".uno:PageStatus=Slide 20 of 83" overwrites any previous PageStatus.
case LOK_CALLBACK_STATE_CHANGED:
{
// Compare the state name=value and overwrite earlier entries with same name.
const auto pos = payload.find('=');
if (pos != std::string::npos)
{
const std::string name = payload.substr(0, pos + 1);
removeAll(
[type, &payload, &name] (const queue_type::value_type& elem) {
return (elem.first == type) && (elem.second.compare(0, name.size(), name) == 0);
}
);
}
}
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