[PD] [devel] the joy of global variables, part 1

Krzysztof Czaja czaja at chopin.edu.pl
Sat Sep 22 19:20:34 CEST 2001


the following sequence of events causes creation of a strange
kind of a subcanvas having its own environment, and therefore
detached from its parent.

1. In search for help user invokes a popup menu item by clicking
on an object, whose help file does not exist (like [table]).

2 to n-1. User performs any number of other actions, but no new
canvases are created.

n. User creates a subcanvas object by typing [pd <name>] into an
object box.

After that [pd <name>] box and <name> subcanvas are causing
various troubles and generally misbehave.

The reason: a value of a canvas_newdirectory static variable,
used as a flag indicating if the next created canvas deserves
getting its own environment, sticks around after being set
during unsuccesful execution of binbuf_evalfile(), and not being
cleared after that.

The remedy: this value should be cleared, for example by modifying 
binbuf_evalfile() in m_binbuf.c:

-    if (binbuf_read(b, name->s_name, dir->s_name, 0)) perror(name->s_name);
+    if (binbuf_read(b, name->s_name, dir->s_name, 0)) {
+        perror(name->s_name);
+        glob_setfilename(0, &s_, &s_);
+    }

or in any other way.


More information about the Pd-list mailing list