From e83bab90d783a49ba6342418452c5f7668da1e60 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sun, 7 Jun 2026 22:10:52 +0100 Subject: [PATCH] fix for shape registration The automatic global static was hitting a destructor on xcode, this seemed like it was being pedantic about name at first but then between runs the same issue would come back. With this change it is wrapped in a function to get the vector instead. --- Engine/source/ts/loader/tsShapeLoader.cpp | 8 ++++---- Engine/source/ts/tsShape.cpp | 23 ++++++++++++++++------- Engine/source/ts/tsShape.h | 4 ++-- Engine/source/ts/tsShapeEdit.cpp | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Engine/source/ts/loader/tsShapeLoader.cpp b/Engine/source/ts/loader/tsShapeLoader.cpp index 10d54bfec..50ff9ec3e 100644 --- a/Engine/source/ts/loader/tsShapeLoader.cpp +++ b/Engine/source/ts/loader/tsShapeLoader.cpp @@ -1302,9 +1302,9 @@ String TSShapeLoader::getFormatExtensions() { // "*.dsq TAB *.dae TAB StringBuilder output; - for(U32 n = 0; n < TSShape::sRegistrations.size(); ++n) + for(U32 n = 0; n < TSShape::getShapeRegistrations().size(); ++n) { - TSShape::ShapeRegistration reg = TSShape::sRegistrations[n]; + TSShape::ShapeRegistration reg = TSShape::getShapeRegistrations()[n]; for (U32 i = 0; i < reg.extensions.size(); i++) { TSShape::ShapeFormat format = reg.extensions[i]; @@ -1320,9 +1320,9 @@ String TSShapeLoader::getFormatFilters() { // "DSQ Files|*.dsq|COLLADA Files|*.dae|" StringBuilder output; - for (U32 n = 0; n < TSShape::sRegistrations.size(); ++n) + for (U32 n = 0; n < TSShape::getShapeRegistrations().size(); ++n) { - TSShape::ShapeRegistration reg = TSShape::sRegistrations[n]; + TSShape::ShapeRegistration reg = TSShape::getShapeRegistrations()[n]; for (U32 i = 0; i < reg.extensions.size(); i++) { TSShape::ShapeFormat format = reg.extensions[i]; diff --git a/Engine/source/ts/tsShape.cpp b/Engine/source/ts/tsShape.cpp index dc218ad72..43e3b40fe 100644 --- a/Engine/source/ts/tsShape.cpp +++ b/Engine/source/ts/tsShape.cpp @@ -38,19 +38,28 @@ #include "core/stream/fileStream.h" #include "core/fileObject.h" -Vector TSShape::sRegistrations(__FILE__, __LINE__); +// Vector TSShape::sShapeRegistrations(__FILE__, __LINE__); + +Vector& TSShape::getShapeRegistrations() + { + static Vector* regs = + new Vector(__FILE__, __LINE__); + + return *regs; + } void TSShape::sRegisterFormat(const ShapeRegistration& reg) { - U32 insert = sRegistrations.size(); - sRegistrations.insert(insert, reg); + U32 insert = getShapeRegistrations().size(); + getShapeRegistrations().insert(insert, reg); } -const TSShape::ShapeRegistration* TSShape::sFindRegInfo(const String& extension, bool exporting) + +const TSShape::ShapeRegistration* TSShape::sFindShapeRegInfo(const String& extension, bool exporting) { - for (U32 i = 0; i < TSShape::sRegistrations.size(); i++) + for (U32 i = 0; i < getShapeRegistrations().size(); i++) { - const TSShape::ShapeRegistration& reg = TSShape::sRegistrations[i]; + const TSShape::ShapeRegistration& reg = getShapeRegistrations()[i]; const Vector& extensions = exporting ? reg.export_extensions : reg.extensions; for (U32 j = 0; j < extensions.size(); j++) @@ -2358,7 +2367,7 @@ template<> void *Resource::create(const Torque::Path &path) } else { - const TSShape::ShapeRegistration* regInfo = TSShape::sFindRegInfo(extension); + const TSShape::ShapeRegistration* regInfo = TSShape::sFindShapeRegInfo(extension); if (regInfo == NULL) { readSuccess = false; diff --git a/Engine/source/ts/tsShape.h b/Engine/source/ts/tsShape.h index 733a36008..03e7c842a 100644 --- a/Engine/source/ts/tsShape.h +++ b/Engine/source/ts/tsShape.h @@ -122,8 +122,8 @@ public: }; static void sRegisterFormat(const ShapeRegistration& reg); - static const ShapeRegistration* sFindRegInfo(const String& extension, bool exporting = false); - static Vector sRegistrations; + static const ShapeRegistration* sFindShapeRegInfo(const String& extension, bool exporting = false); + static Vector& getShapeRegistrations(); /// Nodes hold the transforms in the shape's tree. They are the bones of the skeleton. struct Node diff --git a/Engine/source/ts/tsShapeEdit.cpp b/Engine/source/ts/tsShapeEdit.cpp index 042fb130f..e44a3be2e 100644 --- a/Engine/source/ts/tsShapeEdit.cpp +++ b/Engine/source/ts/tsShapeEdit.cpp @@ -1361,7 +1361,7 @@ bool TSShape::isShapeFileType(Torque::Path filePath) { String fileExt = filePath.getExtension(); - if (TSShape::sFindRegInfo(fileExt)) + if (TSShape::sFindShapeRegInfo(fileExt)) return true; return false;