Bug: push_visual/push_colormap bug related to styles on certain machines.



I have included a short example below.

I see this on Solaris, but it runs with no complaints on RH Linux 6.0.

I am using glib/gtk 1.2.3 and imlib 1.9.4 I was not able to determine
if it might be an imlib problem.

The example program below displays a window for a short while before 
entering the main loop. The purpose of this was to display a splash
screen with a pixmap and a status bar in it to let the user know how
initialization was going. Since this code was not needed to reproduce
the bug, it has been removed. After displaying and hiding the splash
screen a window containing a ctree is opened. Clicking the right mouse
button opens a popup menu.

You should be able to use the command at the top of the source file
to compile the example. In the current state, there are no problems. 
If you uncomment the #define WITH_PIXMAP line ( around line 12 in the
example ) you may see the following.

Gtk-CRITICAL **: file gtkstyle.c: line 683 (gtk_style_destroy):
assertion `style->attach_count == 0' failed.

Gtk-CRITICAL **: file gtkstyle.c: line 575 (gtk_style_unref): assertion
`style->ref_count > 0' failed.

Gtk-CRITICAL **: file gtkstyle.c: line 575 (gtk_style_unref): assertion
`style->ref_count > 0' failed.

Gtk-CRITICAL **: file gtkstyle.c: line 575 (gtk_style_unref): assertion
`style->ref_count > 0' failed.

Gtk-CRITICAL **: file gtkstyle.c: line 575 (gtk_style_unref): assertion
`style->ref_count > 0' failed.


Any help would be appreciated.

thanks,
Todd.


-- 
   | Todd Dukes                      E-MAIL:  tdukes@ibmoto.com |
   | Motorola Somerset                  Phone:   (512) 424-8008 |
   | 6200 Bridgepoint Parkway Building #4 MS OE70               |
   | Austin, Texas 78730                                        |
/*
 i="sst"; \
 g++ -o ${i} -I. `gtk-config --cflags` `gtk-config --libs` \
 `imlib-config --cflags --libs-gdk`  ${i}.c
*/

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

/*
#define WITH_PIXMAP
*/

#define TRACE_LINE printf("%s:%d\n", __FILE__, __LINE__ );

gint idle;

gint
clearIdle ( gpointer data ) 
{
  printf("clearIdle\n");
  idle = TRUE;
  return 0;
}

void
update ()
{
  gtk_idle_add_priority ( GTK_PRIORITY_DEFAULT,
			  ( GtkFunction ) clearIdle, 0 );

}

void
itemcallback ( gpointer data )
{
  printf ( "callback\n " );
}

void
buttonPress ( GtkWidget *ebox, GdkEventButton *event, gpointer data )
{
  char pc[1024];
  static GtkItemFactory *item_factory = 0;

  if ( item_factory )
    gtk_object_destroy ( GTK_OBJECT ( item_factory ) );
  
  if ( event -> button == 3 )
    {
      printf ( "buttonPress\n" );

      sprintf ( pc, "/button pressed at %d, %d ", event -> x, event -> y );

      item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<main>", 0 );

      {
	GtkItemFactoryEntry  entry;
	GtkWidget           *menu;  
	entry . path = pc;
	entry . accelerator = 0;
	entry . callback = &itemcallback;
	entry . callback_action = 0;
	entry . item_type = "<Item>";

	gtk_item_factory_create_items (item_factory, 1, &entry, "message" );
	gtk_item_factory_create_items (item_factory, 1, &entry, "message2" );

	menu = gtk_item_factory_get_widget ( item_factory, "" );

	gtk_menu_popup ( GTK_MENU ( menu ) ,
			 0, 0, 0, 0, event -> button, event -> time );
      }
    }
}

int
main ( int argc, char *argv [] )
{

  GtkWidget * window;
  GtkWidget * window2;
  GtkWidget * vbox;
  GtkWidget * ctree;
  GdkImlibImage * im;
  gint w;
  gint h;
  GdkImlibColorModifier mod;
  GdkPixmap * p;
  GdkPixmap * m;
  GtkWidget * pixmap;

  gtk_init ( &argc, &argv );

#ifdef  WITH_PIXMAP

  gdk_imlib_init ();

  gtk_widget_push_visual ( gdk_imlib_get_visual () );
  gtk_widget_push_colormap ( gdk_imlib_get_colormap () );

#endif

  window = gtk_window_new ( GTK_WINDOW_DIALOG );

  vbox = gtk_vbox_new ( FALSE, 0 );
  gtk_container_add ( GTK_CONTAINER ( window ), vbox );

  gtk_widget_show_all ( window );
  gdk_flush ();

  printf ("start processing pending events\n" );
  idle = FALSE;
  update ();
  printf ( " done with pending events\n" );
  printf ("sleep\n");
  sleep ( 2 );

#ifdef WITH_PIXMAP
  gtk_widget_pop_visual ();
  gtk_widget_pop_colormap ();
#endif

  gtk_widget_hide ( window );

  update ();

  window2 = gtk_window_new ( GTK_WINDOW_TOPLEVEL );
  
  gtk_widget_set_usize ( window2, 200, 200 );

  ctree = gtk_ctree_new ( 2, 0 );

  gtk_container_add ( GTK_CONTAINER ( window2 ), ctree );

  gtk_signal_connect (GTK_OBJECT (window2), "destroy",
		      GTK_SIGNAL_FUNC(gtk_main_quit),
		      NULL);
  gtk_signal_connect (GTK_OBJECT (window2), "delete-event",
		      GTK_SIGNAL_FUNC (gtk_false),
		      NULL);

  gtk_signal_connect ( GTK_OBJECT ( ctree ), "button_press_event",
		       GTK_SIGNAL_FUNC ( buttonPress ), NULL );

  gtk_widget_show_all ( window2 );
  gtk_main ();

  return 0;
}



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