[gnumeric] recalc: improve recalc cache clearing setup.



commit 2daaf09d1d1d328bd9e546eeb48289b0a2985169
Author: Morten Welinder <terra gnome org>
Date:   Tue May 18 13:42:53 2010 -0400

    recalc: improve recalc cache clearing setup.

 ChangeLog                     |    7 +++++++
 plugins/fn-lookup/functions.c |    3 ++-
 src/application.c             |   19 ++++++++++++++++++-
 src/application.h             |    1 +
 src/collect.c                 |    2 +-
 src/func-builtin.c            |   14 +++-----------
 6 files changed, 32 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4cb66f5..ed44b2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-18  Morten Welinder  <terra gnome org>
+
+	* src/collect.c (create_caches): Hook recalc-clear-caches.
+
+	* src/application.c (gnm_app_recalc_clear_caches): New function.
+	(gnm_app_recalc_finish): Call gnm_app_recalc_clear_caches too.
+
 2010-05-17  Morten Welinder  <terra gnome org>
 
 	* src/func-builtin.c (gnumeric_table): Fix interaction with
diff --git a/plugins/fn-lookup/functions.c b/plugins/fn-lookup/functions.c
index 1d07629..5a553a2 100644
--- a/plugins/fn-lookup/functions.c
+++ b/plugins/fn-lookup/functions.c
@@ -1765,13 +1765,14 @@ GnmFuncDescriptor const lookup_functions[] = {
 G_MODULE_EXPORT void
 go_plugin_init (GOPlugin *plugin, GOCmdContext *cc)
 {
-	g_signal_connect (gnm_app_get_app (), "recalc-finished",
+	g_signal_connect (gnm_app_get_app (), "recalc-clear-caches",
 			  G_CALLBACK (clear_caches), NULL);
 }
 
 G_MODULE_EXPORT void
 go_plugin_shutdown (GOPlugin *plugin, GOCmdContext *cc)
 {
+	clear_caches ();
 	g_signal_handlers_disconnect_by_func (gnm_app_get_app (),
 					      G_CALLBACK (clear_caches), NULL);
 }
diff --git a/src/application.c b/src/application.c
index fac9e33..e3ae88b 100644
--- a/src/application.c
+++ b/src/application.c
@@ -50,6 +50,7 @@ enum {
 	CUSTOM_UI_REMOVED,
 	CLIPBOARD_MODIFIED,
 	RECALC_FINISHED,
+	RECALC_CLEAR_CACHES,
 	LAST_SIGNAL
 };
 
@@ -82,6 +83,7 @@ typedef struct {
 	void (*custom_ui_removed)   (GnmApp *gnm_app, GnmAppExtraUI *ui);
 	void (*clipboard_modified)  (GnmApp *gnm_app);
 	void (*recalc_finished)     (GnmApp *gnm_app);
+	void (*recalc_clear_caches) (GnmApp *gnm_app);
 } GnmAppClass;
 
 static GObjectClass *parent_klass;
@@ -733,6 +735,13 @@ gnm_app_class_init (GObjectClass *gobject_klass)
 		NULL, NULL,
 		g_cclosure_marshal_VOID__VOID,
 		G_TYPE_NONE, 0);
+	signals [RECALC_FINISHED] = g_signal_new ("recalc_clear_caches",
+		GNM_APP_TYPE,
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (GnmAppClass, recalc_clear_caches),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__VOID,
+		G_TYPE_NONE, 0);
 }
 
 static void
@@ -856,6 +865,14 @@ gnm_app_recalc_finish (void)
 {
 	g_return_if_fail (app->recalc_count > 0);
 	app->recalc_count--;
-	if (app->recalc_count == 0)
+	if (app->recalc_count == 0) {
+		gnm_app_recalc_clear_caches ();
 		g_signal_emit_by_name (gnm_app_get_app (), "recalc-finished");
+	}
+}
+
+void
+gnm_app_recalc_clear_caches (void)
+{
+	g_signal_emit_by_name (gnm_app_get_app (), "recalc-clear-caches");
 }
diff --git a/src/application.h b/src/application.h
index b16aff9..be30951 100644
--- a/src/application.h
+++ b/src/application.h
@@ -29,6 +29,7 @@ void	     gnm_app_history_add	   (char const *filename, const char *mimetype);
 
 void         gnm_app_recalc_start          (void);
 void         gnm_app_recalc_finish         (void);
+void         gnm_app_recalc_clear_caches   (void);
 
 /* GtkFileFilter */
 void        *gnm_app_create_opener_filter (void);
diff --git a/src/collect.c b/src/collect.c
index 415d470..4e4606a 100644
--- a/src/collect.c
+++ b/src/collect.c
@@ -87,7 +87,7 @@ create_caches (void)
 		return;
 
 	cache_handler =
-		g_signal_connect (gnm_app_get_app (), "recalc-finished",
+		g_signal_connect (gnm_app_get_app (), "recalc-clear-caches",
 				  G_CALLBACK (clear_caches), NULL);
 
 	single_floats_cache = g_hash_table_new_full
diff --git a/src/func-builtin.c b/src/func-builtin.c
index 5d5e517..b9356e2 100644
--- a/src/func-builtin.c
+++ b/src/func-builtin.c
@@ -144,14 +144,6 @@ gnumeric_table_link (GnmFuncEvalInfo *ei)
 	return DEPENDENT_IGNORE_ARGS;
 }
 
-static void
-void_calculation_caches (void)
-{
-	/* A CRUDE, CRUDE way of killing collect.c's caches.  */
-	g_signal_emit_by_name (gnm_app_get_app (), "recalc-finished");
-}
-
-
 static GnmValue *
 gnumeric_table (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
 {
@@ -209,7 +201,7 @@ gnumeric_table (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
 			gnm_cell_eval (x_iter);
 			in[0]->value = value_dup (x_iter->value);
 			dependent_queue_recalc (&in[0]->base);
-			void_calculation_caches ();
+			gnm_app_recalc_clear_caches ();
 		} else
 			val[0] = value_dup (x_iter->value);
 
@@ -224,7 +216,7 @@ gnumeric_table (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
 				/* not a leak, val[] holds the original */
 				in[1]->value = value_dup (y_iter->value);
 				dependent_queue_recalc (&in[1]->base);
-				void_calculation_caches ();
+				gnm_app_recalc_clear_caches ();
 				if (NULL != in[0]) {
 					gnm_cell_eval (in[2]);
 					value_array_set (res, x, y, value_dup (in[2]->value));
@@ -260,7 +252,7 @@ gnumeric_table (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
 				sheet_cell_remove (ei->pos->sheet, in[x], FALSE, FALSE);
 				in[x] = NULL;
 			}
-			void_calculation_caches ();
+			gnm_app_recalc_clear_caches ();
 		}
 	for (x = 0 ; x < 3 ; x++)
 		if (in[x])



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