Commit 46e62889 authored by Maxime Perrotin's avatar Maxime Perrotin

Prevent segfault

parent 8573e003
......@@ -86,12 +86,9 @@ reads the value from the editor and place it back in the model '''
def __init__(self, oParent=None):
super(TreeDelegate, self).__init__(oParent)
def createEditor(self, parent, option, index):
''' Define the delegate (editor) to use for a given cell. This function
is called when the user clicks on a cell.
index.data() returns the actual value, and index.data(role) points
to some user data when role >= 32. 32 is Qt.UserRole. '''
def update_model(editor, index, event):
@Slot(QWidget, int)
def update_model(self, editor, index):
#def update_model(editor, index, event):
''' Trigger an immediate update of the model and therefore of the
visible elements of the gui, when user changes a value in the
editor. For example when the CHOICE index changes, this makes sure
......@@ -99,8 +96,15 @@ reads the value from the editor and place it back in the model '''
for the user to click outside from the widget '''
# Do not call setModelData directly, it would segfault
# self.setModelData(editor, index.model(), index)
self.commitData.emit(editor)
pass
#self.commitData.emit(editor)
def createEditor(self, parent, option, index):
''' Define the delegate (editor) to use for a given cell. This function
is called when the user clicks on a cell.
index.data() returns the actual value, and index.data(role) points
to some user data when role >= 32. 32 is Qt.UserRole. '''
# Check the (user-defined) type associated with the cell
asnType = index.data(ASN1TYPE)
if asnType == 'INTEGER':
......@@ -119,10 +123,11 @@ reads the value from the editor and place it back in the model '''
minVal = index.data(MIN_RANGE)
maxVal = index.data(MAX_RANGE)
editor.setRange(minVal, maxVal)
editor.valueChanged.connect(partial(update_model, editor, index))
#editor.valueChanged.connect(partial(update_model, editor, index))
elif asnType in ('ENUMERATED', 'CHOICE'):
editor = QComboBox(parent)
editor.activated.connect(partial(update_model, editor, index))
#editor.activated.connect(partial(update_model, editor, index))
editor.activated.connect(partial(self.update_model, editor))
enumVal = index.data(CHOICE_LIST)
for val in enumVal:
editor.addItem(val)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment