[goffice] Plugins: plug leaks.



commit 76ca392a942a6f989c1b4a7fb0c56cc760c664cb
Author: Morten Welinder <terra gnome org>
Date:   Sun Mar 30 17:17:33 2014 -0400

    Plugins: plug leaks.

 ChangeLog                       |    4 ++++
 NEWS                            |    1 +
 goffice/graph/gog-plot-engine.c |   29 +++++++++++++++++++----------
 3 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 72b62a6..f3b8dc1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2014-03-30  Morten Welinder  <terra gnome org>
 
+       * goffice/graph/gog-plot-engine.c
+       (gog_trend_line_service_deactivate): Plug leak.
+       (gog_plot_type_service_deactivate): Ditto.
+
        * 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.)
diff --git a/NEWS b/NEWS
index c1d200c..417b573 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Morten:
        * Work on conditional formats for ODF.
        * Implement numbered colours in number formats.
        * Fix plugin deactivation.
+       * Plug leaks.
 
 --------------------------------------------------------------------------
 goffice 0.10.13:
diff --git a/goffice/graph/gog-plot-engine.c b/goffice/graph/gog-plot-engine.c
index 10b5529..1221acf 100644
--- a/goffice/graph/gog-plot-engine.c
+++ b/goffice/graph/gog-plot-engine.c
@@ -315,11 +315,16 @@ gog_plot_type_service_deactivate (GOPluginService *service, GOErrorInfo **ret_er
        plot_service->types = NULL;
 
        if (pending_plot_type_files) {
-               l = plot_service->paths;
-               while (l) {
-                   g_hash_table_remove (pending_plot_type_files, l->data);
-                   l = l->next;
-           }
+               GSList *l;
+               for (l = plot_service->paths; l; l = l->next) {
+                       const char *path = l->data;
+                       g_hash_table_remove (pending_plot_type_files, path);
+               }
+
+               if (g_hash_table_size (pending_plot_type_files) == 0) {
+                       g_hash_table_destroy (pending_plot_type_files);
+                       pending_plot_type_files = NULL;
+               }
        }
        service->is_active = FALSE;
 }
@@ -593,11 +598,15 @@ gog_trend_line_service_deactivate (GOPluginService *service, GOErrorInfo **ret_e
        line_service->types = NULL;
 
        if (pending_trend_line_type_files) {
-               l = line_service->paths;
-               while (l) {
-                   g_hash_table_remove (pending_trend_line_type_files, l->data);
-                   l = l->next;
-           }
+               GSList *l;
+               for (l = line_service->paths; l; l = l->next) {
+                       const char *path = l->data;
+                       g_hash_table_remove (pending_trend_line_type_files, path);
+               }
+               if (g_hash_table_size (pending_trend_line_type_files) == 0) {
+                       g_hash_table_destroy (pending_trend_line_type_files);
+                       pending_trend_line_type_files = NULL;
+               }
        }
        service->is_active = FALSE;
 }


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