rm flashing windows
This commit is contained in:
parent
8ceec61e76
commit
c06fb29157
3 changed files with 9 additions and 62 deletions
|
|
@ -183,14 +183,9 @@ class SLICENODE_Executor(ExecSliceNode, SliceNodeJoiner):
|
||||||
|
|
||||||
def evaluate(self, operator=None):
|
def evaluate(self, operator=None):
|
||||||
from ....infra.blender.blender_slice_nodes_generic import (
|
from ....infra.blender.blender_slice_nodes_generic import (
|
||||||
node_execution_feedback,
|
|
||||||
feedback_disabled,
|
|
||||||
execution_cache,
|
execution_cache,
|
||||||
resolve_input
|
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):
|
for i, job in enumerate(self.inputs):
|
||||||
# Resolve the input to get the connected node(s)
|
# Resolve the input to get the connected node(s)
|
||||||
|
|
@ -209,11 +204,10 @@ class SLICENODE_Executor(ExecSliceNode, SliceNodeJoiner):
|
||||||
operator.report({'INFO'}, f"Executing: {upstream_node.bl_label}")
|
operator.report({'INFO'}, f"Executing: {upstream_node.bl_label}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with maybe_disabled():
|
with execution_cache():
|
||||||
with node_execution_feedback(upstream_node):
|
exec_res = upstream_node.evaluate(operator=operator)
|
||||||
exec_res = upstream_node.evaluate(operator=operator)
|
if exec_res != 'ok' and exec_res is not None:
|
||||||
if exec_res != 'ok' and exec_res is not None:
|
if operator: operator.report({'WARNING'}, f"Node {upstream_node.bl_label} returned {exec_res}")
|
||||||
if operator: operator.report({'WARNING'}, f"Node {upstream_node.bl_label} returned {exec_res}")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if operator: operator.report({'ERROR'}, f"Failed executing {upstream_node.bl_label}: {str(e)}")
|
if operator: operator.report({'ERROR'}, f"Failed executing {upstream_node.bl_label}: {str(e)}")
|
||||||
return 'error'
|
return 'error'
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import bpy
|
||||||
from bpy.types import NodeTree, Operator, Menu
|
from bpy.types import NodeTree, Operator, Menu
|
||||||
from bpy.app.handlers import persistent
|
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
|
from ...registry import register_class
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
@ -102,10 +102,8 @@ def tree_update_handler(scene, depsgraph):
|
||||||
if should_refresh:
|
if should_refresh:
|
||||||
_is_updating = True
|
_is_updating = True
|
||||||
try:
|
try:
|
||||||
from ...infra.blender.blender_slice_nodes_generic import feedback_disabled
|
with execution_cache():
|
||||||
with feedback_disabled():
|
node.evaluate()
|
||||||
with node_execution_feedback(node):
|
|
||||||
node.evaluate()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Auto-refresh failed: {e}")
|
print(f"Auto-refresh failed: {e}")
|
||||||
import traceback
|
import traceback
|
||||||
|
|
@ -454,7 +452,7 @@ class SLICENODE_OT_Execute(Operator):
|
||||||
node = node_tree.nodes[self.node_name]
|
node = node_tree.nodes[self.node_name]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with node_execution_feedback(node):
|
with execution_cache():
|
||||||
res = node.evaluate(operator=self)
|
res = node.evaluate(operator=self)
|
||||||
if res == 'ok':
|
if res == 'ok':
|
||||||
self.report({"INFO"}, f"Execution Successful")
|
self.report({"INFO"}, f"Execution Successful")
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,6 @@ class SliceNode(Node, AutoBlIdName):
|
||||||
## Evaluation helpers
|
## Evaluation helpers
|
||||||
|
|
||||||
_current_execution_cache: _EvalCache | None = None
|
_current_execution_cache: _EvalCache | None = None
|
||||||
_feedback_enabled: bool = True
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def execution_cache():
|
def execution_cache():
|
||||||
|
|
@ -240,50 +239,6 @@ def execution_cache():
|
||||||
finally:
|
finally:
|
||||||
_current_execution_cache = None
|
_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
|
@contextmanager
|
||||||
def _group_context(node: bpy.types.Node, cache: _EvalCache | None = None):
|
def _group_context(node: bpy.types.Node, cache: _EvalCache | None = None):
|
||||||
stack = _get_group_stack(cache)
|
stack = _get_group_stack(cache)
|
||||||
|
|
@ -543,7 +498,7 @@ def _resolve_output(
|
||||||
|
|
||||||
visited.add(node_key)
|
visited.add(node_key)
|
||||||
try:
|
try:
|
||||||
with node_execution_feedback(socket.node):
|
with execution_cache():
|
||||||
if not isinstance(socket.node, SliceNode):
|
if not isinstance(socket.node, SliceNode):
|
||||||
is_group = isinstance(socket.node, SLICENODE_Group) or (
|
is_group = isinstance(socket.node, SLICENODE_Group) or (
|
||||||
isinstance(getattr(bpy.types, "NodeGroup", None), type) and isinstance(socket.node, bpy.types.NodeGroup)
|
isinstance(getattr(bpy.types, "NodeGroup", None), type) and isinstance(socket.node, bpy.types.NodeGroup)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue