[Bf-blender-cvs] [607dca0] master: BGE: Fix T44069 playing action during libfree.

Porteries Tristan noreply at git.blender.org
Wed Jul 1 16:51:58 CEST 2015


Commit: 607dca070587f4d8bc4afa3c4a49e0f9a74873cd
Author: Porteries Tristan
Date:   Wed Jul 1 16:38:31 2015 +0200
Branches: master
https://developer.blender.org/rB607dca070587f4d8bc4afa3c4a49e0f9a74873cd

BGE: Fix T44069 playing action during libfree.

===================================================================

M	source/gameengine/Converter/KX_BlenderSceneConverter.cpp
M	source/gameengine/Ketsji/BL_ActionManager.cpp
M	source/gameengine/Ketsji/BL_ActionManager.h
M	source/gameengine/Ketsji/KX_GameObject.cpp
M	source/gameengine/Ketsji/KX_GameObject.h

===================================================================

diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 9e53d9e..28de61f 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -1082,6 +1082,7 @@ bool KX_BlenderSceneConverter::FreeBlendFile(Main *maggie)
 					if (IS_TAGGED(action)) {
 						STR_HashedString an = action->name + 2;
 						mapStringToActions.remove(an);
+						m_map_blender_to_gameAdtList.remove(CHashedPtr(action));
 						i--;
 					}
 				}
@@ -1110,6 +1111,7 @@ bool KX_BlenderSceneConverter::FreeBlendFile(Main *maggie)
 						}
 					}
 					else {
+						gameobj->RemoveTaggedActions();
 						/* free the mesh, we could be referecing a linked one! */
 						int mesh_index = gameobj->GetMeshCount();
 						while (mesh_index--) {
diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp
index c3d0f9e..975f9ea 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.cpp
+++ b/source/gameengine/Ketsji/BL_ActionManager.cpp
@@ -26,6 +26,9 @@
 
 #include "BL_Action.h"
 #include "BL_ActionManager.h"
+#include "DNA_ID.h"
+
+#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->flag & LIB_DOIT))
 
 BL_ActionManager::BL_ActionManager(class KX_GameObject *obj):
 	m_obj(obj),
@@ -123,6 +126,18 @@ void BL_ActionManager::StopAction(short layer)
 	if (action) action->Stop();
 }
 
+void BL_ActionManager::RemoveTaggedActions()
+{
+	for (BL_ActionMap::iterator it = m_layers.begin(); it != m_layers.end();) {
+		if (IS_TAGGED(it->second->GetAction())) {
+			delete it->second;
+			m_layers.erase(it++);
+		}
+		else
+			++it;
+	}
+}
+
 bool BL_ActionManager::IsActionDone(short layer)
 {
 	BL_Action *action = GetAction(layer);
diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h
index 45bcd10..00e5366 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.h
+++ b/source/gameengine/Ketsji/BL_ActionManager.h
@@ -110,6 +110,11 @@ public:
 	void StopAction(short layer);
 
 	/**
+	 * Remove playing tagged actions.
+	 */
+	void RemoveTaggedActions();
+
+	/**
 	 * Check if an action has finished playing
 	 */
 	bool IsActionDone(short layer);
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 5701d0e..d98669c 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -469,6 +469,11 @@ void KX_GameObject::StopAction(short layer)
 	GetActionManager()->StopAction(layer);
 }
 
+void KX_GameObject::RemoveTaggedActions()
+{
+	GetActionManager()->RemoveTaggedActions();
+}
+
 bool KX_GameObject::IsActionDone(short layer)
 {
 	return GetActionManager()->IsActionDone(layer);
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index 670fcd6..3639d73 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -302,6 +302,11 @@ public:
 	void StopAction(short layer);
 
 	/**
+	 * Remove playing tagged actions.
+	 */
+	void RemoveTaggedActions();
+
+	/**
 	 * Check if an action has finished playing
 	 */
 	bool IsActionDone(short layer);




More information about the Bf-blender-cvs mailing list