maqetta/maqetta — Issue #1349: state change publish should pass editor object, subscribe should check
Author: JonFerraiolo
Created: 2011-12-13 01:37:07+00:00
State: open
Labels: Bug, Priority Med

@billreed63

I think this is the cause of various intermittent bugs, which is why I assigned it to Priority-Med

Various parts of the code publish ```*/state/changed``` and various other parts of the code subscribe to this event. The problem is the event doesn't pass any information about which editor window the state change applies to. As a result, in some cases, state change events published in editor A are received by editor B. I think the safest and most reliable fix is to always pass an editor pointer on the event object with each publish and then check that pointer with each subscribe.

Note that I checked in a bandaid fix for one particular problem in this area: where the theme editor publishes ```*/state/changed``` with '$all' as the widget (i.e., a string instead of a widget object) but one of the open page editor has subscribed to this event and was trying to call ```getParent``` on '$all'. My bandaid was making sure that "widget" is an object (and not a string): 0b90104b3f

It might be that there is existing logic that (mostly) prevents such a scenario from happening, but I've been able to trigger such a scenario by having four editors open at once: mobile html page editor, mobile theme editor, mobile theme editor and mobile html page editor (in that order) and then try various combinations of switching editors and refreshing the Maqetta browser window.