From 2fb4908c409cb7bb8569a72bf3fccaccffa2d746 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Fri, 4 Nov 2005 20:00:38 +0000 Subject: [PATCH] applied a patch by Gerald Friedland that changes the code to clear the 2005-11-04 Sven Neumann * app/base/siox.c: applied a patch by Gerald Friedland that changes the code to clear the cache selectively instead of dumping it completely if the foreground or background area is changed. --- ChangeLog | 6 ++++++ app/base/siox.c | 25 +++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53367b03f4..0407721308 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-11-04 Sven Neumann + + * app/base/siox.c: applied a patch by Gerald Friedland that + changes the code to clear the cache selectively instead of dumping + it completely if the foreground or background area is changed. + 2005-11-04 Sven Neumann * app/core/gimpenvirontable.c (gimp_environ_table_load_env_file): diff --git a/app/base/siox.c b/app/base/siox.c index a228e7f73d..25031d411f 100644 --- a/app/base/siox.c +++ b/app/base/siox.c @@ -698,15 +698,26 @@ siox_progress_update (SioxProgressFunc progress_callback, progress_callback (progress_data, value); } -/* Needed for clearing hashtable as defined by glib*/ +/* Clear hashtable entries that get invalid due to refinement */ static gboolean -dummy_remove_hash (gpointer key, - gpointer value, - gpointer user_data) +siox_cache_remove_fg (gpointer key, + gpointer value, + gpointer user_data) { - return TRUE; + classresult *cr = value; + + return (cr->bgdist < cr->fgdist); } +static gboolean +siox_cache_remove_bg (gpointer key, + gpointer value, + gpointer user_data) +{ + classresult *cr = value; + + return (cr->fgdist < cr->bgdist); +} /** * siox_init: @@ -845,7 +856,9 @@ siox_foreground_extract (SioxState *state, SIOX_REFINEMENT_ADD_BACKGROUND)) { g_hash_table_foreach_remove (state->cache, - (GHRFunc) dummy_remove_hash, NULL); + refinement & SIOX_REFINEMENT_ADD_FOREGROUND ? + siox_cache_remove_fg : siox_cache_remove_bg, + NULL); /* count given foreground and background pixels */ pixel_region_init (&mapPR, mask, x, y, width, height, FALSE);