diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-05 20:23:53 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-05 20:23:53 -0500 |
| commit | 03ee407c346845484629c2a6afef39a13f0b9a3d (patch) | |
| tree | 1057bbbefcfa0cf1518c97b3695dcf0f2f60fd9b /src/loglist.cpp | |
| parent | ea0429342ade6e908807ff1faef7c8f7e5e46b75 (diff) | |
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
Diffstat (limited to 'src/loglist.cpp')
| -rw-r--r-- | src/loglist.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
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)
|
