From b8677f650b1c0d34243fd1714d340e49fd4897ac Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 15 Mar 2021 16:04:58 +0100 Subject: [PATCH] Supply event processing from log events also if an abstract progress is used --- src/lay/lay/layLogViewerDialog.cc | 47 +++++++++++++++++++++---------- src/lay/lay/layLogViewerDialog.h | 2 ++ 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/lay/lay/layLogViewerDialog.cc b/src/lay/lay/layLogViewerDialog.cc index b3604b652..e99c9e126 100644 --- a/src/lay/lay/layLogViewerDialog.cc +++ b/src/lay/lay/layLogViewerDialog.cc @@ -22,12 +22,15 @@ #include "layLogViewerDialog.h" +#include "layApplication.h" #include #include #include #include #include +#include +#include #include @@ -221,25 +224,39 @@ LogFile::max_entries () const void LogFile::add (LogFileEntry::mode_type mode, const std::string &msg, bool continued) { - QMutexLocker locker (&m_lock); + bool can_yield = false; - if (m_max_entries == 0) { - return; + { + QMutexLocker locker (&m_lock); + + if (m_max_entries == 0) { + return; + } + + if (m_messages.size () >= m_max_entries) { + m_messages.pop_front (); + } + + if (mode == LogFileEntry::Warning || mode == LogFileEntry::WarningContinued) { + m_has_warnings = true; + } else if (mode == LogFileEntry::Error || mode == LogFileEntry::ErrorContinued) { + m_has_errors = true; + } + + m_messages.push_back (LogFileEntry (mode, msg, continued)); + + ++m_generation_id; + + if (QThread::currentThread ()->eventDispatcher () && (tl::Clock::current () - m_last_yield).seconds () > 0.1) { + m_last_yield = tl::Clock::current (); + can_yield = true; + } } - if (m_messages.size () >= m_max_entries) { - m_messages.pop_front (); + // use this opportunity to process events + if (can_yield) { + QThread::currentThread ()->eventDispatcher ()->processEvents (QEventLoop::AllEvents); } - - if (mode == LogFileEntry::Warning || mode == LogFileEntry::WarningContinued) { - m_has_warnings = true; - } else if (mode == LogFileEntry::Error || mode == LogFileEntry::ErrorContinued) { - m_has_errors = true; - } - - m_messages.push_back (LogFileEntry (mode, msg, continued)); - - ++m_generation_id; } int diff --git a/src/lay/lay/layLogViewerDialog.h b/src/lay/lay/layLogViewerDialog.h index c9da714a3..340b28ed0 100644 --- a/src/lay/lay/layLogViewerDialog.h +++ b/src/lay/lay/layLogViewerDialog.h @@ -26,6 +26,7 @@ #include "ui_LogViewerDialog.h" #include "tlLog.h" +#include "tlTimer.h" #include "layCommon.h" #include @@ -227,6 +228,7 @@ private: size_t m_last_generation_id; bool m_has_errors, m_has_warnings; bool m_last_attn; + tl::Clock m_last_yield; /** * @brief Adds an error