[gimp] Fix gimp_data_factory_data_foreach()
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Fix gimp_data_factory_data_foreach()
- Date: Fri, 30 Oct 2009 21:51:29 +0000 (UTC)
commit 223cbeb6fb2646001b438351f9d4c736622511f8
Author: Michael Natterer <mitch gimp org>
Date: Fri Oct 30 22:50:02 2009 +0100
Fix gimp_data_factory_data_foreach()
Make the function do what is says also if the callback doesn't remove
the data from the factory, argh... also add "gboolean skip_internal"
parameter because doing that unconditionally feels equally broken.
app/core/gimpdatafactory.c | 41 ++++++++++++++---------------------------
1 files changed, 14 insertions(+), 27 deletions(-)
---
diff --git a/app/core/gimpdatafactory.c b/app/core/gimpdatafactory.c
index 9340896..03cd96a 100644
--- a/app/core/gimpdatafactory.c
+++ b/app/core/gimpdatafactory.c
@@ -274,39 +274,25 @@ gimp_data_factory_refresh_cache_remove (gpointer key,
static void
gimp_data_factory_data_foreach (GimpDataFactory *factory,
+ gboolean skip_internal,
GimpDataForeachFunc callback,
gpointer user_data)
{
- GimpList *list;
+ GList *list = GIMP_LIST (factory->priv->container)->list;
- if (gimp_container_is_empty (factory->priv->container))
- return;
-
- list = GIMP_LIST (factory->priv->container);
+ if (skip_internal)
+ {
+ while (list && GIMP_DATA (list->data)->internal)
+ list = g_list_next (list);
+ }
- if (list->list)
+ while (list)
{
- if (GIMP_DATA (list->list->data)->internal)
- {
- /* if there are internal objects in the list, skip them */
- GList *glist;
+ GList *next = g_list_next (list);
- for (glist = list->list; glist; glist = g_list_next (glist))
- {
- if (glist->next && ! GIMP_DATA (glist->next->data)->internal)
- {
- while (glist->next)
- callback (factory, glist->next->data, user_data);
+ callback (factory, list->data, user_data);
- break;
- }
- }
- }
- else
- {
- while (list->list)
- callback (factory, list->list->data, user_data);
- }
+ list = next;
}
}
@@ -385,7 +371,7 @@ gimp_data_factory_data_refresh (GimpDataFactory *factory)
cache = g_hash_table_new (g_str_hash, g_str_equal);
- gimp_data_factory_data_foreach (factory,
+ gimp_data_factory_data_foreach (factory, TRUE,
gimp_data_factory_refresh_cache_add, cache);
/* Now the cache contains a filename => list-of-objects mapping of
@@ -478,7 +464,8 @@ gimp_data_factory_data_free (GimpDataFactory *factory)
gimp_container_freeze (factory->priv->container);
- gimp_data_factory_data_foreach (factory, gimp_data_factory_remove_cb, NULL);
+ gimp_data_factory_data_foreach (factory, TRUE,
+ gimp_data_factory_remove_cb, NULL);
gimp_container_thaw (factory->priv->container);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]