Revert "chore(Debug/Scripting): improve debug errors during the unloading scripts (#19643)" (#19951)

This reverts commit db7183a573.

*wrongly use to catch sigsegv
*null check isn't necessary: https://en.cppreference.com/w/cpp/memory/new/operator_delete
This commit is contained in:
Grimdhex
2024-09-12 13:05:12 +02:00
committed by GitHub
parent 20b443e011
commit 4254827b2c

View File

@@ -30,24 +30,9 @@ namespace
template<typename T>
inline void SCR_CLEAR()
{
for (auto& [scriptID, script] : ScriptRegistry<T>::ScriptPointerList)
for (auto const& [scriptID, script] : ScriptRegistry<T>::ScriptPointerList)
{
try
{
if(script)
{
delete script;
script = nullptr;
}
}
catch (const std::exception& e)
{
LOG_ERROR("scripts.unloading", "Failed to unload script {} with ID: {}. Error: {}", script->GetName(), scriptID, e.what());
}
catch (...)
{
LOG_ERROR("scripts.unloading", "Failed to unload script {} with ID: {}. Unknown error occurred.", script->GetName(), scriptID);
}
delete script;
}
ScriptRegistry<T>::ScriptPointerList.clear();