11 Replies Latest reply on Nov 29, 2011 3:43 AM by TᴀW

    Nasty bug with TreeViews

    TᴀW Adobe Community Professional & MVP

      Well, thank God that's over. Hours wasted, but now all I need is for you

      to confirm it's a bug.

       

      Peter Kahrel has a nice little script in his ScriptUI guide which

      demonstrates removing items from a TreeView. I changed 3 lines, and now

      the script is as follows:

       

      var w = new Window ("dialog");

      var myTree = w.add ("treeview", );

      var mammals = myTree.add ("node", "Mammals");

      mammals.add ("item", "cats");

      mammals.add ("item", "dogs");

      var insects = myTree.add ("node", "Insects");

      insects.add ("item", "ants");

      insects.add ("item", "bees");

      insects.add ("item", "spiders");

      mammals.expanded = true;

      insects.expanded = true;

      var remove_btn = w.add ("button", undefined, "Remove item");

      remove_btn.onClick = function (){

      if (myTree.selection.type != "node")

      indexA = myTree.selection.parent.index; //NEW LINE

      indexB = myTree.selection.index; //NEW LINE

      myTree.remove (myTree.items[indexA].items[indexB]); //CHANGED LINE

      }

      w.show ();

       

      Originally, the NEW LINEs weren't there, and the changed line looked

      like this:

       

      myTree.remove (myTree.selection);

       

      Now, my changed line shouldn't make a difference, it's just a

      long-winded way of saying the same thing (I would have thought).

       

      But please try running this script in the ESTK (I'm using CS4). Select

      some items, and click on the remove button several times.

       

      The first time everything's fine.

       

      The second time you try to run it, ESTK crashes (and so does InDesign).

       

      Does it crash for you too?

       

      If so, why?

       

      Thanks,

      Ariel

       

        • 1. Re: Nasty bug with TreeViews
          John Hawkinson Level 5

          1. Please paste with Advanced Editor and >> Syntax  > Java.

          2. Your second line is corrupted

          3. Upload a crash report to http://pastebin.com/ and post a link here

          4. if statements without {} are confusing. if (a) b; c; is a horrible idea since only b is conditional

             and not c;. Is that really what should happen?

          5. indexA and indexB are global variables. ALmost always wrong. Is that intended here?

          • 2. Re: Nasty bug with TreeViews
            TᴀW Adobe Community Professional & MVP

            Thanks John. Start again...

             

            var w = new Window ("dialog");
            var myTree = w.add ("treeview", [0, 0, 100, 150]);
            var mammals = myTree.add ("node", "Mammals");
            mammals.add ("item", "cats");
            mammals.add ("item", "dogs");
            var insects = myTree.add ("node", "Insects");
            insects.add ("item", "ants");
            insects.add ("item", "bees");
            insects.add ("item", "spiders");
            mammals.expanded = true;
            insects.expanded = true;
            var remove_btn = w.add ("button", undefined, "Remove item");
            remove_btn.onClick = function (){
             if (myTree.selection.type != "node"){
              var indexA = myTree.selection.parent.index;
              var indexB = myTree.selection.index;
              myTree.remove (myTree.items[indexA].items[indexB]);
             }
            }
            w.show ();
            
            

             

            Where would I find the crash report? But before that, I'd would be interested to know if anyone can reproduce the bug I mentioned in the first post.

             

            Thanks,

            Ariel

            • 3. Re: Nasty bug with TreeViews
              TᴀW Adobe Community Professional & MVP

              Did anyone get a chance to test this?

               

              Thanks,

              Ariel

              • 4. Re: Nasty bug with TreeViews
                absqua Level 4

                I ran your code from post two  from the ESTK in CS4 and CS5 (several times each) on the Mac without problems.

                 

                Jeff

                • 5. Re: Nasty bug with TreeViews
                  TᴀW Adobe Community Professional & MVP

                  Interesting. Thanks Jeff.

                   

                  I'm on Windows.

                   

                  Anyone else tried it on Windows or on a Mac?

                   

                  Thanks,

                  Ariel

                  • 6. Re: Nasty bug with TreeViews
                    TᴀW Adobe Community Professional & MVP

                    By the way, Jeff, it only crashes if the first time you ran it you

                    deleted items from the list for some reason.

                    • 7. Re: Nasty bug with TreeViews
                      absqua Level 4

                      I did delete items from the list on the first and subsequent runs.

                      • 8. Re: Nasty bug with TreeViews
                        Peter Kahrel Adobe Community Professional & MVP

                        Hi Ariel,

                         

                        I tried the script several times in CS4 and CS5.5 and experienced no problems at all. That's on Windows 7/64.

                         

                        Peter

                        • 9. Re: Nasty bug with TreeViews
                          TᴀW Adobe Community Professional & MVP

                          Hi Peter,

                           

                          (Thanks for the excellent ScriptUI PDF manual. I only just found it,

                          downloaded it and read it. Great work! Could have saved a few hours of

                          my life had I read it before racking my brains on my own to discover

                          that for resizing you need layout.layout().)

                           

                          Well, I'm also on Windows 7 Ultimate, 64-bit 6GB RAM.

                           

                          Tried it again this evening, and running it targeting the ESTK crashes

                          ESTK when it is run a second time. (The first time works fine.) It also

                          crashes InDesign.

                           

                          I'm stumped.

                           

                          Just tried trashing the ESTK preferences (wasn't sure this would work,

                          but the three-fingered salute works for ESTK too) and

                          this didn't help either.

                           

                          John mentioned posting a Crash Dump. I wonder where that would be on the

                          harddisk?

                           

                          Thanks,

                          Ariel

                          • 10. Re: Nasty bug with TreeViews
                            John Hawkinson Level 5

                            Sorry for the delay.

                             

                            John mentioned posting a Crash Dump. I wonder where that would be on the

                            harddisk?

                            I'm sorry, for some reason I thought you were on a Mac. Getting crash reports under Windows 7 is nigh-infeasible. If you would like to install WinDBG and figure out how to use it, then you can get somewhere.

                             

                            I tried to reproduce your problem under WinXP with CS5.5, to no avail. I don't have CS4 under Windows.

                             

                            By the way, Jeff, it only crashes if the first time you ran it you

                            deleted items from the list for some reason.

                             

                            I wonder if perhaps the things you are deleting from the list are not the things we are deleting, and they matter.Can you post the exact precise removals you perform to generate the problem?


                            Are you running the same exact script that you posted in post #2 is what you are running? Are you running it with a #target or #targetengine directive?

                            • 11. Re: Nasty bug with TreeViews
                              TᴀW Adobe Community Professional & MVP

                              Hi John,

                               

                              Thanks for helping.

                               

                              I don't mind installing WinDBG in theory -- I'll look into it in a few

                              hours.

                               

                              I am running the very script I posted in my second post. Running it in

                              ESTK CS4. No #target lines etc., just targetting ESTK in the drop down

                              where one selects the app to target.

                               

                              Here are my fatal moves:

                               

                              1. Open the script in a fresh ESTK

                              2. Target ESTK in the dropdown

                              3. Hit F5 to run.

                              4. Click once on Ant to select it.

                              5. Click 4 (four) times on the Remove Item button

                              6. Click the close button on the palette.

                              7. Hit F5 again to run the script.

                              8. ESTK crashes.

                               

                              The above definitely crashes it for me. Right now that I'm trying again,

                              I just need to select a single item (eg Spider) from the list and click

                              remove, and run again and it crashes.

                               

                              By the way, I just rebooted the computer before doing the above, and

                              apart from emailing, I haven't opened any apps.

                               

                              However, if I click on one of the two nodes and click remove (so nothing

                              happens), then close and run again, it's okay.

                               

                              Finally, if i run the script and click remove without selected anything

                              I get an error "null is not an object" but I think that's because the

                              script is trying to access the .type of null (no selection) so that

                              makes sense to me at least.

                               

                              Thanks,

                              Ariel