1 Reply Latest reply on Aug 25, 2014 1:12 AM by DBarranca

    suspendHistory breaks activeHistoryState

    DBarranca Level 4

      Hi,

      I've found that when you try to get the activeHistoryState after a suspendHistory call, you get the wrong one, namely the previous - e.g.

       

      var doc = app.activeDocument;
      $.writeln(doc.activeHistoryState); // [HistoryState DemoFile.jpg]
      doc.suspendHistory ("TEST", "doc.activeLayer.name = 'Something'; doc.activeLayer.name = 'SomethingElse';");
      $.writeln(doc.activeHistoryState); // [HistoryState DemoFile.jpg]
      // shouldn't be [HistoryState TEST] ?
      

       

      Why is it this way? Any workaround?

      I've also tried using doc.historyStates.getByName('TEST'); but fires an error - it seems like the state hasn't been created.

      Any help is really appreciated, thank you!

       

      Davide Barranca

      ---

      www.davidebarranca.com

      www.cs-extensions.com

        • 1. Re: suspendHistory breaks activeHistoryState
          DBarranca Level 4

          FYI,

          Michel Mariani suggested this workaround:

           

          var doc = app.activeDocument;  
          $.writeln(doc.activeHistoryState); // [HistoryState DemoFile.jpg] 
          doc.suspendHistory ("TEST", "doc.activeLayer.name = 'Something'; doc.activeLayer.name = 'SomethingElse';"); 
          app.refresh();
          $.writeln(doc.activeHistoryState); // [HistoryState TEST]  
          

           

          It adds the usual, unwanted delay app.refresh adds, but at least the history state is the right one. Thanks Michel!

           

          Davide Barranca

          ---

          www.davidebarranca.com

          www.cs-extensions.com