| 232 | void ClearServices(); |
| 233 | |
| 234 | void PClass::StaticShutdown () |
| 235 | { |
| 236 | if (WP_NOCHANGE != nullptr) |
| 237 | { |
| 238 | delete WP_NOCHANGE; |
| 239 | } |
| 240 | |
| 241 | ClearServices(); |
| 242 | // delete all variables containing pointers to script functions. |
| 243 | for (auto p : FunctionPtrList) |
| 244 | { |
| 245 | *p = nullptr; |
| 246 | } |
| 247 | FunctionPtrList.Clear(); |
| 248 | VMFunction::DeleteAll(); |
| 249 | // From this point onward no scripts may be called anymore because the data needed by the VM is getting deleted now. |
| 250 | // This flags DObject::Destroy not to call any scripted OnDestroy methods anymore. |
| 251 | bVMOperational = false; |
| 252 | |
| 253 | // Make a full garbage collection here so that all destroyed but uncollected higher level objects |
| 254 | // that still exist are properly taken down before the low level data is deleted. |
| 255 | GC::FullGC(); |
| 256 | GC::FullGC(); |
| 257 | |
| 258 | |
| 259 | Namespaces.ReleaseSymbols(); |
| 260 | |
| 261 | // This must be done in two steps because the native classes are not ordered by inheritance, |
| 262 | // so all meta data must be gone before deleting the actual class objects. |
| 263 | for (auto cls : AllClasses) if (cls->Meta != nullptr) cls->DestroyMeta(cls->Meta); |
| 264 | for (auto cls : AllClasses) delete cls; |
| 265 | // Unless something went wrong, anything left here should be class and type objects only, which do not own any scripts. |
| 266 | bShutdown = true; |
| 267 | TypeTable.Clear(); |
| 268 | ClassDataAllocator.FreeAllBlocks(); |
| 269 | AllClasses.Clear(); |
| 270 | ClassMap.Clear(); |
| 271 | |
| 272 | AutoSegs::TypeInfos.ForEach([](ClassReg* typeInfo) |
| 273 | { |
| 274 | typeInfo->MyClass = nullptr; |
| 275 | }); |
| 276 | } |
| 277 | |
| 278 | //========================================================================== |
| 279 | // |
nothing calls this directly
no test coverage detected