Re: Bad memory management?



In any case, here's the setup:

I create a struct that has 
GtkWidget *win, *table, *prog_bar
GdkPixmap *pixmap
GtkStyle *sty
and guint width, height

I create the window, copy the style out, set the background pixmap to
what I have in the *pixmap, copy the style back in.  All good so far.


So in order:

win = create_window()
style = get_style()
style = copy_style(style)
pixmap_ref(bgpixmap)
if(style->bgpixmap != NULL)
 pixmap_unref(style->bgpixmap)
style->bgpixmap = bgpixmap
set_style(win, style)

I hope that's right, is that how yer doing that?


Now for the fun part.  I want to free up the memory.

The struct in question is *s.  I do the following:

gtk_widget_hide_all( s->win );

gdk_pixmap_unref( s->pixmap );
s->pixmap = NULL;
gtk_style_unref( s->sty );
s->sty = NULL;

gtk_object_destroy( GTK_OBJECT( s->prog_bar ) );
s->prog_bar = NULL;
gtk_object_destroy( GTK_OBJECT( s->table ) );
s->table = NULL;
gtk_object_destroy( GTK_OBJECT( s->win ) );
s->win = NULL;

free( s );
s = NULL;


I think destroying the window would be sufficient to destroy its children
and the style. Since it'll unref the style.

Only thing you need to unref is your own bgpixmap.

I may be wrong though, better double check *G*

--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/





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