Correctly stop live patching after player terminates

This commit is contained in:
Moritz Brückner 2021-06-27 22:35:37 +02:00
parent 088bc0f666
commit 441f42383e
2 changed files with 9 additions and 1 deletions

View file

@ -19,6 +19,7 @@ msgbus_owner = object()
def start():
"""Start the live patch session."""
log.debug("Live patch session started")
listen(bpy.types.Object, "location", "obj_location")
@ -32,6 +33,12 @@ def start():
listen(light_type, "energy", "light_energy")
def stop():
"""Stop the live patch session."""
log.debug("Live patch session stopped")
bpy.msgbus.clear_by_owner(msgbus_owner)
def patch_export():
"""Re-export the current scene and update the game accordingly."""
if state.proc_build is not None:
@ -68,7 +75,6 @@ def patch_done():
js = 'iron.Scene.patch();'
write_patch(js)
state.proc_build = None
bpy.msgbus.clear_by_owner(msgbus_owner)
def write_patch(js: str):

View file

@ -398,9 +398,11 @@ def build(target, is_play=False, is_publish=False, is_export=False):
shutil.copy(fn, arm.utils.build_dir() + dest + os.path.basename(fn))
def play_done():
"""Called if the player was stopped/terminated."""
state.proc_play = None
state.redraw_ui = True
log.clear()
live_patch.stop()
def assets_done():
if state.proc_build == None: