Re: GSList Keeps losing its contents
- From: Soeren Sandmann <sandmann daimi au dk>
- To: "Ian Frawley" <ifrawley opaltelecom co uk>
- Cc: <gtk-app-devel-list gnome org>
- Subject: Re: GSList Keeps losing its contents
- Date: 18 Oct 2001 20:28:23 +0200
"Ian Frawley" <ifrawley opaltelecom co uk> writes:
void SendMessage(GtkWidget * button, screen_controls * sc)
{
int i = 0;
sc->group = g_slist_nth( sc->group, i );
while ( sc->group != NULL && i < 3)
{
if (GTK_TOGGLE_BUTTON (sc->group->data)->active == TRUE)
{
cout << i << endl;
}
sc->group = g_slist_next ( sc->group );
i++;
}
}
Your problem is that you keep updating the master copy of your list in
the screen controls until it is NULL - at which point the list is
empty and the contents leaked.
Instead, try something like this (I didn't test it):
void SendMessage(GtkWidget * button, screen_controls * sc)
{
int i = 0;
GList *list;
list = g_slist_nth ( sc->group, i );
while ( list != NULL && i < 3)
{
if (GTK_TOGGLE_BUTTON (list->data)->active == TRUE)
{
cout << i << endl;
}
list = g_slist_next ( list );
i++;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]