I have a script that uses globals that access eachother. In order to ensure proper order of initialization, i create the instance of the global that is accessed by other globals on demand:
namespace detail
{
CMultiScripts@ __MultiScripts = null;
}
/**
* Gets the global multi scripts manager.
*/
CMultiScripts@ get_MultiScripts()
{
if( detail::__MultiScripts is null )
{
@detail::__MultiScripts = CMultiScripts();
}
return @detail::__MultiScripts;
}
However, because i initialize it to null explicitly, the global is initialized to null after my globals have called get_MultiScripts, destroying the first instance.
If i remove the explicit assignment, everything works as expected.
I think this may be a bug, should the compiler remove explicit initialization to null with handles in this case?