wxGrid and more than one SetTable

Hi everyone!

I’m finally in the process of porting a wx 2.8 application to Phoenix (4.1.0).
I’m hitting a few problems with a wx.Grid though: if I run then 2.8 code without modification, the application crashes upon displaying the frame containing the grid. I’ve narrowed it down to the takeOwnership parameter of grid.SetTable, if I set it to True, the crash goes away.
There is still a problem though: when the program later calls SetTable again (to replace the grid data) everything crashes down again (“double free or corruption”). What is the recommended way to handle this issue?

Many thanks for your time!

Does this work?

  • use SetTable with takeOwnership=False
  • keep a reference to your table yourself (such that it is not deleted)
  • use SetTable again if required
1 Like

I had tried something like that before posting, but it seems that keeping the reference to the table inside the grid itself is not the way to go :sweat_smile: Now that I’m storing the reference elsewhere it is working, many thanks! :smiley:

You’re welcome.
The documentation for AssignTable is a bit more enlightening than SetTable:
https://wxpython.org/Phoenix/docs/html/wx.grid.Grid.html#wx.grid.Grid.AssignTable

1 Like