Forráskód Böngészése

Replacing JPH_CRASH with std::abort (#881)

See: https://x.com/frustum/status/1743550411288825915?s=20
Jorrit Rouwe 1 éve
szülő
commit
f5c3cc1f03

+ 0 - 3
Jolt/Core/Core.h

@@ -352,9 +352,6 @@
 	#error Unknown platform
 #endif
 
-// Crashes the application
-#define JPH_CRASH				do { int *ptr = nullptr; *ptr = 0; } while (false)
-
 // Begin the JPH namespace
 #define JPH_NAMESPACE_BEGIN																		\
 	JPH_SUPPRESS_WARNING_PUSH																	\

+ 8 - 2
Jolt/Core/TempAllocator.h

@@ -58,7 +58,10 @@ public:
 		{
 			uint new_top = mTop + AlignUp(inSize, JPH_RVECTOR_ALIGNMENT);
 			if (new_top > mSize)
-				JPH_CRASH; // Out of memory
+			{
+				Trace("TempAllocator: Out of memory");
+				std::abort();
+			}
 			void *address = mBase + mTop;
 			mTop = new_top;
 			return address;
@@ -76,7 +79,10 @@ public:
 		{
 			mTop -= AlignUp(inSize, JPH_RVECTOR_ALIGNMENT);
 			if (mBase + mTop != inAddress)
-				JPH_CRASH; // Freeing in the wrong order
+			{
+				Trace("TempAllocator: Freeing in the wrong order");
+				std::abort();
+			}
 		}
 	}
 

+ 1 - 1
Jolt/Physics/Collision/BroadPhase/QuadTree.cpp

@@ -190,7 +190,7 @@ uint32 QuadTree::AllocateNode(bool inIsChanged)
 	if (index == Allocator::cInvalidObjectIndex)
 	{
 		Trace("QuadTree: Out of nodes!");
-		JPH_CRASH;
+		std::abort();
 	}
 	return index;
 }

+ 0 - 1
Jolt/Physics/Collision/Shape/MeshShape.cpp

@@ -235,7 +235,6 @@ void MeshShape::sFindActiveEdges(const MeshShapeSettings &inSettings, IndexedTri
 			}
 
 			JPH_ASSERT(false);
-			JPH_CRASH;
 			return ~uint(0);
 		}
 

+ 2 - 2
Jolt/RegisterTypes.cpp

@@ -80,8 +80,8 @@ void RegisterTypesInternal(uint64 inVersionID)
 	// Version check
 	if (!VerifyJoltVersionIDInternal(inVersionID))
 	{
-		JPH_ASSERT(false, "Version mismatch, make sure you compile the client code with the same Jolt version and compiler definitions!");
-		JPH_CRASH;
+		Trace("Version mismatch, make sure you compile the client code with the same Jolt version and compiler definitions!");
+		std::abort();
 	}
 
 #ifndef JPH_DISABLE_CUSTOM_ALLOCATOR