From 808740f0fc73a4c82e7f556a59b11e1d475e0590 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Fri, 30 Dec 2016 18:01:23 -0500
Subject: [PATCH] fix #214: Cannot read property 'setAttributeNS' of null

---
 pd/nw/pdgui.js | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 83c90fcc9..4590cb477 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -2293,8 +2293,11 @@ function gui_bng_new(cid, tag, cx, cy, radius) {
 }
 
 function gui_bng_button_color(cid, tag, color) {
-    var button = get_item(cid, tag + "button");
-    configure_item(button, { fill: color });
+    var button;
+    if (patchwin[cid]) {
+        button = get_item(cid, tag + "button");
+        configure_item(button, { fill: color });
+    }
 }
 
 function gui_bng_configure(cid, tag, color, cx, cy, r) {
-- 
GitLab