From b35b55f6887706cad0c6287a03ad812346682e21 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Sun, 17 Jan 2016 18:11:25 -0500
Subject: [PATCH] add workaround for out-of-order request from Pd that tries to
 destory a border on a scalar it already told us to erase

---
 pd/nw/pdgui.js | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index d88c0d58b..96f3db450 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -2515,13 +2515,18 @@ function gui_scalar_draw_select_rect(cid, tag, state, x1, y1, x2, y2, basex, bas
     // for selected borders because somehow calling properties on a graph
     // triggers this function.  I have no idea why it does that.
     var g = get_gobj(cid, tag),
+        b;
+    // somehow the scalar can unvis before calling this, so we check for
+    // its existence here...
+    if (g) {
         b = g.querySelector(".border");
-    configure_item(b, {
-        x: (x1 - basex) + 0.5,
-        y: (y1 - basey) + 0.5,
-        width: x2 - x1,
-        height: y2 - y1,
-    });
+        configure_item(b, {
+            x: (x1 - basex) + 0.5,
+            y: (y1 - basey) + 0.5,
+            width: x2 - x1,
+            height: y2 - y1
+        });
+    }
 }
 
 function gui_create_scalar_group(cid, tag, parent_tag, attr_array) {
-- 
GitLab