Non-atomicity in gtk_list_store_insert(), gtk_list_store_set()


Currently one modifies a GtkListStore or GtkTreeStore like this:

	GtkTreeIter iter;

	gtk_list_store_insert (list_store, N, &iter);
	gtk_list_store_set (list_store, &iter,
			    0, "foo",
			    1, "bar",

However, consider the case where other code connects to "row-inserted"
on the model.  This will get emitted from inside
gtk_list_store_insert(), but when the callback does
gtk_tree_model_get(), it will get null data as the row's data has not
been set yet.

This is a problem for filtered models and everything else, as your
custom filtering function must explicitly test for null data.

I guess this can be solved easily by providing

void gtk_list_store_insert_and_set (GtkListStore *list_store,
				    GtkTreeIter  *iter,
				    int           position,
				    int           first_column,

The idea is to call it like this:

	gtk_list_store_insert_and_set (list_store, &iter, N,
				       0, "foo",
				       1, "bar",

This would make the insertion+modification atomic; the append_and_set()
version would be analogous.  Only the "insert-row" signal would be

Should we have this, and deprecate the old insert()/append() functions? 
set() can remain in place, as it is needed to modify existing rows.


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