aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-09-21 15:18:26 +0800
committerChris Lahey <clahey@src.gnome.org>2000-09-21 15:18:26 +0800
commit1771bc9932db7343e284d38507b7d639feafd750 (patch)
treeb6fc6ebb3ce3b9236489b559d147b2186228953d /e-util
parent9e6e29ee3ce7bb0f757d17fa02f44edc99ca592b (diff)
downloadgsoc2013-evolution-1771bc9932db7343e284d38507b7d639feafd750.tar.gz
gsoc2013-evolution-1771bc9932db7343e284d38507b7d639feafd750.tar.zst
gsoc2013-evolution-1771bc9932db7343e284d38507b7d639feafd750.zip
Made e_list a bit more reentrant. If a iterator gets its data pulled out
2000-09-18 Christopher James Lahey <clahey@helixcode.com> * e-list-iterator.c, e-list.c, e-list.h: Made e_list a bit more reentrant. If a iterator gets its data pulled out from under it while in a loop, it goes back one so that loops will be able to continue. svn path=/trunk/; revision=5533
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog7
-rw-r--r--e-util/e-list-iterator.c7
-rw-r--r--e-util/e-list.c19
-rw-r--r--e-util/e-list.h6
4 files changed, 31 insertions, 8 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 81bc3c5122..3174e3db52 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,5 +1,12 @@
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
+ * e-list-iterator.c, e-list.c, e-list.h: Made e_list a bit more
+ reentrant. If a iterator gets its data pulled out from under it
+ while in a loop, it goes back one so that loops will be able to
+ continue.
+
+2000-09-18 Christopher James Lahey <clahey@helixcode.com>
+
* Makefile.am: Removed all the files moved to gal.
* e-dialog-widgets.c: Fixed the #include lines to deal properly
diff --git a/e-util/e-list-iterator.c b/e-util/e-list-iterator.c
index 51480447b4..360e37ca40 100644
--- a/e-util/e-list-iterator.c
+++ b/e-util/e-list-iterator.c
@@ -208,12 +208,7 @@ e_list_iterator_delete (EIterator *_iterator)
{
EListIterator *iterator = E_LIST_ITERATOR(_iterator);
if (iterator->iterator) {
- GList *temp = iterator->iterator->next;
- if (iterator->list->free)
- iterator->list->free(iterator->iterator->data, iterator->list->closure);
- iterator->list->list = g_list_remove_link(iterator->list->list, iterator->iterator);
- iterator->iterator = temp;
- e_list_invalidate_iterators(iterator->list, E_ITERATOR(iterator));
+ e_list_remove_link (iterator->list, iterator->iterator);
}
}
diff --git a/e-util/e-list.c b/e-util/e-list.c
index 2a6f842888..6fd0e559d5 100644
--- a/e-util/e-list.c
+++ b/e-util/e-list.c
@@ -140,6 +140,24 @@ e_list_invalidate_iterators (EList *list, EIterator *skip)
}
}
+/* FIXME: This doesn't work properly if the iterator is the first
+ iterator in the list. Well, the iterator doesn't continue on after
+ the next time next is called, at least. */
+void
+e_list_remove_link (EList *list, GList *link)
+{
+ GList *iterators = list->iterators;
+ for (; iterators; iterators = iterators->next) {
+ if (((EListIterator *)iterators->data)->iterator == link) {
+ e_iterator_prev(iterators->data);
+ }
+ }
+ if (list->free)
+ list->free(link->data, list->closure);
+ list->list = g_list_remove_link(list->list, link);
+ g_list_free_1(link);
+}
+
void
e_list_remove_iterator (EList *list, EIterator *iterator)
{
@@ -156,3 +174,4 @@ e_list_destroy (GtkObject *object)
g_list_foreach(list->list, (GFunc) list->free, list->closure);
g_list_free(list->list);
}
+
diff --git a/e-util/e-list.h b/e-util/e-list.h
index 7a0170970f..017f48d813 100644
--- a/e-util/e-list.h
+++ b/e-util/e-list.h
@@ -50,10 +50,12 @@ void e_list_append (EList *list,
int e_list_length (EList *list);
/* For iterators to call. */
-void e_list_invalidate_iterators (EList *list,
- EIterator *skip);
+void e_list_remove_link (EList *list,
+ GList *link);
void e_list_remove_iterator (EList *list,
EIterator *iterator);
+void e_list_invalidate_iterators (EList *list,
+ EIterator *skip);
/* Standard Gtk function */
GtkType e_list_get_type (void);