ID 387512 - DropDataCallback throws exceptions when creating nodes through nuke.nodePaste()

Follow

Problem summary
When creating functions for the DropDataCallback, Nuke throws an exception if the user attempts to use the nuke.nodePaste() to create Nodes from dropped Gizmos or Nuke scripts.

Interestingly, this does not happen when executing the function with a nukescripts.dropData() call.

Customer reported version
nuke.11.1v4

Customer reported platform
windows10

Steps to reproduce

1) Open Nuke, Copy/Paste the following into your Script Editor:

def importGizmo(Type, text):    # Split text variable to get the filename and extension    file = os.path.basename(text)    filename = file.split('.')[0]    extension = file.split('.')[1]    # If the file is a .gizmo, create the Gizmo     if extension == 'gizmo':        newNode = nuke.nodePaste(text)        newNode.setName(filename)        return True    return Falsenukescripts.addDropDataCallback(importGizmo)if __name__ == "__main__":    nukescripts.dropData('text/plain', "C:/path/to/custom/TestGizmo.gizmo")

2) Once pasted, replace the path in the nukescripts.dropData() with your custom Gizmo path  ( Last line in the snippet )

3) Execute the script, your Gizmo should be created in the Node Graph as expected.

4) From your custom Gizmo folder, drag and drop your Gizmo into the Node Graph.

Result:   Nuke will not load the Gizmo and will throw the following exception:
​​
​​

Expected behaviour
The dropped .gizmo should be created as a node within the Node Graph

Actual behaviour
The dropped .gizmo throws an exception and is not loaded.

Workaround
It is possible to workaround this issue through a  PySide2.QtCore.QTimer.singleShot() delay.

The delay allows the dropdown callback to finish and then execute the nuke.nodePaste() function:

import PySide2from PySide2 import QtCorefrom PySide2.QtCore import QTimerdef pasteDropNode(filename, text):    newNode = nuke.nodePaste(text)    newNode.setName(filename)def importGizmo(Type, text):    # Split text variable to get the filename and extension    file = os.path.basename(text)    filename = file.split('.')[0]    extension = file.split('.')[1]    # If the file is a .gizmo,     if extension == 'gizmo':        QTimer.singleShot(0, lambda: pasteDropNode(filename, text))        return True    return Falsenukescripts.addDropDataCallback(importGizmo)

The snippet above can be added to your menu.py to add the callback on launch.

Reproduced by support

This bug has been reproduced in:
Nuke11.3v3- Windows 7 - Mac10.13 - CentOS7
Nuke11.3v1- Windows 7
Nuke11.2v1 - Windows 7
Nuke11.1v1 - Windows 7
Nuke11.0v1 - Windows 7
Nuke10.5v1 - Windows 7
Nuke10.0v1 - Windows 7
Nuke9.0v1 - Windows 7
Nuke8.0v1 - Windows 7 - Mac10.13 - CentOS7

Earliest version tested
- This issue appears to be in all versions of the product
 

    We're sorry to hear that

    Please tell us why