Hello, All.

   Sorry for my English. When i try create and destroy widget with changed style, I 
get 
   Gtk-CRITICAL **: file gtkstyle.c: line 606 (gtk_style_ref): assertion 
`style->ref_count > 0' failed.
   
   What's wrong ? See my code:

#include <gtk/gtk.h>
#include <stdio.h>

static GtkWidget *create_mw(void);
static GtkWidget *create_button(void);

int main(int argc, char *argv[])
{
   gtk_set_locale();
   gtk_init(&argc, &argv);

   create_mw();

   gtk_main();

   return (0);
}

static GtkWidget *create_mw()
{
   int                  i;
   GtkWidget            *mw, *button;

   mw = gtk_widget_new(gtk_window_get_type(),
                       "GtkObject::user_data", NULL,
                       "GtkWindow::type", GTK_WINDOW_TOPLEVEL,
                        NULL);

   gtk_signal_connect(GTK_OBJECT(mw), "destroy",
                      GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
   gtk_widget_show(mw);

   for (i = 0; i < 100; ++i)
   {
      button = create_button();

      gtk_widget_destroy(button);

      printf("i - %d\n", i);
   }
   
   return (mw);
}

static GtkWidget *create_button()
{
   GtkWidget    *foo, *button;
   GtkStyle     *style;
   GdkPixmap    *pixmap;      
   GdkBitmap    *mask = NULL; 

   button = gtk_fixed_new();
   gtk_widget_set_usize(button, 143, 19); 
   gtk_widget_show(button);

   pixmap = gdk_pixmap_colormap_create_from_xpm(NULL,                         
                                                gtk_widget_get_colormap(button), 
                                                &mask, NULL, "button.xpm");      
                                                                              
   gtk_style_unref(button->style);                                            
   style = gtk_style_copy(gtk_widget_get_default_style());                    
   style->bg_pixmap[GTK_STATE_NORMAL] = pixmap;                               
   gtk_widget_set_style(button, style);                                       

   foo = gtk_label_new("test");
   gtk_fixed_put(GTK_FIXED(button), foo, 5, 0);
   gtk_widget_show(foo);

   return (button);
}

Output:

[bash]$ ./bg_xpm
i - 0
i - 1
i - 2

Gtk-CRITICAL **: file gtkstyle.c: line 606 (gtk_style_ref): assertion 
`style->ref_count > 0' failed.
i - 3
i - 4
i - 5
i - 6
i - 7
Segmentation fault (core dumped)

                                                // DS


_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to