Hi,
The crashing line is called before the OnCreate method of the list is
called, so the List is apparently not yet ready to receive items.
The crashing line is part of the OnInit of the main frame with data that
are related to the functionality of my program.
The structure looks like this:
class MainFrame(wx.Frame):
def __init__(self, res):
<snip>
def OnCreate(self, event):
self.Unbind(wx.EVT_WINDOW_CREATE)
self.my_list = xrc.XRCCTRL(self, "my_list")
# self.my_list.OnCreate(None) # Makes it work
self._init_data()
def _init_data(self):
<snip>
self.my_list.InsertStringItem(RowNum, M) # Crash
When I manually call the OnInit of the list before the _init_data(),
everhthing works nicely, but this seems to me a dirty hack.
Is there an elegant way to solve this? I already call the data
initialisation at the very end of the OnCreate method of the frame.
Martijn
P.S. platform is linux/gtk
···
On Thu, 2008-04-03 at 16:31 -0700, Robin Dunn wrote:
Martijn wrote:
> Hi all,
>
> I encounter a segfault in ListCtrl.InsertStringItem()
>
>
> The list control is created from xrc using two phase creation:
>
> The xrc code:
>
> <object class="wxListCtrl" name="my_list"
> subclass="WxEllips.AutoWidthListCtrl">
>
> the python code:
>
> class AutoWidthListCtrl(wx.ListCtrl, ListCtrlAutoWidthMixin):
> def __init__(self):
> Pre = wx.PreListCtrl()
> self.PostCreate(Pre)
> ListCtrlAutoWidthMixin.__init__(self)
> self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate)
>
> def OnCreate(self, event):
> self.Unbind(wx.EVT_WINDOW_CREATE)
> self.InsertColumn(0, "Column1")
> self.InsertStringItem(0, "Item1") # this works!
> self.InsertStringItem(1, "Item2") # this too
>
>
> self.my_list = xrc.XRCCTRL(self, "my_list")
> self.my_list.InsertStringItem(RowNum, M)
>
> In this last line I get the segfault.
> I checked that the RowNum is a correct number and that M is a string.I'm not sure if it's possible, but could you check if OnCreate is being
called before the crashing line is? (BTW, which platform?)
This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/disclaimer/email.html