Skip to content

Commit d3c5446

Browse files
committed
Fix error on Windows after deleting fit node.
Fit deletion triggers onTreeSelChanged handler with event holding the deleted and memory-released phase node. The handler calls GetNodeType, but all node data are already gone. Solution: Return None from GetNodeType if GetTreeItemDict gives None. Note: Might be better to somehow disable events from the deleted nodes. Note: Shows only on Windows, dead-node events are not raised on Mac.
1 parent 94cc5ec commit d3c5446

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

diffpy/pdfgui/gui/fittree.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,21 @@ def GetNodeType(self, node):
176176
177177
This is the "type" entry in the data dictionary of the node.
178178
"""
179-
if not node: return
180-
return self.GetTreeItemDict(node)['type']
179+
if not node:
180+
return None
181+
datadict = self.GetTreeItemDict(node)
182+
if datadict is None:
183+
return None
184+
return datadict['type']
181185

182-
def SetNodeType(self, node, type):
186+
def SetNodeType(self, node, tp):
183187
"""Set the node type of a node."""
184188
if not node: return
185189
datadict = self.GetTreeItemDict(node)
186-
if not datadict:
187-
self.SetPyData(node, {'type': type})
188-
else:
189-
self.GetTreeItemDict(node)['type'] = type
190+
if datadict is None:
191+
datadict = {}
192+
self.SetPyData(node, datadict)
193+
datadict['type'] = tp
190194
return
191195

192196
def GetBranchName(self, node):

0 commit comments

Comments
 (0)