Problem with GtkTreeModel, simultaneous iterating and append

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

 



Hi,

is it possible to append a row to a TreeModel while having
an iterator going through the same model?

I have a code snippet that does just the same,
the second time the code runs
the second gtk_tree_model_get_iter_first() seems to succeed
but gives an invalid iterator, as I get invalid values.

I use an uptodate fedora core, gtk2-2.2.4-5.1.

This is the code:

void utolso_sztorno(void) {
	GtkTreeIter	iter, iter1;
	int		sorsz, sorsz1, lancfej, lancresz, gyujto, afa,
			prev, next;
	gchar		*tranz, *vk, *nev, *afajel, *egys;
	double		szorzo, ar, osszeg;

	if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ptgdb_internal->tetelek), &iter)) {
		do {
			gtk_tree_model_get (GTK_TREE_MODEL(ptgdb_internal->tetelek), &iter,
				TETEL_SORSZ, &sorsz, TETEL_PREV, &lancresz, -1);
			if (!lancresz)
				lancfej = sorsz;
		} while (gtk_tree_model_iter_next (GTK_TREE_MODEL(ptgdb_internal->tetelek), &iter));
#if 0 /* makes no difference */
		memset(&iter, 0, sizeof(iter));
#endif
		if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ptgdb_internal->tetelek), &iter))
		do {
			gtk_tree_model_get (GTK_TREE_MODEL(ptgdb_internal->tetelek), &iter,
				TETEL_SORSZ, &sorsz1, TETEL_TRANZAK, &tranz,
				TETEL_VKOD, &vk, TETEL_NEV, &nev,
				TETEL_GYUJTO, &gyujto, TETEL_AFA, &afa,
				TETEL_AFAJEL, &afajel, TETEL_SZORZO, &szorzo,
				TETEL_EGYSEG, &egys, TETEL_AR, &ar,
				TETEL_OSSZEG, &osszeg, TETEL_PREV, &prev,
				TETEL_NEXT, &next, -1);
/* here I get invalid numbers on the second run, seems to be un-initialized */
printf("sorsz: %d\n", sorsz1);
			if (sorsz1 > sorsz)
				break;
			if ((sorsz1 >= lancfej) && (sorsz1 <= sorsz)) {
				gtk_list_store_set (ptgdb_internal->tetelek,
					&iter1, TETEL_SZTORNO, TRUE,
					osszeg, -1);
				gtk_list_store_append (ptgdb_internal->tetelek, &iter1);
				gtk_list_store_set(ptgdb_internal->tetelek, &iter1,
					TETEL_SORSZ, sorsz1 + sorsz - lancfej + 1,
					TETEL_TRANZAK, tranz,
					TETEL_VKOD, vk, TETEL_NEV, nev,
					TETEL_SZTORNO, TRUE, TETEL_IGAZITAS, 1.0,
					TETEL_GYUJTO, gyujto,
					TETEL_AFA, afa, TETEL_AFAJEL, afajel,
					TETEL_SZORZO, -szorzo,
					TETEL_EGYSEG, egys,
					TETEL_AR, ar, TETEL_OSSZEG, -osszeg,
					TETEL_PREV, prev, TETEL_NEXT, next,
					-1);
			}
		} while (gtk_tree_model_iter_next (GTK_TREE_MODEL(ptgdb_internal->tetelek), &iter1));
	} else
		gdk_beep();
}


-- Best regards, Zoltán Böszörményi

---------------------
What did Hussein say about his knife?
One in Bush worth two in the hand.

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux