From 83fc4f7338bcaaadede8beff55313e50a92914d2 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 16 Aug 2021 21:33:15 +0200 Subject: [PATCH] COMMON: Persist global debug channels between engine runs --- common/debug-channels.h | 1 + common/debug.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/common/debug-channels.h b/common/debug-channels.h index 151c3242b9c..b3f1e6ceca9 100644 --- a/common/debug-channels.h +++ b/common/debug-channels.h @@ -157,6 +157,7 @@ private: DebugChannelMap _debugChannels; uint32 _debugChannelsEnabled; + uint32 _globalChannelsMask; friend class Singleton; diff --git a/common/debug.cpp b/common/debug.cpp index 2b76fd52cea..86593f1856e 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -54,6 +54,12 @@ struct DebugLevelComperator { DebugManager::DebugManager() : _debugChannelsEnabled(0) { addDebugChannels(gDebugChannels); + + // Create global debug channels mask + _globalChannelsMask = 0; + for (uint i = 0; gDebugChannels[i].channel != 0; ++i) { + _globalChannelsMask |= gDebugChannels[i].channel; + } } bool DebugManager::addDebugChannel(uint32 channel, const String &name, const String &description) { @@ -83,9 +89,12 @@ void DebugManager::addAllDebugChannels(const DebugChannelDef *channels) { } void DebugManager::removeAllDebugChannels() { + uint32 globalChannels = _debugChannelsEnabled & _globalChannelsMask; _debugChannelsEnabled = 0; _debugChannels.clear(); addDebugChannels(gDebugChannels); + + _debugChannelsEnabled |= globalChannels; } bool DebugManager::enableDebugChannel(const String &name) {