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

Re: g_list_remove problem



Rob Clack wrote:
[snip]
> When closing panes, it's all fine as long as the pane I'm closing is in 
> the last element of the list.  The problem arises when closing a pane 
> other than the last one.  I remove it from the GList with
> list = g_list_remove(panesList, splitPane);
> but after that all trailing elements in the list are broken.  The 
> pointers look good, but any gtk reference to the actual objects yields 
> gtk errors or seg faults.
> 
> 
> Here is a code fragment:
> 
>       /* find the pane we want to close in the list */
>       element = g_list_find(panesList, focuspane);
> 
>       /* remove it from the list */
>       panesList = g_list_remove(panesList, focuspane);
> 
>       /* point at previous entry  or start of list if none */
>       element = g_list_previous(panesList);
>       if (!element)
>     element = panesList;

is it possible that you meant:

   /* find the pane we want to close in the list */
   element = g_list_find(panesList, focuspane);
   /* point at previous entry which could be the start of the list */
   element = g_list_previous(element);
   /* remove it from the list */
   panesList = g_list_remove(panesList, focuspane);

BTW: g_list_append/remove always return the new list *head*.


>       /* destroy the pane - should do frame, swindow, canvas, too */
>       gtk_widget_destroy(focuspane->pane);


>       /* focus on the appropriate pane */
>       gtk_widget_grab_focus(((splitPane*)element->data)->pane);

Um, maybe add `if (element && element->data)' ? there has to be and
end of the list somewhere.


HTH,
                          -Tristan




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