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. 20
      korman/exporter/manager.py

20
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
# in a modifier, so the name we're given might be for a modifier, not the SO
key = self.find_key(plSceneObject, bl)
if key is None: if key is None:
so = self.add_object(plSceneObject, name=name, loc=location) so = self.add_object(plSceneObject, bl=bl, loc=location)
key = so.key
else: else:
so = key.object so = key.object
pl.owner = key
else: if isinstance(pl, plObjInterface):
pl.owner = so.key 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