[gnumeric] Don't attempt to add a path item when there is no path objecte. [#703052]



commit 1dfa4808f0920e2f6783ac9817e785521df97f6f
Author: Jean Brefort <jean brefort normalesup org>
Date:   Wed Jun 26 09:18:39 2013 +0200

    Don't attempt to add a path item when there is no path objecte. [#703052]

 ChangeLog         |    6 ++++++
 NEWS              |    3 +++
 src/gnm-so-path.c |   29 +++++++++++++++++++++++------
 3 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e1026c1..4f08c58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-06-26  Jean Brefort  <jean brefort normalesup org>
+
+       * src/gnm-so-path.c (gnm_so_path_new_view): return NULL if there is no path.
+       [#703052]
+       (gnm_so_path_copy): fixed copy with multiple paths.
+
 2013-06-25  Morten Welinder <terra gnome org>
 
        * configure.ac: Post-release bump.
diff --git a/NEWS b/NEWS
index d020518..f4945ca 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ Andreas:
        * Improve xlsx export of Gnumeric functions.
        * Fix documentation of r.q*.
 
+Jean:
+       * Don't attempt to add a path item when there is no path objecte. [#703052]
+
 Morten:
        * Improve accuracy for 2-argument ERF.
 
diff --git a/src/gnm-so-path.c b/src/gnm-so-path.c
index de83cd4..5360b70 100644
--- a/src/gnm-so-path.c
+++ b/src/gnm-so-path.c
@@ -241,13 +241,17 @@ static SheetObjectView *
 gnm_so_path_new_view (SheetObject *so, SheetObjectViewContainer *container)
 {
        GnmSOPath *sop = GNM_SO_PATH (so);
-       GnmSOPathView *item = (GnmSOPathView *) goc_item_new (
-           gnm_pane_object_group (GNM_PANE (container)),
-               so_path_goc_view_get_type (),
-               NULL);
+       GnmSOPathView *item;
        /* FIXME: this is unsafe if the paths change after the view is created,
         * but this can't occur for now */
        unsigned i;
+
+       if (sop->path == NULL && sop->paths == NULL)
+               return NULL;
+       item = (GnmSOPathView *) goc_item_new (
+                                   gnm_pane_object_group (GNM_PANE (container)),
+                                   so_path_goc_view_get_type (),
+                                   NULL);
        if (sop->path)
                item->path = goc_item_new (GOC_GROUP (item),
                                           GOC_TYPE_PATH,
@@ -441,9 +445,22 @@ gnm_so_path_copy (SheetObject *dst, SheetObject const *src)
        new_sop->y_offset = sop->y_offset;
        new_sop->width = sop->width;
        new_sop->height = sop->height;
-       if (new_sop->path)
+       if (new_sop->path) {
                go_path_free (new_sop->path);
-       new_sop->path = (sop->path)? go_path_ref (sop->path): NULL;
+               new_sop->path = NULL;
+       } else if (new_sop->paths) {
+               g_ptr_array_unref (new_sop->paths);
+               new_sop->paths = NULL;
+       }
+       if (sop->path)
+               new_sop->path = go_path_ref (sop->path);
+       else {
+               unsigned i;
+               new_sop->paths = g_ptr_array_new_full (sop->paths->len,
+                                                      (GDestroyNotify) go_path_free);
+               for (i = 0; i < sop->paths->len; i++)
+                       g_ptr_array_add (new_sop->paths, go_path_ref (g_ptr_array_index (sop->paths, i)));
+       }
        gnm_so_path_parent_class->copy (dst, src);
 }
 


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