From e0a0914b1b2c3330d810236715899d0a330a732d Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Wed, 5 Nov 2014 14:37:49 -0500
Subject: [PATCH] *fixed bug when applying properties to an iemgui object using
 handles (e.g. moving label or resizing an object), upon undoing all other
 objects that may have been selected at the time a handle was edited would be
 erroneously recreated.

---
 pd/src/g_editor.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index c20fee498..7862a94c5 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -1425,6 +1425,7 @@ typedef struct _undo_apply
 
 void *canvas_undo_set_apply(t_canvas *x, int n)
 {
+    //fprintf(stderr,"canvas_undo_set_apply\n");
     t_undo_apply *buf;
     t_gobj *obj;
     t_linetraverser t;
@@ -1433,6 +1434,13 @@ void *canvas_undo_set_apply(t_canvas *x, int n)
        we are working on */
     if (!x->gl_edit)
         canvas_editmode(x, 1);
+
+    // deselect all objects (if we are editing one while multiple are
+    // selected, upon undoing this will recreate other selected objects,
+    // effectively resulting in unwanted duplicates)
+    // LATER: consider allowing concurrent editing of multiple objects
+    glist_noselect(x);
+
     obj = glist_nth(x, n);
     if (obj && !glist_isselected(x, obj))
         glist_select(x, obj);
@@ -1470,6 +1478,7 @@ void *canvas_undo_set_apply(t_canvas *x, int n)
 
 void canvas_undo_apply(t_canvas *x, void *z, int action)
 {
+    //fprintf(stderr,"canvas_undo_apply\n");
     t_undo_apply *buf = z;
     if (action == UNDO_UNDO || action == UNDO_REDO)
     {
-- 
GitLab