From 0f5b420906e241dfda322906428c418fa31c99b9 Mon Sep 17 00:00:00 2001 From: Morten Welinder Date: Thu, 3 May 2018 13:52:00 -0400 Subject: [PATCH] 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 df7220311..6b6e8d231 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 aceebbdba..cef0e4cc7 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; -- 2.11.4.GIT