From 913ad71e10985561c1a23937fb92033e6a92727b Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Wed, 3 Jan 2018 10:02:59 +0100
Subject: [PATCH] Fix a gop-related update issue (#401).

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

diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index bdf3980be..bef3c426b 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -2813,8 +2813,14 @@ function gui_radio_button_coords(cid, tag, x1, y1, xi, yi, i, s, d, orient) {
 }
 
 function gui_radio_update(cid, tag, fgcolor, prev, next) {
+    // Make sure that we aren't invoked before the patchwin exists.
+    if (!patchwin[cid]) { return; }
     var prev = get_item(cid, tag + "button_" + prev),
         next = get_item(cid, tag + "button_" + next);
+    // There seems to be a race condition here so that in some rare
+    // circumstances related to gop areas prev/next may not be set yet. Bail
+    // out in that case. This resolves issue #401. -ag
+    if (!prev || !next) { return; }
     configure_item(prev, { display: "none" });
     configure_item(next, {
         display: "inline",
-- 
GitLab