[gnumeric] Really fix the component reference count issue.



commit d9825915e96affd43a250aa04fdc4b59063dab03
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sun Apr 26 12:55:26 2020 +0200

    Really fix the component reference count issue.

 ChangeLog                    | 6 ++++++
 component/gnumeric.c         | 2 +-
 src/sheet-object-component.c | 3 ++-
 src/wbc-gtk-actions.c        | 4 +---
 4 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fc3955e2e..7b616e757 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-04-26  Jean Brefort  <jean brefort normalesup org>
+
+       * src/sheet-object-component.c (sheet_object_component_new): really fix
+       the component reference count issue.
+       * src/wbc-gtk-actions.c: ditto.
+
 2020-04-25  Jean Brefort  <jean brefort normalesup org>
 
        * component/gnumeric.c (go_gnm_component_update_data),
diff --git a/component/gnumeric.c b/component/gnumeric.c
index 2f96dcfd1..782138bb9 100644
--- a/component/gnumeric.c
+++ b/component/gnumeric.c
@@ -191,7 +191,7 @@ cb_gognm_save (G_GNUC_UNUSED GtkAction *a, WBCGtk *wbcg)
                                g_object_unref (gognm->wv);
                                g_object_unref (gognm->wb);
                        }
-            gognm->wv = g_object_ref (wv);
+                       gognm->wv = g_object_ref (wv);
                        gognm->wb = wb_view_get_workbook (wv);
                        gnm_app_workbook_list_remove (gognm->wb); /* no need to have this one in the list */
                }
diff --git a/src/sheet-object-component.c b/src/sheet-object-component.c
index 135698602..dec086972 100644
--- a/src/sheet-object-component.c
+++ b/src/sheet-object-component.c
@@ -457,7 +457,8 @@ sheet_object_component_new (GOComponent *component)
 {
        SheetObjectComponent *soc = g_object_new (GNM_SO_COMPONENT_TYPE, NULL);
        sheet_object_component_set_component (GNM_SO (soc), component);
-       g_object_unref (component);
+       if (component)
+               g_object_unref (component);
        return GNM_SO (soc);
 }
 
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index a574fc419..6bce5090d 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -1403,10 +1403,8 @@ static GNM_ACTION_DEF (cb_launch_go_component_from_file)
                GOComponent *component;
                component = go_component_new_from_uri (uri);
                g_free (uri);
-               if (component) {
+               if (component)
                        wbcg_insert_object (WBC_GTK (wbcg), sheet_object_component_new (component));
-                       g_object_unref (component);
-               }
        }
        gtk_widget_destroy (dlg);
 }


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