Revert "types: Remove unfilterable debug output"
TypeSystem::registerTypeClassInternal()
is called in the constructor and
TypeSystem::unregisterTypeClassInternal()
- in the destructor of each
global-variable object declared via the REGISTER_TYPE macro.
registerTypeClassInternal()
does not log any messages, therefore these
global variables are constructed before the function-local static
QLoggingCategory
constant LANGUAGE
. So the global variables are
destroyed after LANGUAGE
(in the reverse order of the completion of
constructors). unregisterTypeClassInternal()
attempts to log a message
via qCDebug(LANGUAGE)
when the function-local LANGUAGE
is already
destroyed. This is undefined behavior, which in practice causes the
following two issues:
- When KDevelop is started normally and
kdevplatform.language.debug=true
, the "Unregistering type class" messages lack the usual prefix "kdevplatform.language: ". - When KDevelop exits immediately without showing the UI (because of
a command-line option such as
--help
or--list-sessions
) andkdevplatform.language.debug=false
(the default), the disabled debug messages clutter the program output (curiously, they do start with the "kdevplatform.language: " prefix).
Log a matching "Registering type class" message via qCDebug(LANGUAGE)
in
registerTypeClassInternal()
to complete the constructor of LANGUAGE
before the constructors of global variables that use LANGUAGE
in their
destructors. This eliminates the undefined behavior and its two
practical consequences.
The reverted commit's message contains:
This is printed before Qt categorized logging is properly set up and thus may be printed even though it's technically disabled via filters.
I haven't encountered the referenced issue during my testing of this
commit. Perhaps the implementation of Qt categorized logging has
improved since then (2017) and is now reliably set up in time. If not
and the original issue resurfaces, the qCDebug(LANGUAGE)
line in
registerTypeClassInternal()
can be replaced with the line LANGUAGE();
,
which does not log anything but still initializes the function-local
static QLoggingCategory
constant.
This reverts commit a5eac48a.
BUG: 442896
FIXED-IN: 5.13.231200