Re: [gtk-list] help with coding, pixmaps



Travis Loyd wrote:
> 
> I've been really at a loss to find what seems like a memory leak.
> Actually, it seems to locate itsself around code which I SWEAR has to be
> right but maybe not I can't find the error here is the volitile code:
> 
>     GdkPixmap *play_pix[4];
>     GdkBitmap *play_mask[4];
>     GtkStyle *style;
> 
>     gtk_widget_realize(mother->main_window);
>     style = gtk_widget_get_style(mother->main_window);
> 
>     ptr = -1;
>     play_pix[++ptr] = gdk_pixmap_create_from_xpm_d(
>             mother->main_window->window, &play_mask[ptr],
>             &style->bg[GTK_STATE_NORMAL],
>             play0_xpm);
>     play_pix[++ptr] = gdk_pixmap_create_from_xpm_d(
>             mother->main_window->window, &play_mask[ptr],
>             &style->bg[GTK_STATE_NORMAL],
>             play1_xpm);
>     play_pix[++ptr] = gdk_pixmap_create_from_xpm_d(
>             mother->main_window->window, &play_mask[ptr],
>             &style->bg[GTK_STATE_NORMAL],
>             play2_xpm);
>     play_pix[++ptr] = gdk_pixmap_create_from_xpm_d(
>             mother->main_window->window, &play_mask[ptr],
>             &style->bg[GTK_STATE_NORMAL],
>             play3_xpm);
> 
>     for(ptr = 0; ptr < 4; ptr ++) {
>         gdk_pixmap_unref (play_pix[ptr]);
>         gdk_bitmap_unref (play_mask[ptr]);    /* CRASH CRASH CRASH */
>     }
> 
> Is the gtk_widget_realize even necessary? What is it anyways? I added it
> in later thinking it might stop the crashing... the error seems to always
> happen when trying 'gdk_bitmap_unref(play_mask[ptr])'. I have 2 linked
> lists but I've checked every line of this code a few times. I have no idea
> where the error might be. Please help me to confirm whether this code is
> wrong or not so I that I might look elsewhere.
> 
> Travis Loyd
> [email: lelandg@usa.net                         Encrypt your email too: ]
> [ (* GNU Privacy Guard, make the switch today! *)  http://www.gnupg.org ]
> [  pgp: send email with subject: sendmepgp      or http://www.pgp.com   ]
> 
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


Perhaps "play_pix[++ptr]" is not evaluated before "&play_mask[ptr]" (not all
compilers do this in the same order).
Try to increment ptr outside this line.

And check that play_mask[ptr] is not Null.

gtk_widget_realize can be necessary because you need a window for creating the
pixmap.

Good luck,

	- José Miguel



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