g_list_remove problem
- From: Rob Clack <rnc sanger ac uk>
- To: gtk-app-devel-list gnome org
- Subject: g_list_remove problem
- Date: Fri, 05 Mar 2004 11:41:04 +0000
Not sure this is really the right list for this question, but it
overlaps two areas, so trying here first. I've spent days on this, both
hacking the code and searching the archives, without making any progress.
I have a window that the user can split as many times as she wants. The
repeating components, vpane, frame, scrolled_window, canvas, live in a
structure I call a splitPane. To keep track of the panes, I use a GList,
to which I g_list_append(panesList, splitPane).
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;
/* 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);
(split:7604): Gtk-CRITICAL **: file gtkwidget.c: line 3400
(gtk_widget_grab_focus): assertion `GTK_IS_WIDGET (widget)' failed
There must be something simple I'm doing wrong but I can't see it. Hope
someone else can.
Thanks
Rob
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Junk is something you've kept for years and then throw away three weeks
before you need it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rob Clack Acedb Development, Informatics Group
email: rnc sanger ac uk Wellcome Trust Sanger Institute
Tel: +44 1223 494883 Wellcome Trust Genome Campus
Fax: +44 1223 494919 Hinxton Cambridge CB10 1SA
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]