debugging hints on gridcelleditor

hi all, I’m trying to use the custom gridcellchoiceeditor found in the wxpython wiki (wxpython cookbook section) in my application. The demo script on the wiki runs correctly but when I use the CustomCellChoiceEditor in my application, this crashes. Attached to this message you can find a script reproducing my problem (winVista, python25, wxpy2.8.10.1). Just try to change the value in cell (1,1) and you should get the error.

thanks in advance for every hint,

Marco

wx cell choice editor.py (4.61 KB)

marco prosperi wrote:

hi all, I'm trying to use the custom gridcellchoiceeditor found in the wxpython wiki (wxpython cookbook section) in my application. The demo script on the wiki runs correctly but when I use the CustomCellChoiceEditor in my application, this crashes. Attached to this message you can find a script reproducing my problem (winVista, python25, wxpy2.8.10.1). Just try to change the value in cell (1,1) and you should get the error.

thanks in advance for every hint,

    def GetAttr(self, row, col, kind):
        if self.GetView().IsVisible(row, col, False):
            myattr = wx.grid.GridCellAttr()
            dictz = {'1':'1 Description_of_A', '2':'2 Description_of_B'}
            myattr.SetEditor(CustomCellChoiceEditor(dictz,True))
        myattr.IncRef() return myattr

You are creating a new editor in the table's GetAttr, and this editor has not had the _tc attribute set yet because Create() is not being called. So when the grid tries to hide the cell editor's control then it is using an uninitialized pointer and it is crashing. You should instead use the same instance of the cell editor that you created for this cell before. (Or just create one and reuse it.)

···

--
Robin Dunn
Software Craftsman