Selaa lähdekoodia

Merge pull request #948 from sgrenier/next

Fixed a bug in cleanup code for AIStateMachine.
Steve Grenier 12 vuotta sitten
vanhempi
sitoutus
c17f981fa1
1 muutettua tiedostoa jossa 12 lisäystä ja 1 poistoa
  1. 12 1
      gameplay/src/AIStateMachine.cpp

+ 12 - 1
gameplay/src/AIStateMachine.cpp

@@ -25,7 +25,18 @@ AIStateMachine::~AIStateMachine()
     {
         (*itr)->release();
     }
-    SAFE_RELEASE(AIState::_empty);
+
+    if (AIState::_empty)
+    {
+        if (AIState::_empty->getRefCount() == 1)
+        {
+            SAFE_RELEASE(AIState::_empty);
+        }
+        else
+        {
+            AIState::_empty->release();
+        }
+    }
 }
 
 AIAgent* AIStateMachine::getAgent() const