[wxPython] wxListControl Styles maybe a bug

After a lot of investigation I now know whats going on here...

The following code will bus error if SetReportView is called.

class MyList(wxPanel):
    def __init__(self, parent):
        wxPanel.__init__(...)
        lstId = wxNewId()
        self.list = wxListCtrl(self, lstId,
style=wxLC_REPORT|wx_SUNKEN_BORDER)
        self.list.SetImageList(...)

        ....

    def SetIconView(self, event):
        self.list.DeleteAllItems()
        self.list.SetSingleStyle(wxLC_SMALL_ICON, 1) # Works as expected
        self.ReloadList()

    def SetListView(self, event):
        self.list.DeleteAllItems()
        self.list.SetSingleStyle(wxLC_LIST, 1) # Works as expected
        self.ReloadList()

    def SetReportView(self, event):
        self.list.DeleteAllItems()
        self.list.SetSingleStyle(wxLC_REPORT, 1) # Bus error here
        self.ReloadList()

The view setting methods are called by pop-up menu events. Setting the icon
or list styles
works as expected, setting the report style bus errors.

The problem is that the column headings appear to be forgotten, even when
changing to a report
view from a report view!. If the heading data is being forgotten, maybe
there is an associated
memory leak. Setting the headings immediately after the style change and
before
reloading the data fixes the problem, as below:

    def SetReportView(self, event):
        self.list.DeleteAllItems()
        self.list.SetSingleStyle(wxLC_REPORT, 1) # Bus error here
        self.list.InsertColumn(0, 'col1')
        self.list.InsertColumn(1, 'col2')
        self.list.InsertColumn(2, 'col3')
        self.ReloadList()

Roger

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users

Thanks for doing the legwork on this Roger. It makes some sense as
interally the list control throws everything away and rebuilds itself when
changing to or from report style. I'm guessing that if you built wxGTK and
wxPython in debug mode you'll probably get an assertion message in there
somewhere.

Out of curiousity, does it also crash if you don't create the columns to
begin with?

Please enter a bug report about this.

···

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

----- Original Message -----
From: "Roger Wenham" <roger.wenham@gmx.net>
To: <wxpython-users@lists.sourceforge.net>
Sent: Monday, February 12, 2001 10:36 AM
Subject: [wxPython] wxListControl Styles maybe a bug

After a lot of investigation I now know whats going on here...

The following code will bus error if SetReportView is called.

class MyList(wxPanel):
    def __init__(self, parent):
        wxPanel.__init__(...)
        lstId = wxNewId()
        self.list = wxListCtrl(self, lstId,
style=wxLC_REPORT|wx_SUNKEN_BORDER)
        self.list.SetImageList(...)

        ....

    def SetIconView(self, event):
        self.list.DeleteAllItems()
        self.list.SetSingleStyle(wxLC_SMALL_ICON, 1) # Works as

expected

        self.ReloadList()

    def SetListView(self, event):
        self.list.DeleteAllItems()
        self.list.SetSingleStyle(wxLC_LIST, 1) # Works as expected
        self.ReloadList()

    def SetReportView(self, event):
        self.list.DeleteAllItems()
        self.list.SetSingleStyle(wxLC_REPORT, 1) # Bus error here
        self.ReloadList()

The view setting methods are called by pop-up menu events. Setting the

icon

or list styles
works as expected, setting the report style bus errors.

The problem is that the column headings appear to be forgotten, even when
changing to a report
view from a report view!. If the heading data is being forgotten, maybe
there is an associated
memory leak. Setting the headings immediately after the style change and
before
reloading the data fixes the problem, as below:

    def SetReportView(self, event):
        self.list.DeleteAllItems()
        self.list.SetSingleStyle(wxLC_REPORT, 1) # Bus error here
        self.list.InsertColumn(0, 'col1')
        self.list.InsertColumn(1, 'col2')
        self.list.InsertColumn(2, 'col3')
        self.ReloadList()

Roger

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users

I no columns are created, It crashes on the first data load...
OK I'll reort it.
Roger

···

----- Original Message -----
From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@lists.sourceforge.net>
Sent: Tuesday, February 13, 2001 8:48 PM
Subject: Re: [wxPython] wxListControl Styles maybe a bug

Thanks for doing the legwork on this Roger. It makes some sense as
interally the list control throws everything away and rebuilds itself when
changing to or from report style. I'm guessing that if you built wxGTK

and

wxPython in debug mode you'll probably get an assertion message in there
somewhere.

Out of curiousity, does it also crash if you don't create the columns to
begin with?

Please enter a bug report about this.

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

----- Original Message -----
From: "Roger Wenham" <roger.wenham@gmx.net>
To: <wxpython-users@lists.sourceforge.net>
Sent: Monday, February 12, 2001 10:36 AM
Subject: [wxPython] wxListControl Styles maybe a bug

> After a lot of investigation I now know whats going on here...
>
> The following code will bus error if SetReportView is called.
>
> class MyList(wxPanel):
> def __init__(self, parent):
> wxPanel.__init__(...)
> lstId = wxNewId()
> self.list = wxListCtrl(self, lstId,
> style=wxLC_REPORT|wx_SUNKEN_BORDER)
> self.list.SetImageList(...)
>
> ....
>
> def SetIconView(self, event):
> self.list.DeleteAllItems()
> self.list.SetSingleStyle(wxLC_SMALL_ICON, 1) # Works as
expected
> self.ReloadList()
>
> def SetListView(self, event):
> self.list.DeleteAllItems()
> self.list.SetSingleStyle(wxLC_LIST, 1) # Works as expected
> self.ReloadList()
>
> def SetReportView(self, event):
> self.list.DeleteAllItems()
> self.list.SetSingleStyle(wxLC_REPORT, 1) # Bus error here
> self.ReloadList()
>
> The view setting methods are called by pop-up menu events. Setting the
icon
> or list styles
> works as expected, setting the report style bus errors.
>
> The problem is that the column headings appear to be forgotten, even

when

> changing to a report
> view from a report view!. If the heading data is being forgotten, maybe
> there is an associated
> memory leak. Setting the headings immediately after the style change and
> before
> reloading the data fixes the problem, as below:
>
> def SetReportView(self, event):
> self.list.DeleteAllItems()
> self.list.SetSingleStyle(wxLC_REPORT, 1) # Bus error here
> self.list.InsertColumn(0, 'col1')
> self.list.InsertColumn(1, 'col2')
> self.list.InsertColumn(2, 'col3')
> self.ReloadList()
>
> Roger
>
>
>
>
> _______________________________________________
> wxPython-users mailing list
> wxPython-users@lists.sourceforge.net
> http://lists.sourceforge.net/lists/listinfo/wxpython-users
>

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users