lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] wx segfault iterating on GetChildren()


From: Greg Chicares
Subject: Re: [lmi] wx segfault iterating on GetChildren()
Date: Mon, 13 Mar 2006 03:45:53 +0000
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

On 2006-3-12 13:04 UTC, Greg Chicares wrote:
> 
> Here's an additional change that prevents that particular segfault:
> 
>   wxNotebookPage& XmlNotebook::CurrentPage() const
>   {
>       // INELEGANT !! This window could be held elsewhere, e.g. as a 
> reference.
>       wxNotebook& notebook = WindowFromXrcName<wxNotebook>("input_notebook");
> +     if(-1 == notebook.GetSelection())
> +         {
> +         fatal_error() << "No page selected in notebook." << LMI_FLUSH;
> +         }
>       wxNotebookPage* page = notebook.GetPage(notebook.GetSelection());
>       if(!page)
>           {
> -         fatal_error() << "No page selected in notebook." << LMI_FLUSH;
> +          fatal_error() << "Selected notebook page is null." << LMI_FLUSH;
>           }
>       return *page;
>   }
> 
> However, there's still a segfault upon exit.

In the 'skeleton' branch where I'm currently doing most of my work,
that change is a pure win: it prevents a segfault that would
otherwise occur, and doesn't trigger another segfault upon exit.

Here's the problem, in wx HEAD:

  
http://cvs.wxwidgets.org/viewcvs.cgi/*checkout*/wxWidgets/include/wx/bookctrl.h?rev=1.28
  wxWindow *GetPage(size_t n) { return m_pages[n]; }

Would it not make sense to add a range check here, inside wx, and
either fail an assertion or return null if 'n' is not in the half-open
range [ 0, m_pages.size() )? Of course, in my testcase, it would be more
natural to call GetCurrentPage() (which you added in revision 1.12), but
I think that has the same problem because it just calls GetPage(), and
GetSelection() can still equal wxNOT_FOUND.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]