Gtk-CRITICAL gtk_css_node_insert_after assertion

please refer to the following code:

#include <gtk/gtk.h>

static GtkTreeModel * create_model( void )
{
     GtkTreeIter iter;
     GtkTreeStore *model = gtk_tree_store_new ( 1, G_TYPE_STRING );

     gtk_tree_store_append( model, &iter, NULL );
     gtk_tree_store_set( model, &iter, 0, "one", -1 );

     /* add children */
     GtkTreeIter child_iter;
     gtk_tree_store_append( model, &child_iter, &iter );
     gtk_tree_store_set( model, &child_iter, 0, "one_a", -1 );

     GtkTreeIter child_child_iter;
     gtk_tree_store_append( model, &child_child_iter, &child_iter );
     gtk_tree_store_set( model, &child_child_iter, 0, "one_a_a", -1 );

     gtk_tree_store_append( model, &child_iter, &iter );
     gtk_tree_store_set( model, &child_iter, 0, "one_b", -1 );
     gtk_tree_store_append( model, &child_iter, &iter );
     gtk_tree_store_set( model, &child_iter, 0, "one_c", -1 );

     return GTK_TREE_MODEL( model );
}

static void do_tree_store( GtkApplication *app, gpointer user_data )
{
     GtkWidget *window = gtk_application_window_new( app );
     gtk_widget_show (window);
     gtk_window_set_title (GTK_WINDOW (window), "Tree Store");

     GtkWidget *treeview = gtk_tree_view_new_with_model( create_model() );
     gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( treeview ), -1, "Holiday", gtk_cell_renderer_text_new(), "text", 0, NULL );
     gtk_window_set_child( GTK_WINDOW( window ), treeview );
     gtk_window_set_default_size( GTK_WINDOW(window), 200, 200 );
}

int main( int argc, char **argv )
{
     GtkApplication *app = gtk_application_new( "hello.one", G_APPLICATION_DEFAULT_FLAGS );
     g_signal_connect( app, "activate", G_CALLBACK( do_tree_store ), NULL );
     int status = g_application_run( G_APPLICATION( app ), argc, argv );
     g_object_unref( app );

     return status;
}

I’m compiling and running with the following command

gcc packet_tree_view.c `pkg-config --cflags --libs gtk4` && ./a.out

I am expanding the tree with mouse. seeing all the branches are also being populated as expected.

After this, if I try to close with Alt+F4 consistently I am seeing the following error :

(a.out:154294): Gtk-CRITICAL **: 13:29:11.669: gtk_css_node_insert_after: assertion ‘previous_sibling == NULL || previous_sibling->parent == parent’ failed

But if I simply execute and close the window using mouse / Alt+F4 it is just fine.

Can someone help me fix so that I can use Alt+F4 and get rid of this error message.

Is there any issue with my code ?
:worried:

Your code doesn’t look bad. You could check in the GTK issue tracker for similar error messages, and file a new issue if you don’t find any. Make sure to attach your code.

@ebassi
Thanks.
Seems the same issue as

1 Like

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.