What does "Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed" mean?



Hello,

I just started developing GTK+ Applications.

But now I get the following error message and a broken Text when clicking back in to the GTKEntry widget:

(gtk-keygen:18220): Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= 
layout->length' failed


Here is the code causing this Problem:


static void activate (GtkApplication *app, gpointer user_data)
{
        GtkWidget *window;
        GtkWidget *grid;
        GtkWidget *label_exp_date;
        GtkWidget *input_exp_date;
        GtkWidget *spacer;
        GtkWidget *out_head;
        GtkWidget *out_gen;
        GtkWidget *gen_button;

        /* Create window */ 
        window = gtk_application_window_new (app);
        gtk_window_set_title (GTK_WINDOW (window), PACKAGE_STRING);
        gtk_container_set_border_width (GTK_CONTAINER (window), 10);

        /* Here we construct the container that is going pack our content */
        grid = gtk_grid_new ();
        gtk_grid_set_column_spacing (GTK_GRID (grid), 5);
        gtk_grid_set_row_spacing (GTK_GRID (grid), 5);

        /* Pack the container in the window */
        gtk_container_add (GTK_CONTAINER (window), grid);

        /* Create head label */
        label_exp_date = gtk_label_new ("Key generator for garmin-srv.");
        gtk_grid_attach (GTK_GRID (grid), label_exp_date, 0, 0, 3, 1);

        /* Spacer */
        spacer = gtk_label_new ("");
        gtk_grid_attach (GTK_GRID (grid), spacer, 0, 1, 1, 1);

        /* Key generator area */
        label_exp_date = gtk_label_new ("Enter expiration date (dd.mm.YYYY):");
        gtk_grid_attach (GTK_GRID (grid), label_exp_date, 0, 1, 1, 1);
        
        input_exp_date = gtk_entry_new ();
        gtk_entry_set_width_chars (GTK_ENTRY (input_exp_date), 10);
        gtk_entry_set_max_length (GTK_ENTRY (input_exp_date), 10);
        gtk_grid_attach (GTK_GRID (grid), input_exp_date, 1, 1, 1, 1);
        
        gen_button = gtk_button_new_with_label ("Generate");
        gtk_widget_set_halign (GTK_WIDGET (gen_button), GTK_ALIGN_END);
        gtk_grid_attach (GTK_GRID (grid), gen_button, 2, 1, 1, 1);

        /* Result area */
        out_head = gtk_label_new ("Generated key:");
        gtk_grid_attach (GTK_GRID (grid), out_head, 0, 2, 1, 1);
        
        GtkEntryBuffer *keybuf;
        keybuf = gtk_entry_buffer_new ("Not yet generated", 45);
        out_gen = gtk_entry_new_with_buffer (GTK_ENTRY_BUFFER (keybuf));
        gtk_entry_set_width_chars (GTK_ENTRY (out_gen), 50);
        gtk_editable_set_editable (GTK_EDITABLE (out_gen), FALSE);
        gtk_widget_set_can_focus (GTK_WIDGET (out_gen), FALSE);
        gtk_grid_attach (GTK_GRID (grid), out_gen, 1, 2, 1, 1);

        
        g_object_set_data (G_OBJECT(gen_button), "input", input_exp_date);
        g_object_set_data (G_OBJECT(gen_button), "output", out_gen);
        
        /* Exit when the window is closed */
        g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

        g_signal_connect (gen_button, "clicked", G_CALLBACK (gtkGenKey),
                                          gen_button);

        // g_signal_connect (gen_button, "clicked", G_CALLBACK (showKey), keybuf);

        gtk_widget_show_all (window);
}

Can somebody help me and tell me what I am doing wrong?

Best Regards,
Dirk

-- 
Dirk Gottschalk, Aachen
Tel.: 01573 / 1152350
eMail: dirk gottschalk1980 googlemail com


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