diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index be0248dff7..a5870f87c3 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -60,7 +60,9 @@ namespace Reporting // Temporarily stores a reference to the hostname. static std::string lastHostname; // Keeps track of report-only-once identifiers. Since they're always constants, a pointer is okay. - static std::map logOnceUsed; + static std::map logNTimes; + static std::mutex logNTimesLock; + // Keeps track of whether a harmful setting was ever used. static bool everUnsupported = false; // Support is cached here to avoid checking it on every single request. @@ -303,7 +305,7 @@ namespace Reporting { // New game, clean slate. spamProtectionCount = 0; - logOnceUsed.clear(); + logNTimes.clear(); everUnsupported = false; currentSupported = IsSupported(); pendingMessagesDone = false; @@ -347,9 +349,10 @@ namespace Reporting bool ShouldLogNTimes(const char *identifier, int count) { // True if it wasn't there already -> so yes, log. - auto iter = logOnceUsed.find(identifier); - if (iter == logOnceUsed.end()) { - logOnceUsed.insert(std::pair(identifier, 1)); + std::lock_guard lock(logNTimesLock); + auto iter = logNTimes.find(identifier); + if (iter == logNTimes.end()) { + logNTimes.insert(std::pair(identifier, 1)); return true; } else { if (iter->second >= count) { @@ -361,6 +364,11 @@ namespace Reporting } } + void ResetCounts() { + std::lock_guard lock(logNTimesLock); + logNTimes.clear(); + } + std::string CurrentGameID() { // TODO: Maybe ParamSFOData shouldn't include nulls in std::strings? Don't work to break savedata, though... diff --git a/Core/Reporting.h b/Core/Reporting.h index 1d168cb88c..50b24f93c8 100644 --- a/Core/Reporting.h +++ b/Core/Reporting.h @@ -53,6 +53,9 @@ namespace Reporting void Init(); void Shutdown(); + // Resets counts on any count-limited logs (see ShouldLogNTimes). + void ResetCounts(); + // Check savestate compatibility, mostly needed on load. void DoState(PointerWrap &p); diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index e133c89bac..79be85c785 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -18,6 +18,7 @@ #include #include "ppsspp_config.h" + #include "Common/System/Display.h" #include "Common/System/NativeApp.h" #include "Common/System/System.h" @@ -37,6 +38,7 @@ #include "Core/Config.h" #include "Core/ConfigValues.h" #include "Core/System.h" +#include "Core/Reporting.h" #include "Core/CoreParameter.h" #include "Core/MIPS/MIPSTables.h" #include "Core/MIPS/JitCommon/JitBlockCache.h" @@ -90,6 +92,7 @@ void DevMenu::CreatePopupContents(UI::ViewGroup *parent) { items->Add(new CheckBox(&g_Config.bShowFrameProfiler, dev->T("Frame Profiler"), "")); #endif items->Add(new CheckBox(&g_Config.bDrawFrameGraph, dev->T("Draw Frametimes Graph"))); + items->Add(new Choice(dev->T("Reset limited logging")))->OnClick.Handle(this, &DevMenu::OnResetLimitedLogging); scroll->Add(items); parent->Add(scroll); @@ -105,6 +108,10 @@ UI::EventReturn DevMenu::OnToggleAudioDebug(UI::EventParams &e) { return UI::EVENT_DONE; } +UI::EventReturn DevMenu::OnResetLimitedLogging(UI::EventParams &e) { + Reporting::ResetCounts(); + return UI::EVENT_DONE; +} UI::EventReturn DevMenu::OnLogView(UI::EventParams &e) { UpdateUIState(UISTATE_PAUSEMENU); diff --git a/UI/DevScreens.h b/UI/DevScreens.h index 28e8c38bda..b97f08574b 100644 --- a/UI/DevScreens.h +++ b/UI/DevScreens.h @@ -45,6 +45,7 @@ protected: UI::EventReturn OnDumpFrame(UI::EventParams &e); UI::EventReturn OnDeveloperTools(UI::EventParams &e); UI::EventReturn OnToggleAudioDebug(UI::EventParams &e); + UI::EventReturn OnResetLimitedLogging(UI::EventParams &e); }; class JitDebugScreen : public UIDialogScreenWithBackground {