diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-01-25 16:49:31 +0200 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-01-25 16:49:31 +0200 |
commit | 2cf3161bff195a862a6853235530ecea7853dedc (patch) | |
tree | aee160436ae414cc0a7801608dab4b3b51797b5f | |
parent | Generate compile_commands.json (diff) | |
download | nheko-2cf3161bff195a862a6853235530ecea7853dedc.tar.xz |
Call processEvents while rendering new events
-rw-r--r-- | src/timeline/TimelineView.cc | 13 |
1 files 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<TimelineEvent> &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 |