Splitter Segmentation Fault

Telly Williams wrote:

Robin Dunn wrote:

Telly Williams wrote:

Robin,

    I emailed earlier that I used ReplaceWindow to fix the problem,
which also allowed me to re-set the pane size without any problems. Did
you still want me to email a reply to your email with the old code for
general purpose?

Yes, please.

    For those desiring to see the code I had which gave me a
Segmentation Fault upon SetMinimumPaneSize for a Splitter object, it's
attached. Again, I circumvented this by including in the (new) code the
ReplaceWindow method. (This [attached] code works under Windows).

Since your sample is not runnable (without MySQLdb) I can't be sure, but it looks to me like the problem is not with SetMinimumPaneSize, it just manifests there. The problem is probably the fact that you were Destroying the self.grid and making a new one but not putting the new one in the splitter. So the splitter still has a pointer to the old grid, which has been destroyed and then it tries to use that pointer in the SetMinimumPaneSize method. The fact that this appears to work on Windows is just lucky, probably the pointer just happens to point at a valid memory location.

http://wiki.wxpython.org/MakingSampleApps

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Telly Williams wrote:

Robin Dunn wrote:

Telly Williams wrote:

Robin,

    I emailed earlier that I used ReplaceWindow to fix the problem,
which also allowed me to re-set the pane size without any
problems. Did
you still want me to email a reply to your email with the old code for
general purpose?

Yes, please.

    For those desiring to see the code I had which gave me a
Segmentation Fault upon SetMinimumPaneSize for a Splitter object, it's
attached. Again, I circumvented this by including in the (new) code the
ReplaceWindow method. (This [attached] code works under Windows).

Since your sample is not runnable (without MySQLdb) I can't be sure,
but it looks to me like the problem is not with SetMinimumPaneSize, it
just manifests there. The problem is probably the fact that you were
Destroying the self.grid and making a new one but not putting the new
one in the splitter. So the splitter still has a pointer to the old
grid, which has been destroyed and then it tries to use that pointer
in the SetMinimumPaneSize method. The fact that this appears to work
on Windows is just lucky, probably the pointer just happens to point
at a valid memory location.

MakingSampleApps - wxPyWiki

Thank you.

One other question that I have about the destroy method: Is that just as
effective as doing the Begin/EndBatch method for the grid? I've asked
this before but got no reply. I was never able to get Batch to work.
What's the con for simply destroying the grid. I haven't seen any
drawbacks to the destroy method, but many advocate the batch mode.

VR

Telly

Telly Williams wrote:

One other question that I have about the destroy method: Is that just as
effective as doing the Begin/EndBatch method for the grid? I've asked
this before but got no reply. I was never able to get Batch to work. What's the con for simply destroying the grid. I haven't seen any
drawbacks to the destroy method, but many advocate the batch mode.

Destroy does what it says, it destroys the widget and any children it has and any resources it holds. If all you are wanting to do is repopulate the grid you can certainly do that with a single widget and destroying it is real overkill.

BeginBatch/EndBatch are another animal entirely, and it really isn't fair to compare them. BeginBatch/EndBatch are like Freeze/Thaw in wx.Window, they simply temporarily suspend updates to the screen while you muck around with lots of changes in the grid, and then when the last EndBatch is called all the cells are refreshed.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!