BGE: Fix T44069 playing action during libfree.
This commit is contained in:
parent
d3709f4e79
commit
607dca0705
Notes:
blender-bot
2023-02-14 11:42:40 +01:00
Referenced by issue #44069, Calling LibLoad and LibFree multiple times on a file that plays an Action crashes Blender
|
@ -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--) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -109,6 +109,11 @@ public:
|
|||
*/
|
||||
void StopAction(short layer);
|
||||
|
||||
/**
|
||||
* Remove playing tagged actions.
|
||||
*/
|
||||
void RemoveTaggedActions();
|
||||
|
||||
/**
|
||||
* Check if an action has finished playing
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -301,6 +301,11 @@ public:
|
|||
*/
|
||||
void StopAction(short layer);
|
||||
|
||||
/**
|
||||
* Remove playing tagged actions.
|
||||
*/
|
||||
void RemoveTaggedActions();
|
||||
|
||||
/**
|
||||
* Check if an action has finished playing
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue