deep copy atomic lists sent from one scene to another

snap7
jmoenig 2021-10-22 15:48:24 +02:00
rodzic f1a5031b7b
commit f926c8f5a3
2 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -49,6 +49,7 @@
* blocks: only show "key" upvar in the "When ... is pressed" hat if "any key" is selected
* blocks: tweaked blocks layout for hidden expansion slots
* blocks, objects, store, threads: made SEND blocks expandable for receivers and renamed them back to BROADCAST
* threads: deep copy atomic lists sent from one scene to another
### 2021-10-21
* threads, objects: make "when I receive 'any message'" hat scripts threadsafe (uninterruptable by other messages)

Wyświetl plik

@ -4683,12 +4683,16 @@ Process.prototype.doSwitchToScene = function (id, transmission) {
ide, scenes, num, scene;
this.assertAlive(rcvr);
this.assertType(message, ['text', 'number', 'Boolean', 'list']);
if (message instanceof List && !message.canBeJSON()) {
if (message instanceof List) {
// make sure only atomic leafs are inside the list
// don't actually encode the list as json, though
throw new Error(localize(
'cannot send media,\nsprites or procedures\nto another scene'
));
if (message.canBeJSON()) {
message = message.deepMap(leaf => leaf); // deep copy the list
} else {
throw new Error(localize(
'cannot send media,\nsprites or procedures\nto another scene'
));
}
}
if (this.readyToTerminate) {
// let the user press "stop" or "esc",