SignalDumper: fix UB (data race on indentation level)
... by making it thread_local. As a natural (and welcome) side-effect, this makes output look sane in multithreaded scenarios. As for why it should be thread_local instead of an atomic: Since signal emissions and slot invocations on one thread are not necessarily correlated with another thread, they should not affect one another's indentation level. As in, emitting QIODevice::readyRead on a background thread should not make QEventLoop::aboutToBlock on the main thread be indented. The only exception to this is BlockingQueued, where one thread is directly tied to another (QTBUG-118145). But slot invocations are anyway not currently printed for Queued connection (see QTBUG-74099.) Pick-to: 6.6 6.5 Change-Id: Iea1fc522d37626df14af419a3455a732729edf74 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
6544a23603
commit
ae0d231c96
@ -24,7 +24,7 @@ inline static void qPrintMessage(const QByteArray &ba)
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC(QList<QByteArray>, ignoreClasses)
|
||||
static int iLevel = 0;
|
||||
Q_CONSTINIT thread_local int iLevel = 0;
|
||||
static int ignoreLevel = 0;
|
||||
enum { IndentSpacesCount = 4 };
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user