ID 355573 - Using setItemDelegateForColumn() in PySide UI crashes Nuke

Follow

Problem summary
When setting up custom PySide UIs, using the 'setItemDelegateForColumn()' from the QtGui/QtWidgets module, Nuke will crash when opening the window.

One weird behaviour noted, is if the code is ran again in Nuke11 (Windows Only) , it will not crash when opening the window, but moving the scrollbar within the window will crash Nuke.

In versions Nuke10 and earlier, launching the window in a second GUI, will still crash when opening the window.

The issue appears to be regressed with Nuke7v10, although the window is slow to run.

Using setItemDelegate() does not cause the crashing behaviour and allows the window to be used.

Customer reported version
nuke.11.1v4

Customer reported platform
n_a_mac

Steps to reproduce

1) Open Nuke

2) Open the Script Editor tab and paste/execute the following script:

try:
from PySide2 import QtWidgets, QtCore
except(ImportError):
from PySide import QtCore
from PySide import QtGui as QtWidgets

class MyDelegate(QtWidgets.QStyledItemDelegate):
def __init__(self, parent=None):
super(MyDelegate, self).__init__(parent)

def paint(self, painter, option, index):
painter.drawText(option.rect,
index.data())

class MyModel(QtCore.QAbstractTableModel):
def __init__(self, node_list, parent=None):
super(MyModel, self).__init__(parent)
self.setNodes(node_list)

def setNodes(self, node_list):
self.nodes = node_list

def data(self, index, role):
return self.nodes[index.row()].name()

def columnCount(self, index=None):
return 3

def rowCount(self, index=None):
return len(self.nodes)

v = QtWidgets.QTableView()
model = MyModel(["hey","there","world"])
v.setModel(model)

v.setItemDelegateForColumn(0, MyDelegate())

# Workaround
#v.setItemDelegate(MyDelegate())

v.show()

Result 1: Nuke11 will crash on first launch, Nuke will always crash on Nuke10 & earlier.

3)  If the snippet above is executed in a second script, Nuke may open the window on the second try.

Try moving the horizontal slider within the window.


Result 2: Nuke crashes

Workaround
Using setItemDelegate() appears to work correctly and not cause the crashes.

Uncomment the workaround in the above snippet for testing:
# Workaround 
#v.setItemDelegate(MyDelegate())

Be sure to comment out setItemDelegateForColumn() before executing the snippet

Reproduced by support

This bug has been reproduced in:

Immediate crash on first launch: ( Windows only )
Nuke11.1v4 - Windows 7
Nuke11.1v1 - Windows 7
Nuke11.0v4 - Windows 7 
Nuke11.0v1 - Windows 7

Always crashes:
Nuke11.1v4 - Mac10.13 - CentOS6.9
Nuke11.1v1 - Mac10.13 - CentOS6.9
Nuke11.0v4 - Mac10.13 - CentOS6.9
Nuke11.0v1 - Mac10.13 - CentOS6.9

Nuke10.5v7 - Windows 7
Nuke10.5v1 - Windows 7 - Mac10.13 - CentOS6.9
Nuke10.0v6 - Windows 7
Nuke10.0v1 - Windows 7 - Mac10.13 - CentOS6.9
Nuke9.0v9 - Windows 7
Nuke9.0v1 - Windows 7 - Mac10.13 - CentOS6.9
Nuke8.0v7 - Windows 7 - Mac10.13 - CentOS6.9 - Regression
Unable to reproduce bug in:
Nuke7.0v10 - Windows 7 - Mac10.13 - CentOS6.9

Earliest version tested
- This issue no longer appears in this version and has regressed

Expected behaviour
When the script is executed, a QtGui window should appear and be functional

Actual behaviour
Nuke Crashes to desktop

    We're sorry to hear that

    Please tell us why