[fix] scene variable to global
this prevents failure of access in case the scene is refreshed by blender
This commit is contained in:
parent
f41808adc3
commit
9276ad4fac
2 changed files with 9 additions and 9 deletions
|
@ -1652,15 +1652,12 @@ def on_depsgraph_update(scene, depsgraph):
|
||||||
lock_depsgraph_updates()
|
lock_depsgraph_updates()
|
||||||
|
|
||||||
def later():
|
def later():
|
||||||
if (
|
if butils.lock_depsgraph_update_n_times <= 0:
|
||||||
"lock_depsgraph_update_ntimes" not in scene.abc3d_data
|
|
||||||
or scene.abc3d_data["lock_depsgraph_update_ntimes"] <= 0
|
|
||||||
):
|
|
||||||
butils.set_text_on_curve(
|
butils.set_text_on_curve(
|
||||||
scene.abc3d_data.available_texts[linked_textobject]
|
scene.abc3d_data.available_texts[linked_textobject]
|
||||||
)
|
)
|
||||||
elif scene.abc3d_data["lock_depsgraph_update_ntimes"] > 0:
|
elif butils.lock_depsgraph_update_n_times <= 0:
|
||||||
scene.abc3d_data["lock_depsgraph_update_ntimes"] -= 1
|
butils.lock_depsgraph_update_n_times -= 1
|
||||||
|
|
||||||
butils.run_in_main_thread(later)
|
butils.run_in_main_thread(later)
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ else:
|
||||||
from .common import utils
|
from .common import utils
|
||||||
|
|
||||||
execution_queue = queue.Queue()
|
execution_queue = queue.Queue()
|
||||||
|
lock_depsgraph_update_n_times = -1
|
||||||
|
|
||||||
|
|
||||||
# This function can safely be called in another thread.
|
# This function can safely be called in another thread.
|
||||||
|
@ -811,6 +812,8 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4)
|
||||||
:type reset_depsgraph_n: int
|
:type reset_depsgraph_n: int
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
global lock_depsgraph_update_n_times
|
||||||
|
|
||||||
# starttime = time.perf_counter_ns()
|
# starttime = time.perf_counter_ns()
|
||||||
mom = text_properties.text_object
|
mom = text_properties.text_object
|
||||||
if mom.type != "CURVE":
|
if mom.type != "CURVE":
|
||||||
|
@ -1040,12 +1043,12 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4)
|
||||||
mom[f"{utils.prefix()}_orientation"] = text_properties.orientation
|
mom[f"{utils.prefix()}_orientation"] = text_properties.orientation
|
||||||
mom[f"{utils.prefix()}_translation"] = text_properties.translation
|
mom[f"{utils.prefix()}_translation"] = text_properties.translation
|
||||||
|
|
||||||
if "lock_depsgraph_update_ntimes" in bpy.context.scene.abc3d_data:
|
if lock_depsgraph_update_n_times < 0:
|
||||||
bpy.context.scene.abc3d_data["lock_depsgraph_update_ntimes"] += len(
|
lock_depsgraph_update_n_times = len(
|
||||||
bpy.context.selected_objects
|
bpy.context.selected_objects
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
bpy.context.scene.abc3d_data["lock_depsgraph_update_ntimes"] = len(
|
lock_depsgraph_update_n_times += len(
|
||||||
bpy.context.selected_objects
|
bpy.context.selected_objects
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue