[gnumeric] Paste: fix undo for cell comments that get overwritten by a paste.



commit 0f5b420906e241dfda322906428c418fa31c99b9
Author: Morten Welinder <terra gnome org>
Date:   Thu May 3 13:52:00 2018 -0400

    Paste: fix undo for cell comments that get overwritten by a paste.

 NEWS           |    1 +
 src/commands.c |   30 +++++++++++++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index df72203..6b6e8d2 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ Gnumeric 1.12.41
 
 Morten:
        * Fix problem with object pasting.
+       * Fix undo problem for cell comments.  [#732653]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.40
diff --git a/src/commands.c b/src/commands.c
index aceebbd..cef0e4c 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -3024,15 +3024,27 @@ cmd_paste_copy_impl (GnmCommand *cmd, WorkbookControl *wbc,
                                NULL, NULL);
        }
 
-       /*
-        * We cannot use the random set of objects at the target location.
-        * See http://bugzilla.gnome.org/show_bug.cgi?id=308300
-        */
-       g_slist_free_full (contents->objects, (GDestroyNotify)g_object_unref);
-       contents->objects = is_undo
-               ? go_slist_map (me->orig_contents_objects,
-                               (GOMapFunc)sheet_object_dup)
-               : NULL;
+       if (is_undo) {
+               // We cannot use the random set of objects at the target
+               // location.  http://bugzilla.gnome.org/show_bug.cgi?id=308300
+               g_slist_free_full (contents->objects, g_object_unref);
+               contents->objects = go_slist_map (me->orig_contents_objects,
+                                                 (GOMapFunc)sheet_object_dup);
+       } else {
+               GSList *l;
+               for (l = contents->objects; l; l = l->next) {
+                       SheetObject *so = l->data;
+                       if (sheet_object_get_sheet (so)) {
+                               g_object_unref (so);
+                               l->data = NULL;
+                       } else {
+                               // Object got deleted by paste, so keep it for
+                               // undo.  See bugzilla 732653
+                       }
+               }
+               contents->objects =
+                       g_slist_remove_all (contents->objects, NULL);
+       }
 
        cellregion_unref (me->contents);
        me->contents = contents;


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