Re: [gtk-list] ...yaq... (yet another question) :-)
- From: Owen Taylor <otaylor redhat com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] ...yaq... (yet another question) :-)
- Date: 09 Jul 1998 14:55:11 -0400
Georg Greve <greve@fusebox.hanse.de> writes:
> -----BEGIN PGP SIGNED MESSAGE-----
>
> Hi !
>
> I am also having another problem. I tagged a special data array to my
> list items and of course the memory should be freed again upon
> destruction of the list items.
>
> So I attached my function to free the memory to the items by
>
> gtk_signal_connect (GTK_OBJECT (list_item), "destroy",
> GTK_SIGNAL_FUNC (destroy_filter_entry), filter);
>
> Where "filter" is the pointer to the data to be freed. The interesting
> question is whether I need to destroy the list item itself
> somehow. And if I have to: how do I do it ? It seems that right now
> just having:
>
> void destroy_filter_entry(GtkWidget *widget, gpointer *data){
> Filter* filter = (Filter*) data;
> delete filter;
> }
>
> crashes my program...
Hmmm, I guess this is a C++ program. I assume you are not mixing
malloc() or g_new/g_malloc with delete. Other than that, it looks
fine.
I suspect there is some other problem with your program - if you
comment out the 'delete filter' and it works, then my guess is that
you are freeing the filter multiple times in some fashion.
[ note, that that should be 'gpointer data', not 'gpointer *data' -
you may have copied it from an old version of the tutorial
which had it wrong in some places. It shouldn't do any harm
here though... ]
> By the way: Is the destruction event called for every GtkListItem upon
> destruction of the GtkList ? One would think so, but by now I am
> desperate enough to consider the weirdest things (voodoo ? :-) ).
Yes, it will be.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]