svn merge -r 16396:16411 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / gameengine / Converter / KX_BlenderSceneConverter.cpp
index e246e49af3f1a726d6725154eeb791fa13696bd3..2ce325326a888c5eb2e2141e64c788ad1387fdf9 100644 (file)
@@ -501,7 +501,17 @@ void KX_BlenderSceneConverter::RegisterGameObject(
 void KX_BlenderSceneConverter::UnregisterGameObject(
                                                                        KX_GameObject *gameobject) 
 {
-       m_map_gameobject_to_blender.remove(CHashedPtr(gameobject));
+       CHashedPtr gptr(gameobject);
+       struct Object **bobp= m_map_gameobject_to_blender[gptr];
+       if (bobp) {
+               CHashedPtr bptr(*bobp);
+               KX_GameObject **gobp= m_map_blender_to_gameobject[bptr];
+               if (gobp && *gobp == gameobject)
+                       // also maintain m_map_blender_to_gameobject if the gameobject
+                       // being removed is matching the blender object
+                       m_map_blender_to_gameobject.remove(bptr);
+               m_map_gameobject_to_blender.remove(gptr);
+       }
 }