GetAttr with custom editor segfault

The latest versions of Phoenix have fixed most of my grid GetAttr woes. Unfortunately, using a custom editor is causing a segfault. The following code seems to properly assign an editor, and it is possible to get any editor working for any particular cell, but the segfault occurs when selecting a different cell after activating an editor.

def GetAttr(self, row, col, kind):
    """ Retrieve the cell attribute object for the specified cell. """

    result = GridCellAttr()

some working stuff not shown

    # First look in the cache for the editor:
    editor = self._editor_cache.get((row, col))
    if editor is None:
        if (row >= rows) or (col >= cols):
            editor = DummyGridCellEditor()
        else:
            # Ask the underlying model for an editor for this cell:
            editor = self.model.get_cell_editor(row, col)
            if editor is not None:
                self._editor_cache[(row, col)] = editor
                editor._grid_info = (self._grid._grid, row, col)

    if editor is not None:
        # Note: We have to increment the reference to keep the
        #       underlying code from destroying our object.
        editor.IncRef()
        result.SetEditor(editor)

##more working stuff not shown
return result

I have traced the events and event handlers to the extent EASILY possible (not the really-low-level ping pong in ETS traits).

Does anyone have ideas on where to look or similar woes?

Happily, all other cell attributes are working splendidly.

Cheers, Eric

Did you try to keep a Python reference to your GridCellAttr instance?
This fixed many problems with wxPython versions before the last grid related updates.

Just try something like
self._attrs =
...
self._attrs.append(result)

Also, I would recommend to keep a reference to DummyGridCellEditor if it is really used.

Regards,

Dietmar

···

On 6/9/17 3:20 PM, braidedlogix@gmail.com wrote:

Does anyone have ideas on where to look or similar woes?

I think I made some attempts at this before, but I have just again attempted the saving of a reference to either editor or result, as well as an attempt to save a reference to each during each call to GetAttr, and I still get a segfault when changing cells after accessing the embedded widget.

After months of this type of behavior, my suspicions certainly are centered around some reference counting issues. That said, the cell widgets are embedded in at least one highly reactive wx.Panel subclass, so any number of things could be hijacking the change cell event.

To be complete, I must mention that I have tried initializing the self._attrs variable in the GridTable class init, as well as in the GetAttr method (for each call), and neither has an impact.

I appreciate the suggestion, and would definitely be open to any other suggestions.

Cheers,Eric

Seems your requirements are more complicated than e.g. one type per column.
Maybe you could use RegisterDataType. Did you try this?
I have not used this for a long time. So I'm not sure whether it works with Phoenix. The GridCustEditor demo has some code which is commented out.
Anyway, I think that data types are more appropriate than attaching the editor to the attributes.

Regards,

Dietmar

···

On 6/12/17 9:12 PM, braidedlogix@gmail.com wrote:

I appreciate the suggestion, and would definitely be open to any other suggestions.