[goffice] Plugins: fix deactivation.



commit 1a95528283e2fc33344cc84d5f9c7300abe23460
Author: Morten Welinder <terra gnome org>
Date:   Sun Mar 30 17:04:27 2014 -0400

    Plugins: fix deactivation.

 ChangeLog               |    6 +++++
 NEWS                    |    1 +
 goffice/app/go-plugin.c |   48 ++++++++++++++++++++++++++++++++--------------
 3 files changed, 40 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3f8f8df..72b62a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-30  Morten Welinder  <terra gnome org>
+
+       * goffice/app/go-plugin.c (go_plugin_db_deactivate_plugin_list):
+       Retry failed deactivations as long as we make progress.  (Some
+       plugins depend on others.)
+
 2014-03-28  Morten Welinder  <terra gnome org>
 
        * goffice/utils/go-format.c (go_format_parse_color): Implement
diff --git a/NEWS b/NEWS
index dc07b5e..c1d200c 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Andreas:
 Morten:
        * Work on conditional formats for ODF.
        * Implement numbered colours in number formats.
+       * Fix plugin deactivation.
 
 --------------------------------------------------------------------------
 goffice 0.10.13:
diff --git a/goffice/app/go-plugin.c b/goffice/app/go-plugin.c
index 0e29149..6301c81 100644
--- a/goffice/app/go-plugin.c
+++ b/goffice/app/go-plugin.c
@@ -1516,26 +1516,43 @@ go_plugin_db_activate_plugin_list (GSList *plugins, GOErrorInfo **ret_error)
 void
 go_plugin_db_deactivate_plugin_list (GSList *plugins, GOErrorInfo **ret_error)
 {
-       GSList *error_list = NULL;
+       GSList *plugins_copy = g_slist_copy (plugins);
 
        GO_INIT_RET_ERROR_INFO (ret_error);
-       GO_SLIST_FOREACH (plugins, GOPlugin, plugin,
-               GOErrorInfo *error;
 
-               go_plugin_deactivate (plugin, &error);
-               if (error != NULL) {
-                       GOErrorInfo *new_error;
+       while (plugins_copy) {
+               gboolean progress = FALSE;
+               GSList *bad = NULL;
+               GSList *error_list = NULL;
 
-                       new_error = go_error_info_new_printf (
-                                   _("Couldn't deactivate plugin \"%s\" (ID: %s)."),
-                                   plugin->name, plugin->id);
-                       go_error_info_add_details (new_error, error);
-                       GO_SLIST_PREPEND (error_list, new_error);
+               while (plugins_copy) {
+                       GOPlugin *plugin = plugins_copy->data;
+                       GOErrorInfo *error;
+
+                       go_plugin_deactivate (plugin, &error);
+
+                       if (error) {
+                               GOErrorInfo *new_error =
+                                       go_error_info_new_printf (
+                                               _("Couldn't deactivate plugin \"%s\" (ID: %s)."),
+                                               plugin->name, plugin->id);
+                               go_error_info_add_details (new_error, error);
+                               GO_SLIST_PREPEND (error_list, new_error);
+                               bad = g_slist_prepend (bad, plugin);
+                       } else
+                               progress = TRUE;
+
+                       plugins_copy = g_slist_delete_link (plugins_copy, plugins_copy);
+               }
+
+               if (progress) {
+                       g_slist_free_full (error_list, (GDestroyNotify)go_error_info_free);
+                       plugins_copy = bad;
+               } else {
+                       GO_SLIST_REVERSE (error_list);
+                       *ret_error = go_error_info_new_from_error_list (error_list);
+                       break;
                }
-       );
-       if (error_list != NULL) {
-               GO_SLIST_REVERSE (error_list);
-               *ret_error = go_error_info_new_from_error_list (error_list);
        }
 }
 
@@ -1890,6 +1907,7 @@ go_plugins_shutdown (void)
 
        if (plugins_marked_for_deactivation_hash != NULL) {
                g_hash_table_destroy (plugins_marked_for_deactivation_hash);
+               plugins_marked_for_deactivation_hash = NULL;
        }
 
        /* deactivate all plugins */


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