From 511226367d26de6eb36b9c5f9e89f41092ca9587 Mon Sep 17 00:00:00 2001
From: Tazpn <tazpn@users.sourceforge.net>
Date: Tue, 11 Sep 2007 02:14:30 +0000
Subject: [PATCH] Fix but with SetCollisionObject which does not allow setting
 the value to nothing.

---
 src/obj/NiAVObject.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/obj/NiAVObject.cpp b/src/obj/NiAVObject.cpp
index d83a7be9..46eecff6 100644
--- a/src/obj/NiAVObject.cpp
+++ b/src/obj/NiAVObject.cpp
@@ -338,10 +338,12 @@ Ref<NiCollisionObject > NiAVObject::GetCollisionObject() const {
 }
 
 void NiAVObject::SetCollisionObject( NiCollisionObject * value ) {
-	if ( value->GetTarget() != NULL ) {
-		throw runtime_error( "You have attempted to add a collision object to a NiAVObject which is already attached to another NiAVObject." );
+	if ( value != NULL ) {
+		if ( value->GetTarget() != NULL ) {
+			throw runtime_error( "You have attempted to add a collision object to a NiAVObject which is already attached to another NiAVObject." );
+		}
+		value->SetTarget( this );
 	}
-	value->SetTarget( this );
 
 	if ( collisionObject !=NULL ) {
 		//Remove unlink previous collision object from this node
-- 
GitLab