{"action":"created","issue":{"url":"https://api.github.com/repos/LLK/scratch-flash/issues/913","labels_url":"https://api.github.com/repos/LLK/scratch-flash/issues/913/labels{/name}","comments_url":"https://api.github.com/repos/LLK/scratch-flash/issues/913/comments","events_url":"https://api.github.com/repos/LLK/scratch-flash/issues/913/events","html_url":"https://github.com/LLK/scratch-flash/pull/913","id":105098250,"number":913,"title":"Fixes #912 and #468, and is a suggestion for an improvement to PR #901.","user":{"login":"TheLogFather","id":7702458,"avatar_url":"https://avatars.githubusercontent.com/u/7702458?v=3","gravatar_id":"","url":"https://api.github.com/users/TheLogFather","html_url":"https://github.com/TheLogFather","followers_url":"https://api.github.com/users/TheLogFather/followers","following_url":"https://api.github.com/users/TheLogFather/following{/other_user}","gists_url":"https://api.github.com/users/TheLogFather/gists{/gist_id}","starred_url":"https://api.github.com/users/TheLogFather/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheLogFather/subscriptions","organizations_url":"https://api.github.com/users/TheLogFather/orgs","repos_url":"https://api.github.com/users/TheLogFather/repos","events_url":"https://api.github.com/users/TheLogFather/events{/privacy}","received_events_url":"https://api.github.com/users/TheLogFather/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-06T14:45:47Z","updated_at":"2015-12-09T19:19:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/LLK/scratch-flash/pulls/913","html_url":"https://github.com/LLK/scratch-flash/pull/913","diff_url":"https://github.com/LLK/scratch-flash/pull/913.diff","patch_url":"https://github.com/LLK/scratch-flash/pull/913.patch"},"body":"It adds a new public var in ScratchRuntime.as, currentDoObj, which can be set during allStacksAndOwnersDo. Only processEdgeTriggeredHats uses it here (since that's causing #901 and #468, referencing a stack which is not the currentThread), but it can potentially be used if there are other such cases (for example, a hacked \"when I receive\" hat block will likely also run into the same bug).\r\n\r\nIt's probably not the most elegant thing, but it's straightforward, and it works.\r\nMaybe someone has a better idea...?\r\n"},"comment":{"url":"https://api.github.com/repos/LLK/scratch-flash/issues/comments/163362623","html_url":"https://github.com/LLK/scratch-flash/pull/913#issuecomment-163362623","issue_url":"https://api.github.com/repos/LLK/scratch-flash/issues/913","id":163362623,"user":{"login":"TheLogFather","id":7702458,"avatar_url":"https://avatars.githubusercontent.com/u/7702458?v=3","gravatar_id":"","url":"https://api.github.com/users/TheLogFather","html_url":"https://github.com/TheLogFather","followers_url":"https://api.github.com/users/TheLogFather/followers","following_url":"https://api.github.com/users/TheLogFather/following{/other_user}","gists_url":"https://api.github.com/users/TheLogFather/gists{/gist_id}","starred_url":"https://api.github.com/users/TheLogFather/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheLogFather/subscriptions","organizations_url":"https://api.github.com/users/TheLogFather/orgs","repos_url":"https://api.github.com/users/TheLogFather/repos","events_url":"https://api.github.com/users/TheLogFather/events{/privacy}","received_events_url":"https://api.github.com/users/TheLogFather/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T19:19:05Z","updated_at":"2015-12-09T19:19:05Z","body":"I'm not totally clear why activeThread can manage to be non-null even when there are no scripts running - I haven't looked into that one.\r\n\r\nIt does slightly concern me that it's like that because it's not getting cleared when all scripts have finished running. It means it could actually be using an invalid value for activeThread in here. (Though I don't think that can happen with this fix, because of below...)\r\n\r\nThe key question is to ask what are the possible ways it can get into primVarGet?\r\n\r\nThere are two I can think of - when it's in the middle of running a script (in which case activeThread will be set), and when it's checking an expression in a hat block (in which case it should have gone through the allStacksAndOwnersDo to find it - at least that's how it finds them at the moment).\r\n\r\nThe above two cases are covered with this fix (at least for the edge-triggered hats - hacked \"when I receive\" is not, though it could easily be). But if you do come up with another way, then certainly it will have to be dealt with!"}}