fix rendering crashes

1) introduce can_regenerate so we only regenerate when necessary
2) no notifications of missing glyphs when rendering
3) use frame_change_pre instead of post
This commit is contained in:
jrkb 2025-05-20 19:24:43 +02:00
parent 2422d0cf09
commit 7ebe913e49
2 changed files with 18 additions and 17 deletions

View file

@ -777,7 +777,7 @@ def is_bezier(curve):
return True
def will_regenerate(text_properties):
def would_regenerate(text_properties):
mom = text_properties.text_object
if len(text_properties.text) != len(text_properties.glyphs):
@ -843,7 +843,7 @@ def parent_to_curve(o, c):
p = cm.vertices[0].co
o.matrix_parent_inverse.translation = p * -1.0
def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4):
def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4, can_regenerate=False):
"""set_text_on_curve
An earlier reset cancels the other.
@ -879,7 +879,7 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4)
# elif distribution_type == "FOLLOW_PATH":
# mom.data.use_path = True
regenerate = will_regenerate(text_properties)
regenerate = can_regenerate and would_regenerate(text_properties)
# if we regenerate.... delete objects
if regenerate and text_properties.get("glyphs"):
@ -954,12 +954,13 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4)
message = message + f" (replaced with '{possible_replacement}')"
replaced = True
ShowMessageBox(
title="Glyph replaced" if replaced else "Glyph missing",
icon="INFO" if replaced else "ERROR",
message=message,
prevent_repeat=True,
)
if can_regenerate:
ShowMessageBox(
title="Glyph replaced" if replaced else "Glyph missing",
icon="INFO" if replaced else "ERROR",
message=message,
prevent_repeat=True,
)
if not replaced:
continue
@ -997,6 +998,7 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4)
inner_node.parent = outer_node
inner_node.matrix_parent_inverse = outer_node.matrix_world.inverted()
parent_to_curve(outer_node, mom)
outer_node.hide_set(True)
glyph_properties["glyph_object"] = outer_node
else:
@ -1079,7 +1081,6 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4)
inner_node.rotation_mode = previous_inner_node_rotation_mode
# outer_node.hide_viewport = True
outer_node.hide_set(True)
############### PREPARE FOR THE NEXT