[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()
|
||||
|
||||
def later():
|
||||
if (
|
||||
"lock_depsgraph_update_ntimes" not in scene.abc3d_data
|
||||
or scene.abc3d_data["lock_depsgraph_update_ntimes"] <= 0
|
||||
):
|
||||
if butils.lock_depsgraph_update_n_times <= 0:
|
||||
butils.set_text_on_curve(
|
||||
scene.abc3d_data.available_texts[linked_textobject]
|
||||
)
|
||||
elif scene.abc3d_data["lock_depsgraph_update_ntimes"] > 0:
|
||||
scene.abc3d_data["lock_depsgraph_update_ntimes"] -= 1
|
||||
elif butils.lock_depsgraph_update_n_times <= 0:
|
||||
butils.lock_depsgraph_update_n_times -= 1
|
||||
|
||||
butils.run_in_main_thread(later)
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ else:
|
|||
from .common import utils
|
||||
|
||||
execution_queue = queue.Queue()
|
||||
lock_depsgraph_update_n_times = -1
|
||||
|
||||
|
||||
# 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
|
||||
"""
|
||||
|
||||
global lock_depsgraph_update_n_times
|
||||
|
||||
# starttime = time.perf_counter_ns()
|
||||
mom = text_properties.text_object
|
||||
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()}_translation"] = text_properties.translation
|
||||
|
||||
if "lock_depsgraph_update_ntimes" in bpy.context.scene.abc3d_data:
|
||||
bpy.context.scene.abc3d_data["lock_depsgraph_update_ntimes"] += len(
|
||||
if lock_depsgraph_update_n_times < 0:
|
||||
lock_depsgraph_update_n_times = len(
|
||||
bpy.context.selected_objects
|
||||
)
|
||||
else:
|
||||
bpy.context.scene.abc3d_data["lock_depsgraph_update_ntimes"] = len(
|
||||
lock_depsgraph_update_n_times += len(
|
||||
bpy.context.selected_objects
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue