gtktext bug



i can't tell if this is a bug in the text widget, or my program.. i'm 
getting this error:

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

i'm using the latest gtk-1-0 from cvs. it also affects the 1.1 cvs tree
 
i don't understand why this is happening. it seems like one of those
situations that happens only under a full moon on the second tuesday of an
odd month..

here's my code:

/* texttest.c  */

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

/* ANSI color codes */
GdkColor	ansiblack = { 0, 0x0000, 0x0000, 0x0000 };
GdkColor	ansiwhite = { 0, 0xffff, 0xffff, 0xffff };
GdkColor 	ansicolors[8] = {
    { 0, 0x0000, 0x0000, 0x0000 },
    { 0, 0xcd00, 0x0000, 0x0000 },
    { 0, 0x0000, 0xcd00, 0x0000 },
    { 0, 0xcd00, 0xcd00, 0x0000 },
    { 0, 0x0000, 0x0000, 0xcd00 },
    { 0, 0xcd00, 0x0000, 0xcd00 },
    { 0, 0x0000, 0xcd00, 0xcd00 },
    { 0, 0xe500, 0xe500, 0xe500 }
};

GdkColor 	ansicolors_bold[8] = {
    { 0, 0x4d00, 0x4d00, 0x4d00 },
    { 0, 0xffff, 0x0000, 0x0000 },
    { 0, 0x0000, 0xffff, 0x0000 },
    { 0, 0xffff, 0xffff, 0x0000 },
    { 0, 0x0000, 0x0000, 0xffff },
    { 0, 0xffff, 0x0000, 0xffff },
    { 0, 0x0000, 0xffff, 0xffff },
    { 0, 0xffff, 0xffff, 0xffff }
};

void texttest (GtkWidget *data)
{
    gchar 	buffer[2047];
    GdkColor	*fore;
    GdkColor	*back;
    
    fore = &ansiblack;
    back = &ansiwhite;
    sprintf(buffer,"\n");
    gtk_text_insert(GTK_TEXT (data), NULL, fore, back, buffer, strlen(buffer));

    fore = &ansicolors_bold[4];
  /** note: if fore is assigned to ansiblack, the SIGABRT does not occur **/


  /*******  The program breaks here  ********/
    sprintf(buffer,"to core, or not to core.."); gtk_text_insert(GTK_TEXT (data), NULL, fore, back, buffer, strlen(buffer));
}

void alloc_colors(GtkWidget *window)
{
    int		i;
    
    for (i=0;i<8;i++)
    {
      gdk_color_alloc(gtk_widget_get_colormap(window), &ansicolors[i]);
      gdk_color_alloc(gtk_widget_get_colormap(window), &ansicolors_bold[i]);
    }

    gdk_color_alloc(gtk_widget_get_colormap(window), &ansiwhite);
    gdk_color_alloc(gtk_widget_get_colormap(window), &ansiblack);
}

gint main (int argc, char *argv[])
{                                  
    GtkWidget	*window;
    GtkWidget	*box1;
    GtkWidget	*box2;
    GtkWidget	*table;
    GtkWidget	*button;
    GtkWidget	*text;
    GtkWidget	*vscrollbar;
    
    gtk_init(&argc, &argv);

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_usize(window, 650, 200);
    gtk_window_set_title(GTK_WINDOW(window), "text test");
    gtk_container_border_width (GTK_CONTAINER (window), 0);
    gtk_signal_connect(GTK_OBJECT(window),
		       "destroy",
		       GTK_SIGNAL_FUNC(gtk_main_quit),
		       NULL);

    alloc_colors(window);
    
    box1 = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), box1);
    gtk_widget_show (box1);


    box2 = gtk_vbox_new (FALSE, 5);
    gtk_container_border_width (GTK_CONTAINER (box2), 5);
    gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
    gtk_widget_show (box2);

    table = gtk_table_new (2, 2, FALSE);
    gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
    gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
    gtk_container_border_width (GTK_CONTAINER (table), 5);
    gtk_box_pack_start (GTK_BOX (box2), table, TRUE, TRUE, 0);
    gtk_widget_show (table);
    
    text=gtk_text_new(NULL, NULL);
    gtk_text_set_editable (GTK_TEXT (text), FALSE);
    gtk_text_set_word_wrap (GTK_TEXT (text), TRUE);
    gtk_table_attach (GTK_TABLE (table), text, 0, 1, 0, 1,
		      GTK_EXPAND | GTK_SHRINK | GTK_FILL,
		      GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);

    gtk_widget_show(text);

    vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj);
    gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1,
		      GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
    gtk_widget_show (vscrollbar);

    
    button=gtk_button_new_with_label("Close");
    gtk_box_pack_start (GTK_BOX(box2), button, TRUE, TRUE, 0);
    gtk_widget_show(button);
    gtk_signal_connect_object(GTK_OBJECT(button),
			      "clicked",
			      GTK_SIGNAL_FUNC(gtk_widget_destroy),
			      GTK_OBJECT(window));
    
    gtk_widget_show(window);

    texttest(text);
    
    gtk_main();
    
    return 0;
}
 _        _  __     __             _ _                                  _
|        / |/ /_ __/ /_____         |       Nuke Skyjumper               |
|       /    / // /  '_/ -_)        |         "Master of the Farce"      |
|_     /_/|_/\_,_/_/\_\\__/        _|_           nuke@bayside.net       _|



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