From f47f938500edbdda179d7efed01db0b72eb3d936 Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@monsoon-hp.(none)>
Date: Sat, 11 Feb 2012 10:13:59 -0500
Subject: [PATCH] fixed three regressions that crept in due to implementation
 of moving gop objects by tag. one of them manifested itself when an object
 was altered as gop and a sub-patch pops up asking to discard changes made to
 it. upon returning on the main window with the said gop, due to redraw
 objects were not reselected so dragging the object would not redraw properly
 even though it could be displaced, resulting in a seemingly stale gop object
 (in actuality it was simply displaced by being dragged while its visual
 content did not displace). Also, excessive stdout errors regarding redrawing
 gop resize handles and possible menu edit update has been dealt with.

---
 src/g_editor.c | 11 ++++++-----
 src/g_graph.c  |  7 ++++++-
 src/pd.tk      | 13 +++++++------
 3 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/g_editor.c b/src/g_editor.c
index bf45c6825..30f4f55f6 100644
--- a/src/g_editor.c
+++ b/src/g_editor.c
@@ -4474,20 +4474,21 @@ void canvas_editmode(t_canvas *x, t_floatarg fyesplease)
             	magicGlass_unbind(x->gl_magic_glass);
             	magicGlass_hide(x->gl_magic_glass);
 			}
-            // end jsarlo
+		        // end jsarlo
+			//dpsaha@vt.edu called to delete the GOP_blob
+			if (x->gl_goprect)		canvas_draw_gop_resize_hooks(x);
         }
 		canvas_setcursor(x, CURSOR_RUNMODE_NOTHING);
     }
-    sys_vgui("pdtk_canvas_editval .x%lx %d\n",
-        glist_getcanvas(x), x->gl_edit);
+    if (glist_isvisible(x))
+		sys_vgui("pdtk_canvas_editval .x%lx %d\n",
+        	glist_getcanvas(x), x->gl_edit);
 	/*if (!x->gl_edit) {
 		sys_vgui(".x%lx.m.edit entryconfigure \"Cord Inspector\" -indicatoron false -state disabled\n", glist_getcanvas(x));
 	}
 	else {
 		sys_vgui(".x%lx.m.edit entryconfigure \"Cord Inspector\" -indicatoron false -state normal\n", glist_getcanvas(x));
 	}*/
-	//dpsaha@vt.edu called to delete the GOP_blob
-	if (x->gl_goprect)		canvas_draw_gop_resize_hooks(x);
 }
 
 // jsarlo
diff --git a/src/g_graph.c b/src/g_graph.c
index 529ad5e78..ce33148c1 100644
--- a/src/g_graph.c
+++ b/src/g_graph.c
@@ -917,6 +917,9 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
         for (g = x->gl_list; g; g = g->g_next) {
             gobj_vis(g, x, 1);
 		}
+		/* reselect it upon redrawing if it was selected before */
+		if (glist_isselected(parent_glist, gr))
+			gobj_select(gr, parent_glist, 1);
     }
     else
     {
@@ -1050,6 +1053,7 @@ static void graph_getrect(t_gobj *z, t_glist *glist,
 
 static void graph_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy)
 {
+	//fprintf(stderr,"graph_displace_withtag %d %d\n", dx, dy);
     t_glist *x = (t_glist *)z;
     if (!x->gl_isgraph)
         text_widgetbehavior.w_displacefnwtag(z, glist, dx, dy);
@@ -1063,6 +1067,7 @@ static void graph_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy)
 
 static void graph_displace(t_gobj *z, t_glist *glist, int dx, int dy)
 {
+	//fprintf(stderr,"graph_displace %d %d\n", dx, dy);
     t_glist *x = (t_glist *)z;
     if (!x->gl_isgraph)
         text_widgetbehavior.w_displacefn(z, glist, dx, dy);
@@ -1084,7 +1089,7 @@ static void graph_displace(t_gobj *z, t_glist *glist, int dx, int dy)
 
 static void graph_select(t_gobj *z, t_glist *glist, int state)
 {
-	//fprintf(stderr,"graph_select .x%lx...\n", (t_int)z);
+	//fprintf(stderr,"graph_select .x%lx %d...\n", (t_int)z, state);
     t_glist *x = (t_glist *)z;
     if (!x->gl_isgraph)
         text_widgetbehavior.w_selectfn(z, glist, state);
diff --git a/src/pd.tk b/src/pd.tk
index cf9cb19dd..60b430826 100644
--- a/src/pd.tk
+++ b/src/pd.tk
@@ -5091,12 +5091,13 @@ proc pdtk_data_dialog {name stuff} {
 #####################iemlib#######################
 proc pdtk_canvas_editval {name value} {
 	#global colors
-
-    if { $value } {
-        $name.m.edit entryconfigure "Edit mode" -indicatoron false -background "#7dd37d"
-    } else {                          
-        $name.m.edit entryconfigure "Edit mode" -indicatoron false -background {}
-    }                                                 
+	#if {[winfo exists $name]} {
+		if { $value } {
+		    $name.m.edit entryconfigure "Edit mode" -indicatoron false -background "#7dd37d"
+		} else {                          
+		    $name.m.edit entryconfigure "Edit mode" -indicatoron false -background {}
+		}
+	#}                                             
 }
 #####################iemlib#######################
 
-- 
GitLab