Re: gtk-app-devel-list Digest, Vol 87, Issue 18



Thanks for your answer.

I have a small piece of code witch show the issue :


/*----------------------------------------------------------------------------*/

#include <gtk/gtk.h>

typedef struct widgets
{
    GtkEntry        * entry1;
} widgets;

static GtkWidget   * MainWindow           = NULL;
static widgets       w;

static int Text_changed = FALSE;

static int cb_entry_changed (GtkWidget * entry, gpointer p_data)
{

    while (g_main_context_iteration (NULL, FALSE));

    Text_changed = TRUE;
    return FALSE;
}

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

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

    /* Load UI from file. If error occurs, report it and quit application.
     * Replace "tut.glade" with your saved project. */
    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, "bck" ));

    /* Connect signals */

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

    w.entry1 = GTK_ENTRY (gtk_builder_get_object (builder, "entry1"));
    g_signal_connect (G_OBJECT (w.entry1), "focus-out-event", G_CALLBACK
(cb_entry_changed), NULL);
    g_signal_connect (G_OBJECT (w.entry1), "changed",         G_CALLBACK
(cb_entry_changed), NULL);
    gtk_entry_set_text (w.entry1, (gchar *)"");

}

int
main( int    argc,
      char **argv )
{
    GtkBuilder * builder;

    /* Init GTK+ */
    gtk_init( &argc, &argv );

    /* Create new GtkBuilder object */
    builder = gtk_builder_new();

    /* Get main window from glade file and connect signals */
    create_and_connect_window (builder, "bck.glade");

    if (MainWindow == NULL)
    {
        printf ("problème de création de la fenetre principale\n");
    }

    /* Destroy builder, since we don't need it anymore */
    g_object_unref( G_OBJECT( builder ) );

    /* Show window. All other widgets are automatically shown by GtkBuilder
*/
    gtk_widget_show( MainWindow );

    /* Start main loop */
    gtk_main();

    return 0;
}

with the statment :
    while (g_main_context_iteration (NULL, FALSE));

I get the error :
(backspace_test:5952): Pango-CRITICAL **: pango_layout_get_cursor_pos:
assertion `index >= 0 && index <= layout->length' failed

My problem is how to block the signal when the program is initializing entry
and unblock it when it is the user which is acting.

I am investigating signal disconnect and reconnect. Is it the good way to go
?


Claude Simon

2011/7/22 <gtk-app-devel-list-request gnome org>

Send gtk-app-devel-list mailing list submissions to
       gtk-app-devel-list gnome org

To subscribe or unsubscribe via the World Wide Web, visit
       http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
or, via email, send a message with subject or body 'help' to
       gtk-app-devel-list-request gnome org

You can reach the person managing the list at
       gtk-app-devel-list-owner gnome org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of gtk-app-devel-list digest..."


Today's Topics:

  1. Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion
     `index >= 0       && index <= layout->length' failed (Claude Simon)
  2. Re: Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion
     `index    >= 0    && index <= layout->length' failed (Bill Czermak)


----------------------------------------------------------------------

Message: 1
Date: Thu, 21 Jul 2011 17:08:05 +0200
From: Claude Simon <claude simon 78 gmail com>
To: gtk-app-devel-list gnome org
Subject: Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion
       `index >= 0     && index <= layout->length' failed
Message-ID:
       <CAJ-OH1Y43gf5g5Btzy+GkrFEOd56OUqNdNChc+14U5BZk_6tjg mail gmail com

Content-Type: text/plain; charset=ISO-8859-1

hello to all the guys here,

I am new to gtk and I am doing a GUI for a program with it.

All is ok, but there is one thing i don't understand.

I have a call back entered when the event "changed" is triggered for a
GtkEntry widget.

When the user is deleting the last character with a backspace he get the
following message at console :

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

The call back routine is doing nothing else that signaling a change to be
saved.

The effective change in the database is done on triggering
"focus-out-event".

I am surely missing an obvious thing ...

What can i do to avoid such a  behavior ?

Claude Simon


------------------------------

Message: 2
Date: Fri, 22 Jul 2011 08:58:47 +1000
From: Bill Czermak <czermak netspace net au>
To: gtk-app-devel-list gnome org
Subject: Re: Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion
       `index  >= 0    && index <= layout->length' failed
Message-ID: <4E28AF27 3010201 netspace net au>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

If you can post a minimal piece of code that demonstrates the error,
then it makes it easier for people to help you.  Also in cutting back to
minimal code, you may well find the problem for yourself.

Rgds Bill

On 22/07/11 01:08, Claude Simon wrote:
hello to all the guys here,

I am new to gtk and I am doing a GUI for a program with it.

All is ok, but there is one thing i don't understand.

I have a call back entered when the event "changed" is triggered for a
GtkEntry widget.

When the user is deleting the last character with a backspace he get the
following message at console :

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

The call back routine is doing nothing else that signaling a change to be
saved.

The effective change in the database is done on triggering
"focus-out-event".

I am surely missing an obvious thing ...

What can i do to avoid such a  behavior ?

Claude Simon
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




------------------------------

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

End of gtk-app-devel-list Digest, Vol 87, Issue 18
**************************************************




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