Ref problem with styles
- From: Eneko Lacunza <elacunza djb es>
- To: gtk-app-devel-list gnome org
- Subject: Ref problem with styles
- Date: 17 Dec 2001 12:04:06 +0100
Hi folks! 8)
I'd developing an small application with gtk, but I have some problems
with styles and buttons.
I have a window with 12 labeled buttons. I have two styles, A and B,
that I use to change button's background pixmap.
During application use, I change button's style depending on its label
content.
The problem I have is that after several style changes, I receive some
errors, and finally the app crashes.
Style construction:
-------------------
static GdkPixmap *aukeratutako_fondoa=NULL;
static GdkPixmap *fondo_arrunta=NULL;
static GdkPixmap *bideo_fondoa=NULL;
static GdkPixmap *bideo_aukeratutako_fondoa=NULL;
static GtkStyle* BideoBotoiEstiloa = NULL;
static GtkStyle* AbestiBotoiEstiloa = NULL;
/* GdkPixmaps get loaded correctly */
AbestiBotoiEstiloa =
gtk_style_copy(gtk_widget_get_default_style());
gtk_style_ref(AbestiBotoiEstiloa);
AbestiBotoiEstiloa->bg_pixmap[GTK_STATE_NORMAL] = fondo_arrunta;
gdk_pixmap_ref(fondo_arrunta);
AbestiBotoiEstiloa->bg_pixmap[GTK_STATE_ACTIVE] = fondo_arrunta;
gdk_pixmap_ref(fondo_arrunta);
AbestiBotoiEstiloa->bg_pixmap[GTK_STATE_PRELIGHT] =
fondo_arrunta;
gdk_pixmap_ref(fondo_arrunta);
AbestiBotoiEstiloa->bg_pixmap[GTK_STATE_SELECTED] =
aukeratutako_fondoa;
gdk_pixmap_ref(aukeratutako_fondoa);
AbestiBotoiEstiloa->bg_pixmap[GTK_STATE_INSENSITIVE] =
fondo_arrunta;
gdk_pixmap_ref(fondo_arrunta);
BideoBotoiEstiloa = gtk_style_copy(AbestiBotoiEstiloa);
gtk_style_ref(BideoBotoiEstiloa);
BideoBotoiEstiloa->bg_pixmap[GTK_STATE_NORMAL] = bideo_fondoa;
gdk_pixmap_ref(bideo_fondoa);
BideoBotoiEstiloa->bg_pixmap[GTK_STATE_ACTIVE] = bideo_fondoa;
gdk_pixmap_ref(bideo_fondoa);
BideoBotoiEstiloa->bg_pixmap[GTK_STATE_PRELIGHT] = bideo_fondoa;
gdk_pixmap_ref(bideo_fondoa);
BideoBotoiEstiloa->bg_pixmap[GTK_STATE_SELECTED] =
bideo_aukeratutako_fondoa;
gdk_pixmap_ref(bideo_aukeratutako_fondoa);
BideoBotoiEstiloa->bg_pixmap[GTK_STATE_INSENSITIVE] =
bideo_fondoa;
gdk_pixmap_ref(bideo_fondoa);
BideoBotoiEstiloa->engine = NULL;
Style change on buttons:
------------------------
if(A)
{
gtk_widget_set_style(AP_botoiak[i],
gtk_style_ref(BideoBotoiEstiloa));
}
else
{
gtk_widget_set_style(AP_botoiak[i],
gtk_style_ref(AbestiBotoiEstiloa));
}
Errors on stderr
----------------
Gdk-CRITICAL **: file gdkpixmap.c: line 823 (gdk_pixmap_unref):
assertion `private->ref_count > 0' failed.
Gdk-CRITICAL **: file gdkpixmap.c: line 823 (gdk_pixmap_unref):
assertion `private->ref_count > 0' failed.
Gdk-CRITICAL **: file gdkpixmap.c: line 823 (gdk_pixmap_unref):
assertion `private->ref_count > 0' failed.
<...more execution ...>
Gdk-CRITICAL **: file gdkpixmap.c: line 823 (gdk_pixmap_unref):
assertion `private->ref_count > 0' failed.
Gdk-CRITICAL **: file gdkpixmap.c: line 823 (gdk_pixmap_unref):
assertion `private->ref_count > 0' failed.
Gdk-CRITICAL **: file gdkpixmap.c: line 823 (gdk_pixmap_unref):
assertion `private->ref_count > 0' failed.
<... execution until window redrawing (it seems) ...>
Gdk-ERROR **: BadPixmap (invalid Pixmap parameter)
serial 9796 error_code 4 request_code 2 minor_code 0
Gdk-ERROR **: BadPixmap (invalid Pixmap parameter)
serial 9831 error_code 4 request_code 2 minor_code 0
I partly understand the error, but I don't know what I'm doing wrong,
as I don't unref styles and pixmaps anytime... The first error block,
that appears just in the gtk_widget_set_style execution, appears when
button's style is changed about 24 times (each button's style is changed
about 2-3 times).
I think the crash happens because my GdkPixmap get unallocated from
memory, but what is doing that? How can fix it?
I'll appreciate any comment.
Thanks a lot!
--
Eneko Lacunza
Desarrollo y Sistemas
DJB Digital Jukebox S.L.
España
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]