More frequent updates of in-window log.

This commit is contained in:
Matthias Koefferlein 2021-05-22 22:34:43 +02:00
parent 47e110115f
commit 726fe40e22
2 changed files with 5 additions and 28 deletions

View File

@ -120,9 +120,8 @@ LogFile::LogFile (size_t max_entries, bool register_global)
{
connect (&m_timer, SIGNAL (timeout ()), this, SLOT (timeout ()));
m_timer.setSingleShot (false);
m_timer.setInterval (100);
m_timer.start ();
m_timer.setSingleShot (true);
m_timer.setInterval (0);
if (register_global) {
tl::info.add (&m_info_receiver, false);
@ -253,30 +252,10 @@ LogFile::add (LogFileEntry::mode_type mode, const std::string &msg, bool continu
void
LogFile::yield ()
{
#if 0
// This looked like a good idea, but in fact it introduces a hell lot of instability
// as it potentially leads to a recursion of events inside innocent functions. Remember
// that log output may be generated from every function called in response of an event
// and not every such function may process further events
bool can_yield = false;
{
QMutexLocker locker (&m_lock);
if (lay::ApplicationBase::instance ()->qapp_gui () && QThread::currentThread () == lay::ApplicationBase::instance ()->qapp_gui ()->thread () && (tl::Clock::current () - m_last_yield).seconds () > 0.1) {
m_last_yield = tl::Clock::current ();
can_yield = true;
}
// will update on next processEvents
if (lay::ApplicationBase::instance ()->qapp_gui () && QThread::currentThread () == lay::ApplicationBase::instance ()->qapp_gui ()->thread ()) {
m_timer.start ();
}
// use this opportunity to process events
// NOTE: as process events may trigger further log output, it's necessary to do process events outside any other
// method (e.g. add) which is subject to locking. Hence we avoid deadlocks.
if (can_yield) {
lay::ApplicationBase::instance ()->process_events (QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, true /*silent*/);
}
#endif
}
int

View File

@ -26,7 +26,6 @@
#include "ui_LogViewerDialog.h"
#include "tlLog.h"
#include "tlTimer.h"
#include "layCommon.h"
#include <QTimer>
@ -233,7 +232,6 @@ 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