ID 248386 - Nuke doesn't correctly load a script correctly when a callback contains nuke.thisNode() on Gizmos

Follow

Problem summary
Nuke doesn't correctly load a script correctly when a callback contains nuke.thisNode(), resulting in any Nodes after a Gizmo not loading, when there is a node with an invalid expression before it or the node the gizmo is expression linked to is created after the gizmo.

Customer reported version
nuke.n/a

Customer reported platform
centos6

Steps to reproduce

1) Add the attached gizmo and menu.py to your .nuke directory

2) Open the attached Nuke script, it will saying Nothing is named "whatever" and will not load any nodes past the dudGizmo. Below left shows what the script should be, below right shows the result

 
Other repro steps:
 
1) Launch Nuke
 
2) Create a Groups node, then export as gizmo... and save it to your ~/.nuke directory
 
3) From the tab menu, run Update [All Plugins]
 
4) Create the Gizmo you exported
 
5) Add any user knob to the Gizmo, like a Floating point slider
 
6) Create ​any other node with a matching knob type, like a Grade
 
7) Expression link the Gizmo to a matching knob in the other node
 
8) Run the following code in the Script Editor: 
def on_knob_changed():    print(nuke.thisKnob().value())nuke.addKnobChanged(on_knob_changed)

9) Select the other node, then the Gizmo and Copy the nodes

10) Delete the nodes

11) Paste the nodes, only the Gizmo will be created

 

Workaround
If you disable forceEvaluate in the dependent() command, it seems to work correctly. This can be done by changing line 3 of the menu.py from:

    print (nuke.thisNode().dependent())

to:

    print( nuke.thisNode().dependent( forceEvaluate = False ))

 
however if your callback is just doing print(nuke.thisKnob().value()), this workaround does not work


Reproduced by support
This problem has been reproduced on:
Nuke 15.1v4 - Windows 10
Nuke 10.5v1 - Windows 10 - CentOS 6.8
Nuke 10.0v5 - Windows 10
Nuke 10.0v1 - Windows 10
Nuke 9.0v9 - Windows 10
Nuke 9.0v1 - Windows 10
Nuke 8.0v6 - Windows 10 - CentOS 6.8

Expected behaviour
For the whole Nuke script to load

Actual behaviour
It got stuck after the dudGizmo node
 

    We're sorry to hear that

    Please tell us why