Removed process_events from log output as this is the main reason of instability.

This commit is contained in:
Matthias Koefferlein 2021-05-12 22:47:18 +02:00
parent e7ae7338b4
commit 453ff7c7ad
2 changed files with 15 additions and 10 deletions

View File

@ -1491,16 +1491,15 @@ GuiApplication::process_events_impl (QEventLoop::ProcessEventsFlags flags, bool
return;
}
if (silent && tl::DeferredMethodScheduler::instance ()) {
tl::DeferredMethodScheduler::instance ()->enable (false);
if (silent) {
tl::DeferredMethodScheduler::enable (false);
}
#if QT_VERSION < 0x050000
QApplication::syncX ();
#endif
mp_mw->enter_busy_mode (true);
try {
#if QT_VERSION < 0x050000
QApplication::syncX ();
#endif
QApplication::processEvents (flags);
// Qt seems not to send posted UserEvents in some cases (e.g. in the unit test application with GLib?
// Glib not doing this without a main window visible?). Hence we do this explicitly here.
@ -1510,8 +1509,8 @@ GuiApplication::process_events_impl (QEventLoop::ProcessEventsFlags flags, bool
}
mp_mw->enter_busy_mode (false);
if (silent && tl::DeferredMethodScheduler::instance ()) {
tl::DeferredMethodScheduler::instance ()->enable (true);
if (silent) {
tl::DeferredMethodScheduler::enable (true);
}
}

View File

@ -254,6 +254,12 @@ 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;
{
@ -268,10 +274,10 @@ LogFile::yield ()
// 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.
// We accept the risk of recursion inside process_events as we have a timeout before accepting new yield calls.
if (can_yield) {
lay::ApplicationBase::instance ()->process_events (QEventLoop::AllEvents);
lay::ApplicationBase::instance ()->process_events (QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, true /*silent*/);
}
#endif
}
int