[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] [commit] Still More OSCresponder issues



Okay, this one is really bad and has been the source of some quite annoying bugs:

<x-tad-smaller>OSCMultiResponder</x-tad-smaller><x-tad-smaller> : </x-tad-smaller><x-tad-smaller>OSCresponder</x-tad-smaller><x-tad-smaller> {
</x-tad-smaller><x-tad-smaller>var</x-tad-smaller><x-tad-smaller> <>nodes;


value { </x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> time, msg;
nodes.do({ </x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> node; node.action.value(time, node, msg) });
}
isEmpty { ^nodes.size == 0 }


}

</x-tad-smaller>
-value here iterates over a collection which may be altered by its members before iteration is done (i.e. by removing themselves!). Considering how often I harp at my students for this sort of thing I'm embarrassed how long it took me to figure it out. I've changed it to the code below and committed it, as I think even if the system gets replaced, this is a current source of many bugs.

<x-tad-smaller> value { </x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> time, msg;
var iterlist;
iterlist = nodes.copy;
iterlist.do({ </x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> node; node.action.value(time, node, msg) });
}
</x-tad-smaller>

Whew...

S.