[patch] GtkText widget bug?



Under certain circumstances, when using the GtkText widget in
gtk+-0.99.2, I get assertion failures in the advance_mark_n() function
related to the GtkText widget.  It apprears that the widget is being
exposed, something goes on in draw_line(), and draw_line() calls
advance_mark_n() with n = 0.  This causes an assertion failure in
advance_mark_n().

This happens in a program where I am doing the following things:

1. Creating a window with a GtkText widget
2. Show the window.
3. Add some text to the window.  
4. Call gtk_main_iteration() from my program.  

The problem seems to be highly timing dependant, so I couldn't 
create a program to reliably demonstrate the problem, but here is 
the relevent portion of a stack trace in gdb:

** ERROR **: file gtktext.c: line 1968 (advance_mark_n): "n > 0"

Program received signal SIGABRT, Aborted.
0x40024665 in __kill ()
(gdb) bt
#0  0x40024665 in __kill ()
#1  0x4004a33d in raise (sig=1075254216)
#2  0x4015421f in advance_mark_n (mark=0xbffff3e8, n=0) at gtktext.c:1968
#3  0x40155eb9 in draw_line (text=0x8070740, pixel_start_height=0, 
    lp=0x8072b60) at gtktext.c:3053
#4  0x40156576 in expose_text (text=0x8070740, area=0x8071350, cursor=1 '\001')
    at gtktext.c:3283
#5  0x40152514 in gtk_text_expose (widget=0x8070740, event=0x8071348)
    at gtktext.c:907
#6  0x40165799 in gtk_widget_marshal_signal_4 (object=0x8070740, 
    func=0x40152460 <gtk_text_expose>, func_data=0x0, args=0xbffff4f0)
    at gtkwidget.c:2749
#7  0x4014a994 in gtk_signal_real_emit (object=0x8070740, signal_type=22, 
    args=0xbffff6d0) at gtksignal.c:904
#8  0x40149989 in gtk_signal_emit () at gtksignal.c:715
#9  0x40163f3a in gtk_widget_event () at gtkwidget.c:1606
#10 0x40130cec in gtk_main_iteration () at gtkmain.c:480


I'm not sure is this is the proper way to fix it, but here is a patch 
that makes the assertion failues go away.  (That is, advance_mark_n now
accepts n = 0).

--- gtk+-0.99.2/gtk/gtktext.c.old       Sat Jan 10 15:30:31 1998
+++ gtk+-0.99.2/gtk/gtktext.c   Sat Jan 10 15:30:41 1998
@@ -1965,7 +1965,7 @@
 {
   gint i;
 
-  g_assert (n > 0);
+  g_assert (n >= 0);
 
   for (i = 0; i < n; i += 1)
     advance_mark (mark);

--
Matt Kimball
mkimball@xmission.com



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