ID 508300 - An onCreate callback for the Root node triggers when using with nuke.root() in another node's onCreate callback

Follow

Problem summary
An onCreate callback for the Root node triggers when using with nuke.root() in another node's onCreate callback
 
Customer reported version
nuke.13.0v1
 
Customer reported platform
windows10
 
Steps to reproduce
 
1) Open Nuke

2) In the Script Editor, run the following code:
def test():    print("Root Node Created")    nuke.addOnCreate(test, nodeClass="Root")
3) In the Node Graph, paste the below node, the Script Editor will print "Root Node Created":
 

NoOp {

onCreate "\nwith nuke.root():\n nuke.createNode(\"Blur\")\n"

selected True

}
 
Expected behaviour
For the NoOp and Blur nodes to be created without triggering the Root node's onCreate callback.
 
Actual behaviour
The Root node's onCreate callback fires when other nodes are create through a callback, shown by the Script Editor printing "Root Node Created"
 
Workaround
Instead of with, use run() to set the context of creating a nodes, so instead of:
 

NoOp {

onCreate "\nwith nuke.root():\n nuke.createNode(\"Blur\")\n"

selected True

}
 
use:
 

NoOp {

onCreate "def runCode():\n\tnuke.createNode('Blur')\nnuke.root().run(runCode)"

selected True

}
 
Reproduced by support
This bug has been reproduced in:
Nuke 13.2v1 - Windows 10, macOS Bir Sur, CentOS 7
Nuke 12.0v1 - Windows 10
Nuke 9.0v1 - Windows 10, macOS Bir Sur
 
Earliest version tested
Nuke 9.0v1 - This issue appears to be in all versions of the product
 

    We're sorry to hear that

    Please tell us why