Browse Source

Fix a race condition in ExportManager.add_object

Bad things would happen if you tried to access a modifier before its
owning SceneObject was created... Whoops!
pull/10/head
Adam Johnson 10 years ago
parent
commit
953012de38
  1. 26
      korman/exporter/manager.py

26
korman/exporter/manager.py

@ -91,21 +91,21 @@ class ExportManager:
elif pl.ClassIndex() in _pool_types: elif pl.ClassIndex() in _pool_types:
node.addPoolObject(pl.key) node.addPoolObject(pl.key)
if isinstance(pl, plObjInterface): if so is None and isinstance(pl, (plObjInterface, plModifier)):
if so is None: assert bl
key = self.find_key(plSceneObject, bl, name)
# prevent race conditions # Don't use find_create_object because we want to specify the location... Also, we're
if key is None: # in a modifier, so the name we're given might be for a modifier, not the SO
so = self.add_object(plSceneObject, name=name, loc=location) key = self.find_key(plSceneObject, bl)
key = so.key if key is None:
else: so = self.add_object(plSceneObject, bl=bl, loc=location)
so = key.object
pl.owner = key
else: else:
pl.owner = so.key so = key.object
if isinstance(pl, plObjInterface):
pl.owner = so.key
# The things I do to make life easy... # The things I do to make life easy... This is something of a God function now.
# This is something of a God function now.
if isinstance(pl, plAudioInterface): if isinstance(pl, plAudioInterface):
so.audio = pl.key so.audio = pl.key
elif isinstance(pl, plCoordinateInterface): elif isinstance(pl, plCoordinateInterface):

Loading…
Cancel
Save