Socket.enabled does not call update methods #89109

Open
opened 2021-06-13 12:39:05 +02:00 by Sergey · 8 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 660 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.09

Blender Version
Broken: version: 2.93.0, branch: master, commit date: 2021-06-02 11:21, hash: 84da05a8b8

Short description of error
Socket.enabled = False make the socket to be sort of hidden with connected link. I assume that the logic here is close to link.is_muted = True. But unlike changes of is_muted attribute changes of enabled attribute does no trigger calling update method of a tree. And it does not change the is_linked status of the socket from opposite side.
So I think there are two bugs here.

  1. Whenever enabled attribute is changed the update method of a tree should be called. This will indicate that topology of the tree was changed.
  2. Sockets with connected hidden links should have is_linked status as False because disabled sockets should not produce or receive any data (according to how I understand the purpose of this functionality).

Exact steps for others to reproduce the error
untitled (2).blend

  1. Open the file
  2. Ran the script
  3. Read a console
**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 660 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.09 **Blender Version** Broken: version: 2.93.0, branch: master, commit date: 2021-06-02 11:21, hash: `84da05a8b8` **Short description of error** `Socket.enabled = False` make the socket to be sort of hidden with connected link. I assume that the logic here is close to `link.is_muted = True`. But unlike changes of `is_muted` attribute changes of `enabled` attribute does no trigger calling update method of a tree. And it does not change the `is_linked` status of the socket from opposite side. So I think there are two bugs here. 1. Whenever `enabled` attribute is changed the update method of a tree should be called. This will indicate that topology of the tree was changed. 2. Sockets with connected hidden links should have `is_linked` status as False because disabled sockets should not produce or receive any data (according to how I understand the purpose of this functionality). **Exact steps for others to reproduce the error** [untitled (2).blend](https://archive.blender.org/developer/F10169284/untitled__2_.blend) 1. Open the file 2. Ran the script 3. Read a console
Author

Added subscriber: @randum

Added subscriber: @randum
Member

Added subscribers: @HooglyBoogly, @JacquesLucke, @lichtwerk

Added subscribers: @HooglyBoogly, @JacquesLucke, @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
Member

I would agree here.

Going briefly over usages of SOCK_UNAVAIL this really seems to alter the tree (and just firing the NC_NODE | ND_DISPLAY notifier is not enough).
We could add something like the following to get the tree update to be called:

P2209: #89109 snippet



diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index c26e9e883d6..7f54d97dd7f 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -2844,16 +2844,29 @@ static void rna_NodeSocket_type_set(PointerRNA *ptr, int value)
   nodeModifySocketType(ntree, node, sock, value, 0);
 }
 
-static void rna_NodeSocket_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_NodeSocket_update_ex(Main *bmain, PointerRNA *ptr, bool do_update_tree)
 {
   bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
   bNodeSocket *sock = (bNodeSocket *)ptr->data;
   bNode *node;
   if (nodeFindNode(ntree, sock, &node, NULL)) {
     ED_node_tag_update_nodetree(bmain, ntree, node);
+    if (do_update_tree) {
+      ntreeUpdateTree(bmain, ntree);
+    }
   }
 }
 
+static void rna_NodeSocket_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
+{
+  rna_NodeSocket_update_ex(bmain, ptr, false);
+}
+
+static void rna_NodeSocket_tree_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
+{
+  rna_NodeSocket_update_ex(bmain, ptr, true);
+}
+
 static bool rna_NodeSocket_is_output_get(PointerRNA *ptr)
 {
   bNodeSocket *sock = ptr->data;
@@ -10100,7 +10113,7 @@ static void rna_def_node_socket(BlenderRNA *brna)
   prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SOCK_UNAVAIL);
   RNA_def_property_ui_text(prop, "Enabled", "Enable the socket");
-  RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL);
+  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_tree_update");
 
   prop = RNA_def_property(srna, "link_limit", PROP_INT, PROP_NONE);
   RNA_def_property_int_sdna(prop, NULL, "limit");

On the is_linked issue, I would tend to agree here as well (just seems to make more sense).

Not sure these two would be classified as bugs, maybe @JacquesLucke or @HooglyBoogly can comment?

I would agree here. Going briefly over usages of `SOCK_UNAVAIL` this really seems to alter the tree (and just firing the `NC_NODE | ND_DISPLAY` notifier is not enough). We could add something like the following to get the tree update to be called: [P2209: #89109 snippet](https://archive.blender.org/developer/P2209.txt) ``` diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index c26e9e883d6..7f54d97dd7f 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2844,16 +2844,29 @@ static void rna_NodeSocket_type_set(PointerRNA *ptr, int value) nodeModifySocketType(ntree, node, sock, value, 0); } -static void rna_NodeSocket_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_NodeSocket_update_ex(Main *bmain, PointerRNA *ptr, bool do_update_tree) { bNodeTree *ntree = (bNodeTree *)ptr->owner_id; bNodeSocket *sock = (bNodeSocket *)ptr->data; bNode *node; if (nodeFindNode(ntree, sock, &node, NULL)) { ED_node_tag_update_nodetree(bmain, ntree, node); + if (do_update_tree) { + ntreeUpdateTree(bmain, ntree); + } } } +static void rna_NodeSocket_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + rna_NodeSocket_update_ex(bmain, ptr, false); +} + +static void rna_NodeSocket_tree_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +{ + rna_NodeSocket_update_ex(bmain, ptr, true); +} + static bool rna_NodeSocket_is_output_get(PointerRNA *ptr) { bNodeSocket *sock = ptr->data; @@ -10100,7 +10113,7 @@ static void rna_def_node_socket(BlenderRNA *brna) prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SOCK_UNAVAIL); RNA_def_property_ui_text(prop, "Enabled", "Enable the socket"); - RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocket_tree_update"); prop = RNA_def_property(srna, "link_limit", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "limit"); ``` On the `is_linked` issue, I would tend to agree here as well (just seems to make more sense). Not sure these two would be classified as bugs, maybe @JacquesLucke or @HooglyBoogly can comment?

Added subscriber: @brecht

Added subscriber: @brecht

Modifying is_linked would be a Python API breaking change. I don't think it should be changed, the link still exists and is in the ntree.links list. If that link should be used for evaluation or not is another matter.

Modifying `is_linked` would be a Python API breaking change. I don't think it should be changed, the link still exists and is in the `ntree.links` list. If that link should be used for evaluation or not is another matter.
Author

@brecht What about muted links? They also still exist and are in the tree.links but sockets connected to such links have is_linked status as False.

{F10201836, size=full}

@brecht What about muted links? They also still exist and are in the `tree.links` but sockets connected to such links have `is_linked` status as False. {[F10201836](https://archive.blender.org/developer/F10201836/2021-06-25_11-44-09.png), size=full}

Ok, if muting does it already it's fine for it to be affected by this as well.

Ok, if muting does it already it's fine for it to be affected by this as well.
Philipp Oeser removed the
Interest
Nodes & Physics
label 2023-02-10 08:44:47 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#89109
No description provided.