Re: GSList Keeps losing its contents
- From: "Ian Frawley" <ifrawley opaltelecom co uk>
- To: "Soeren Sandmann" <sandmann daimi au dk>
- Cc: <gtk-app-devel-list gnome org>
- Subject: Re: GSList Keeps losing its contents
- Date: Fri, 19 Oct 2001 08:59:32 +0100
Thanks Soeren.
Is what you saying that I should take a copy of my group GSList? If that's
the case will that not still be a pointer to my actual group list (pointer
to pointer) therefore having the same effect as my current code? I am sorry
if it is a silly question but I am not totally clued up on GSLists & GLists.
Ian
----- Original Message -----
From: "Soeren Sandmann" <sandmann daimi au dk>
To: "Ian Frawley" <ifrawley opaltelecom co uk>
Cc: <gtk-app-devel-list gnome org>
Sent: Thursday, October 18, 2001 7:28 PM
Subject: Re: GSList Keeps losing its contents
"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]