This time I have a serious issue that I have to fix *ASAP*
(i.e. yesterday ;o). It's about grids (once again).
The target grid in the application has seven columns. Three of them
use boolean renderers & editors, and two of them work just fine.
On changing any value in the third (boolean) column the application
halts due to an ugly segfault. However, the grid's underlying
model (a file with proprietary format) is correctly updated because
the file contents change just like they should and, on re-launching
the application, the GUI displays the correct values.
OTOH, initialization code calls the grid's `AutoSizeColumns` method
'cause columns need to be auto sized big enough to display the whole
values. Besides the file contents are polled (smart polling ;o)
at regular intervals in order to synchronize GUI & data. However when the
segfault shows up there's no external source modifying its contents.
The code that updates the GUI invokes the aforementioned method too.
Nevertheles, I tried to trigger its invokation by modifying values
directly in the file (remember smart polling ? ;o), but misteriously
it works fine (i.e. no segfault).
Considering what's been mentioned in the previous paragraph then
you should also know that the
segfault doesn't happen anymore if both calls to `AutoSizeColumns`
are removed. All this makes me think that the bug is related to
nothing but the GUI toolkit (wxPython in this case) or GUI code. The
only segfaults I've experienced are related to the use of
`wx.grid.GridCellAttr.IncRef` inside the model's `GetAttr` method,
but in this case everything seems to be as usual and I used `logging`
to confirm that it is always executed from inside `GetAttr`. Besides
everything works fine if both calls are removed. So my questions are
the following :
Q:
- Has anybody experienced similar problems before ?
- Could it happen due to some kind of non-reentrant method present
in wxPython and working under-the-hood ?
- Is it necessary to take extra precautions when using `AutoSizeColumns`
together with the boolean cell renderer, model's attributes or alike ?
If so, what should be done ?
- Any other idea about how to find the root cause and troubleshoot ?
- Is there a way to work around this and simulate the call to
`AutoSizeColumns` ?
Besides
{{{
wx.version()
'2.8.4.0 (msw-ansi)'
import sys
sys.version_info
(2, 6, 3, 'final', 0)
sys.version_info
win32
}}}
Thnx in advance !
'''PS''' : Since the software is complex (and I don't know all
implementation details yet, because somebody else did it some time ago)
I can't share a simplified version illustrating the circumstances
that lead to the segfault
I'm afraid we'll need a runnable sample to be able to be of any real help (MakingSampleApps - wxPyWiki) but some clues that may help you track down the problem further are:
* Keep in mind that the auto-size methods will end up invoking the renderers' GetBestSize method for every cell being evaluated for the auto-sizing being done, and it will also fetch the cell attribute(s) for that cell/row/col to pass to it, and the GetBestSize will likely be fetching the cell's value from the table. So in other words, the auto-size functionality can end up being rather complex and can tax the grid and related classes quite a bit.
* Try disabling the use of each of the renderers and retesting to find out which renderer is having the issue, or if it is not the renderers at all.
* If not then try disabling other features/aspects of the grid to narrow down further.
···
On 3/1/10 6:33 AM, Olemis Lang wrote:
Hello guys ! once again
This time I have a serious issue that I have to fix *ASAP*
(i.e. yesterday ;o). It's about grids (once again).
The target grid in the application has seven columns. Three of them
use boolean renderers& editors, and two of them work just fine.
On changing any value in the third (boolean) column the application
halts due to an ugly segfault. However, the grid's underlying
model (a file with proprietary format) is correctly updated because
the file contents change just like they should and, on re-launching
the application, the GUI displays the correct values.
OTOH, initialization code calls the grid's `AutoSizeColumns` method
'cause columns need to be auto sized big enough to display the whole
values. Besides the file contents are polled (smart polling ;o)
at regular intervals in order to synchronize GUI& data. However when the
segfault shows up there's no external source modifying its contents.
The code that updates the GUI invokes the aforementioned method too.
Nevertheles, I tried to trigger its invokation by modifying values
directly in the file (remember smart polling ? ;o), but misteriously
it works fine (i.e. no segfault).
Considering what's been mentioned in the previous paragraph then
you should also know that the
segfault doesn't happen anymore if both calls to `AutoSizeColumns`
are removed. All this makes me think that the bug is related to
nothing but the GUI toolkit (wxPython in this case) or GUI code. The
only segfaults I've experienced are related to the use of
`wx.grid.GridCellAttr.IncRef` inside the model's `GetAttr` method,
but in this case everything seems to be as usual and I used `logging`
to confirm that it is always executed from inside `GetAttr`. Besides
everything works fine if both calls are removed. So my questions are
the following :
Q:
- Has anybody experienced similar problems before ?
- Could it happen due to some kind of non-reentrant method present
in wxPython and working under-the-hood ?
- Is it necessary to take extra precautions when using `AutoSizeColumns`
together with the boolean cell renderer, model's attributes or alike ?
If so, what should be done ?
- Any other idea about how to find the root cause and troubleshoot ?
- Is there a way to work around this and simulate the call to
`AutoSizeColumns` ?
Besides
{{{
wx.version()
'2.8.4.0 (msw-ansi)'
import sys
sys.version_info
(2, 6, 3, 'final', 0)
sys.version_info
win32
}}}
Thnx in advance !
'''PS''' : Since the software is complex (and I don't know all
implementation details yet, because somebody else did it some time ago)
I can't share a simplified version illustrating the circumstances
that lead to the segfault
This time I have a serious issue that I have to fix *ASAP*
(i.e. yesterday ;o). It's about grids (once again).
The target grid in the application has seven columns. Three of them
use boolean renderers& editors, and two of them work just fine.
On changing any value in the third (boolean) column the application
halts due to an ugly segfault. However, the grid's underlying
model (a file with proprietary format) is correctly updated because
the file contents change just like they should and, on re-launching
the application, the GUI displays the correct values.
[...]
'''PS''' : Since the software is complex (and I don't know all
implementation details yet, because somebody else did it some time ago)
I can't share a simplified version illustrating the circumstances
that lead to the segfault
I know, if I can't find a solution then I'll try to do that .
but some clues that may help you
track down the problem further are:
Firstly, thnx ... ;o)
* Keep in mind that the auto-size methods will end up invoking the
renderers' GetBestSize method for every cell being evaluated for the
auto-sizing being done, and it will also fetch the cell attribute(s) for
that cell/row/col to pass to it, and the GetBestSize will likely be fetching
the cell's value from the table. So in other words, the auto-size
functionality can end up being rather complex and can tax the grid and
related classes quite a bit.
* Try disabling the use of each of the renderers and retesting to find out
which renderer is having the issue, or if it is not the renderers at all.
Great hint ! :o)
I tried once again using default renderer and it works fine so
it seems to be related to
bool renderer and | or bool editor (probably the later because everything
happens on editing the cell value)
[...]
Q:
- Is there a way to work around this and simulate the call to
`AutoSizeColumns` ?
What about this ? Any pointers (I really have no idea of how to do it
myself :-S )
Thnx once again !
···
On Mon, Mar 1, 2010 at 4:04 PM, Robin Dunn <robin@alldunn.com> wrote:
This time I have a serious issue that I have to fix *ASAP*
(i.e. yesterday ;o). It's about grids (once again).
The target grid in the application has seven columns. Three of them
use boolean renderers& editors, and two of them work just fine.
On changing any value in the third (boolean) column the application
halts due to an ugly segfault.
[...]
* Try disabling the use of each of the renderers and retesting to find out
which renderer is having the issue, or if it is not the renderers at all.
Great hint ! :o)
I tried once again using default renderer and it works fine so
it seems to be related to
bool renderer and | or bool editor (probably the later because everything
happens on editing the cell value)
I tried once again using all renderers & editors except boolean R & E
and everything works just fine (so I suppose it's an issue related to
bool E | R)
···
On Tue, Mar 2, 2010 at 2:50 PM, Olemis Lang <olemis@gmail.com> wrote:
On Mon, Mar 1, 2010 at 4:04 PM, Robin Dunn <robin@alldunn.com> wrote:
This time I have a serious issue that I have to fix *ASAP*
(i.e. yesterday ;o). It's about grids (once again).
The target grid in the application has seven columns. Three of them
use boolean renderers& editors, and two of them work just fine.
On changing any value in the third (boolean) column the application
halts due to an ugly segfault.
[...]
* Try disabling the use of each of the renderers and retesting to find out
which renderer is having the issue, or if it is not the renderers at all.
Great hint ! :o)
I tried once again using default renderer and it works fine so
it seems to be related to
bool renderer and | or bool editor (probably the later because everything
happens on editing the cell value)
I tried once again using all renderers & editors except boolean R & E
and everything works just fine (so I suppose it's an issue related to
bool E | R)
I found this suggestion in a separate thread and considered to use it
as a way to work around this problem
[...]
I'd probably try AutoSizeColumns, maybe with the setAsMin=True keyword
argument passed in. Reading Robin's book, it sounds like AutoSize()
itself should work (pg 439), so I'm wondering if it's getting called
before the values are set in the cells. Maybe try calling it with
wx.CallAfter()?
The «solution» was to substitute `AutoSizeColumns` and use the
following method instead
{{{
#!python
def _AutoSizeColumns(self):
wx.CallAfter(lambda : [grid.AutoSizeColumn(col) for col in ALL_COLS \
if col not in BOOL_COLS])
}}}
Therefore boolean columns are not resized. However this doesn't mean
that the underlying problem is gone (i.e. it seems there's something
wrong with bool editor + autosizeXXX)
Thnx Robin, Mike, Chris et al ... veeeeery much
:o)
···
On Tue, Mar 2, 2010 at 3:07 PM, Olemis Lang <olemis@gmail.com> wrote:
On Tue, Mar 2, 2010 at 2:50 PM, Olemis Lang <olemis@gmail.com> wrote:
On Mon, Mar 1, 2010 at 4:04 PM, Robin Dunn <robin@alldunn.com> wrote:
On 3/1/10 6:33 AM, Olemis Lang wrote:
On Wed, Mar 3, 2010 at 10:42 AM, Mike Driscoll <kyosohma@gmail.com> wrote:
On Mar 2, 7:19 pm, Christopher Barker <Chris.Bar...@noaa.gov> wrote: