From 03ee407c346845484629c2a6afef39a13f0b9a3d Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Wed, 5 Feb 2020 20:23:53 -0500 Subject: fixed LogModel not being thread safe optimizations: - create BrowserDialog on demand - scroll to bottom of log in a timer, coalesces fast logging - disabled md5 of dlls --- src/loglist.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/loglist.cpp') diff --git a/src/loglist.cpp b/src/loglist.cpp index 5d6710c7..af0e6768 100644 --- a/src/loglist.cpp +++ b/src/loglist.cpp @@ -27,7 +27,6 @@ const std::size_t MaxLines = 1000; LogModel::LogModel() { - connect(this, &LogModel::entryAdded, [&](auto&& e){ onEntryAdded(e); }); } void LogModel::create() @@ -42,7 +41,8 @@ LogModel& LogModel::instance() void LogModel::add(MOBase::log::Entry e) { - emit entryAdded(std::move(e)); + QMetaObject::invokeMethod( + this, [this, e]{ onEntryAdded(std::move(e)); }, Qt::QueuedConnection); } void LogModel::clear() @@ -173,13 +173,16 @@ LogList::LogList(QWidget* parent) this, &QWidget::customContextMenuRequested, [&](auto&& pos){ onContextMenu(pos); }); - connect( - model(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(scrollToBottom())); + connect(model(), &LogModel::rowsInserted, [&]{ onNewEntry(); }); + connect(model(), &LogModel::dataChanged, [&]{ onNewEntry(); }); - connect( - model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(scrollToBottom())); + m_timer.setSingleShot(true); + connect(&m_timer, &QTimer::timeout, [&]{ scrollToBottom(); }); +} + +void LogList::onNewEntry() +{ + m_timer.start(std::chrono::milliseconds(10)); } void LogList::setCore(OrganizerCore& core) -- cgit v1.3.1