diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2024-01-30 23:15:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-30 23:15:34 +0100 |
commit | 7ebdc14a107b23d1255011a7730e1d8463ac9c67 (patch) | |
tree | 24cb1a195004f94fdb17b4e29436cb3ab3c33efa | |
parent | 2f46eb59b02b837367c0e02aba7097673d2f3bbd (diff) | |
parent | 6ad955ae0aab8b79910cb4a12777419a78a42a90 (diff) | |
download | NorthstarLauncher-feat/update-for-new-verified-json.tar.gz NorthstarLauncher-feat/update-for-new-verified-json.zip |
Merge branch 'main' into feat/update-for-new-verified-jsonfeat/update-for-new-verified-json
-rw-r--r-- | primedev/mods/modmanager.cpp | 1 | ||||
-rw-r--r-- | primedev/util/utils.h | 12 |
2 files changed, 7 insertions, 6 deletions
diff --git a/primedev/mods/modmanager.cpp b/primedev/mods/modmanager.cpp index 8a0eb71d..e1077922 100644 --- a/primedev/mods/modmanager.cpp +++ b/primedev/mods/modmanager.cpp @@ -771,7 +771,6 @@ void ModManager::LoadMods() // make sure command isnt't registered multiple times. if (!g_pCVar->FindCommand(command->Name.c_str())) { - ConCommand* newCommand = new ConCommand(); std::string funcName = command->Function; RegisterConCommand(command->Name.c_str(), ModConCommandCallback, command->HelpString.c_str(), command->Flags); } diff --git a/primedev/util/utils.h b/primedev/util/utils.h index 1a419607..c8cbc7e8 100644 --- a/primedev/util/utils.h +++ b/primedev/util/utils.h @@ -2,22 +2,24 @@ void RemoveAsciiControlSequences(char* str, bool allow_color_codes); -class ScopeGuard +template <typename T> class ScopeGuard { public: auto operator=(ScopeGuard&) = delete; ScopeGuard(ScopeGuard&) = delete; - ScopeGuard(std::function<void()> callback) : m_callback(callback) {} + ScopeGuard(T callback) : m_callback(callback) {} ~ScopeGuard() { - m_callback(); + if (!m_dismissed) + m_callback(); } void Dismiss() { - m_callback = [] {}; + m_dismissed = true; } private: - std::function<void()> m_callback; + bool m_dismissed = false; + T m_callback; }; |