rm flashing windows
This commit is contained in:
parent
8ceec61e76
commit
c06fb29157
3 changed files with 9 additions and 62 deletions
|
|
@ -183,15 +183,10 @@ class SLICENODE_Executor(ExecSliceNode, SliceNodeJoiner):
|
|||
|
||||
def evaluate(self, operator=None):
|
||||
from ....infra.blender.blender_slice_nodes_generic import (
|
||||
node_execution_feedback,
|
||||
feedback_disabled,
|
||||
execution_cache,
|
||||
resolve_input
|
||||
)
|
||||
|
||||
# If auto_refresh is on, we don't want highlighting/redraws for upstream nodes either
|
||||
maybe_disabled = feedback_disabled if self.auto_refresh else lambda: execution_cache()
|
||||
|
||||
for i, job in enumerate(self.inputs):
|
||||
# Resolve the input to get the connected node(s)
|
||||
res = resolve_input(job)
|
||||
|
|
@ -209,8 +204,7 @@ class SLICENODE_Executor(ExecSliceNode, SliceNodeJoiner):
|
|||
operator.report({'INFO'}, f"Executing: {upstream_node.bl_label}")
|
||||
|
||||
try:
|
||||
with maybe_disabled():
|
||||
with node_execution_feedback(upstream_node):
|
||||
with execution_cache():
|
||||
exec_res = upstream_node.evaluate(operator=operator)
|
||||
if exec_res != 'ok' and exec_res is not None:
|
||||
if operator: operator.report({'WARNING'}, f"Node {upstream_node.bl_label} returned {exec_res}")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import bpy
|
|||
from bpy.types import NodeTree, Operator, Menu
|
||||
from bpy.app.handlers import persistent
|
||||
|
||||
from ...infra.blender.blender_slice_nodes_generic import node_execution_feedback, resolve_input
|
||||
from ...infra.blender.blender_slice_nodes_generic import execution_cache, resolve_input
|
||||
from ...registry import register_class
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
@ -102,9 +102,7 @@ def tree_update_handler(scene, depsgraph):
|
|||
if should_refresh:
|
||||
_is_updating = True
|
||||
try:
|
||||
from ...infra.blender.blender_slice_nodes_generic import feedback_disabled
|
||||
with feedback_disabled():
|
||||
with node_execution_feedback(node):
|
||||
with execution_cache():
|
||||
node.evaluate()
|
||||
except Exception as e:
|
||||
print(f"Auto-refresh failed: {e}")
|
||||
|
|
@ -454,7 +452,7 @@ class SLICENODE_OT_Execute(Operator):
|
|||
node = node_tree.nodes[self.node_name]
|
||||
|
||||
try:
|
||||
with node_execution_feedback(node):
|
||||
with execution_cache():
|
||||
res = node.evaluate(operator=self)
|
||||
if res == 'ok':
|
||||
self.report({"INFO"}, f"Execution Successful")
|
||||
|
|
|
|||
|
|
@ -225,7 +225,6 @@ class SliceNode(Node, AutoBlIdName):
|
|||
## Evaluation helpers
|
||||
|
||||
_current_execution_cache: _EvalCache | None = None
|
||||
_feedback_enabled: bool = True
|
||||
|
||||
@contextmanager
|
||||
def execution_cache():
|
||||
|
|
@ -240,50 +239,6 @@ def execution_cache():
|
|||
finally:
|
||||
_current_execution_cache = None
|
||||
|
||||
@contextmanager
|
||||
def feedback_disabled():
|
||||
global _feedback_enabled
|
||||
old = _feedback_enabled
|
||||
_feedback_enabled = False
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
_feedback_enabled = old
|
||||
|
||||
@contextmanager
|
||||
def node_execution_feedback(node: bpy.types.Node):
|
||||
if not _feedback_enabled:
|
||||
with execution_cache():
|
||||
yield
|
||||
return
|
||||
|
||||
# Save original color
|
||||
old_use_color = getattr(node, "use_custom_color", False)
|
||||
old_color = getattr(node, "color", (0.0, 0.0, 0.0))[:] if hasattr(node, "color") else None
|
||||
|
||||
if hasattr(node, "use_custom_color"):
|
||||
node.use_custom_color = True
|
||||
if hasattr(node, "color"):
|
||||
node.color = (75/255, 73/255, 19/255) # Green
|
||||
|
||||
# Refresh UI
|
||||
try:
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
with execution_cache():
|
||||
yield
|
||||
finally:
|
||||
if hasattr(node, "use_custom_color"):
|
||||
node.use_custom_color = old_use_color
|
||||
if hasattr(node, "color") and old_color is not None:
|
||||
node.color = old_color
|
||||
try:
|
||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@contextmanager
|
||||
def _group_context(node: bpy.types.Node, cache: _EvalCache | None = None):
|
||||
stack = _get_group_stack(cache)
|
||||
|
|
@ -543,7 +498,7 @@ def _resolve_output(
|
|||
|
||||
visited.add(node_key)
|
||||
try:
|
||||
with node_execution_feedback(socket.node):
|
||||
with execution_cache():
|
||||
if not isinstance(socket.node, SliceNode):
|
||||
is_group = isinstance(socket.node, SLICENODE_Group) or (
|
||||
isinstance(getattr(bpy.types, "NodeGroup", None), type) and isinstance(socket.node, bpy.types.NodeGroup)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue