core: order destruction of singleton instances
Previously, the order of destructing singleton instances was undefined. Now, have singleton instances register their destruction via nm_singleton_instance_register(). Objects that are registered later, will be destructed earlier. IOW, they will be destroyed in reverse order of construction. This is only a crude method to get the lifetime of singleton instances right by default. Having singletons ref other singletons to keep them alive gives more control over the lifetimes of singletons. This change of having a defined order of destruction does not conflict with taking references to singletons (and thus extending their lifetime). Note that previously, NMPlatform was not registered for destruction. We don't change that yet and intenionally leak a reference.
Showing with 68 additions and 28 deletions