Pango-CRITICAL during g_main_context_iteration (NULL, FALSE)



To gtk gurus

I want to put a new title as soon as possible to the mainwindow when en
entry change.
For that I must have all pending call back executed. the only way I know is
to put the following
statment in the entry call back :

    while (g_main_context_iteration (NULL, FALSE));

And when that statment is there i get the Pango-CRITICAL message.

After deletion of maximum code,a small piece of code shows my problem :

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

typedef struct widgets
{
    GtkEntry        * entry1;
    gulong            signal_entry1;
} widgets;

static GtkWidget   * MainWindow           = NULL;
static widgets       w;

static int cb_entry_changed (GtkWidget * entry, gpointer p_data)
{
    while (g_main_context_iteration (NULL, FALSE)); /* pango-CRITICAL ... */

    printf ("Entry changed\n");
    return FALSE;
}

static void window_destroy (GtkWidget * window, gpointer p_data)
{
    gtk_main_quit ();
}

static void create_and_connect_window (GtkBuilder * builder, char *
glade_file)
{
    GError     *error = NULL;

    if( ! gtk_builder_add_from_file( builder, glade_file, &error ) )
    {
        g_warning( "%s", error->message );
        g_free( error );
        return;
    }

    MainWindow = GTK_WIDGET( gtk_builder_get_object( builder, "entry_test"
));

    /* Connect signals */

    gtk_builder_connect_signals( builder, NULL );
    g_signal_connect (MainWindow, "delete-event", G_CALLBACK
(window_destroy), NULL);

    w.entry1 = GTK_ENTRY (gtk_builder_get_object (builder, "entry1"));
    w.signal_entry1 = g_signal_connect (G_OBJECT (w.entry1), "changed",
G_CALLBACK (cb_entry_changed), NULL);
}

int
main( int    argc,
      char **argv )
{
    GtkBuilder * builder;
    gtk_init( &argc, &argv );
    builder = gtk_builder_new();
    create_and_connect_window (builder, "bck.glade");

    if (MainWindow == NULL)
    {
        printf ("issu dureind creation of mainwindow\n");
    }

    g_object_unref( G_OBJECT( builder ) );
    gtk_widget_show( MainWindow );
    gtk_main();

    return 0;
}

And at the run :

When I enter a new character

Entry changed
Entry changed
Entry changed
Entry changed

When I enter backspace

(entry_test:4677): Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion
`index >= 0 && index <= layout->length' failed

(entry_test:4677): Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion
`index >= 0 && index <= layout->length' failed

(entry_test:4677): Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion
`index >= 0 && index <= layout->length' failed

Is there other mean to obtain the wanted effect ?

Claude SIMON

Mail : claude simon 78 gmail com



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