Bug 1260042 - fix edge case with when auto-prettifying fails in debugger r=me
authorJames Long <longster@gmail.com>
Mon, 28 Mar 2016 13:18:09 -0400
changeset 290713 6735565943d34747d8219d3b3b7b30003e7cb265
parent 290712 3f54e19a24326db7c75d49ee000d53db6b628c83
child 290714 a66e1fb0320678f5d2acb2b8712a4133104d4b45
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1260042
milestone48.0a1
Bug 1260042 - fix edge case with when auto-prettifying fails in debugger r=me
devtools/client/debugger/content/reducers/sources.js
devtools/client/shared/redux/non-react-subscriber.js
--- a/devtools/client/debugger/content/reducers/sources.js
+++ b/devtools/client/debugger/content/reducers/sources.js
@@ -62,18 +62,25 @@ function update(state = initialState, ac
 
   case constants.TOGGLE_PRETTY_PRINT:
     let s = state;
     if (action.status === "error") {
       s = mergeIn(state, ['sourcesText', action.source.actor], {
         loading: false
       });
 
-      // If it errored, just display the source as it way before.
-      emitChange('prettyprinted', s.sources[action.source.actor]);
+      // If it errored, just display the source as it was before, but
+      // only if there is existing text already. If auto-prettifying
+      // is on, the original text may still be coming in and we don't
+      // have it yet. If we try to set empty text we confuse the
+      // editor because it thinks it's already displaying the source's
+      // text and won't load the text when it actually comes in.
+      if(s.sourcesText[action.source.actor].text != null) {
+        emitChange('prettyprinted', s.sources[action.source.actor]);
+      }
     }
     else {
       s = _updateText(state, action);
       // Don't do this yet, the progress bar is still imperatively shown
       // from the source view. We will fix in the next iteration.
       // emitChange('source-text-loaded', s.sources[action.source.actor]);
 
       if (action.status === 'done') {
--- a/devtools/client/shared/redux/non-react-subscriber.js
+++ b/devtools/client/shared/redux/non-react-subscriber.js
@@ -84,21 +84,16 @@ function makeStateBroadcaster(stillAlive
       enqueuedChanges.push([name, payload]);
     },
 
     subscribeToStore: store => {
       store.subscribe(() => {
         if (stillAliveFunc()) {
           enqueuedChanges.forEach(([name, payload]) => {
             if (listeners[name]) {
-              let payloadStr = payload;
-              try {
-                payloadStr = JSON.stringify(payload);
-              }
-              catch(e) {}
               listeners[name].forEach(listener => {
                 listener(payload)
               });
             }
           });
           enqueuedChanges = [];
         }
       });