From 2cf3161bff195a862a6853235530ecea7853dedc Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Thu, 25 Jan 2018 16:49:31 +0200 Subject: [PATCH] Call processEvents while rendering new events --- src/timeline/TimelineView.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/timeline/TimelineView.cc b/src/timeline/TimelineView.cc index 31d190cc..85f01b5d 100644 --- a/src/timeline/TimelineView.cc +++ b/src/timeline/TimelineView.cc @@ -249,16 +249,23 @@ TimelineView::parseMessageEvent(const mtx::events::collections::TimelineEvents & void TimelineView::renderBottomEvents(const std::vector &events) { + int counter = 0; + for (const auto &event : events) { TimelineItem *item = parseMessageEvent(event, TimelineDirection::Bottom); - if (item != nullptr) + if (item != nullptr) { addTimelineItem(item, TimelineDirection::Bottom); + counter++; + + // Prevent blocking of the event-loop + // by calling processEvents every 10 items we render. + if (counter % 10 == 0) + QApplication::processEvents(); + } } lastMessageDirection_ = TimelineDirection::Bottom; - - QApplication::processEvents(); } int