1
0
forked from mirrors/0ad

Don't use std::shared_ptr to store m_ScriptContext and m_ScriptInterface in the CGUIManager

`std::shared_ptr` is intrusive. When a function expects a
`std::shared_ptr` the caller has to use it too and can't store the
element on the stack for example.

Comments by: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5221
This was SVN commit r28131.
This commit is contained in:
phosit
2024-06-27 19:09:30 +00:00
parent 75753abd2e
commit 4bcbc72274
12 changed files with 67 additions and 56 deletions
+5 -1
View File
@@ -678,9 +678,12 @@ static void RunGameOrAtlas(const PS::span<const char* const> argv)
g_Mods.UpdateAvailableMods(modInterface);
}
std::optional<ScriptInterface> guiScriptInterface;
if (isVisual)
{
InitGraphics(args, 0, installedMods);
guiScriptInterface.emplace("Engine", "gui", *g_ScriptContext);
InitGraphics(args, 0, installedMods, *g_ScriptContext, *guiScriptInterface);
MainControllerInit();
}
else if (!InitNonVisual(args))
@@ -709,6 +712,7 @@ static void RunGameOrAtlas(const PS::span<const char* const> argv)
modsToInstall.clear();
ShutdownNetworkAndUI();
guiScriptInterface.reset();
ShutdownConfigAndSubsequent();
MainControllerShutdown();
flags &= ~INIT_MODS;