Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

getting "ReferenceError: Object is invalid" while resetting a listBox

Community Beginner ,
Jun 18, 2016 Jun 18, 2016

Hi

i'm trying to create a refresh button for a list (that shows the render Q better for my needs). it works fine, i'm removing all the list items and then re-entering them. for some reason when i click the same refresh button for the 6th/7th time i'm getting:

ReferenceError: Object is invalid

(it seems to be related to line 66 in the code - " curItem = folderPathListbox.add ('item', renderItem.toString());    // Column 1")

any help?

i'm lost here...

attached are the JSX and a sample project i use to test it:

thanks

D

here's the code:

try{

    

function createUserInterface (thisObj,userInterfaceString,scriptName){

            var pal = (thisObj instanceof Panel) ? thisObj : new Window("palette", scriptName,

                                        undefined,{resizeable: true});

            if (pal == null) return pal;

           

            var UI=pal.add(userInterfaceString);

           

            pal.layout.layout(true);

            pal.layout.resize();

            pal.onResizing = pal.onResize = function () {

                                                            this.layout.resize();

                                                            }

            if ((pal != null) && (pal instanceof Window)) {

                    pal.show();

            }

    return UI;

};

{var res ="group {orientation:'column',\

                                    alignment:['fill','fill'],\

                                    alignChildren:['fill','top'],\

                                    headerText:StaticText {text:'Render Q lister', alignment:'center'},\

                                    buttonGroup: Group{\

                                                                alignment:['center','top']\

                                                                refButton: Button{text:'Refresh'}\

                                                                dupButton: Button{text:'Duplicate Selected'}\

                                                                selButton: Button{text:'Select in renderQueue'}\

                                                                expButton: Button{text:'Export to File'}\

                                                                }\

                                    folderPathListbox:ListBox{\

                                                            alignment:['fill','fill'],\

                                                            properties:{\

                                                                            multiline:true,\

                                                                            multiselect:true,\

                                                                            numberOfColumns:5,\

                                                                            showHeaders:true,\

                                                                            columnTitles: ['Render #','Date','Time', 'Comp Name', 'Render Path']\

                                                                            }\

                                                            },\

                        }";

                       

}

function listRQ (rqList){

    try{

            var folderPathListbox = rqList;

            var proj = app.project;

            var totalRenderQ = proj.renderQueue.numItems;

            for(var i= 1; i<=totalRenderQ;  i++){

                    var totalOM= proj.renderQueue.item(i).numOutputModules;

                     for (var om= 1; om<=totalOM; om++){

                                    var dateList, timeList, curItem, renderItem;

                                    renderItem =  "Render #" + i + " - " + om ;

                                    if (proj.renderQueue.item(i).startTime != null){

                                                var min = proj.renderQueue.item(i).startTime.getMinutes() <10 ? "0"+ proj.renderQueue.item(i).startTime.getMinutes() : proj.renderQueue.item(i).startTime.getMinutes();

                                                var year = proj.renderQueue.item(i).startTime.getFullYear().toString().substr (-2,2);

                                                timeList = (proj.renderQueue.item(i).startTime.getHours()-1)+":" + min;

                                                dateList =proj.renderQueue.item(i).startTime.getDate()+"/"+(proj.renderQueue.item(i).startTime.getMonth()+1)+"/"+year ;

                                    }else{     

                                            dateList = "not rendered";

                                            timeList = "    ";

                                        }

                                    curItem = folderPathListbox.add ('item', renderItem.toString());    // Column 1

                                    curItem.subItems[0].text = dateList.toString();                         // Column 2

                                    curItem.subItems[1].text = timeList.toString();                          // Column 3

                                    curItem.subItems[2].text = proj.renderQueue.item(i).comp.name; // Column 4

                                    curItem.subItems[3].text = proj.renderQueue.item(i).outputModule(om).file.toString().replace(new RegExp(",","g"), "\r").replace(new RegExp("%20","g"), " ").replace(new RegExp("%5B","g"), "[").replace(new RegExp("%5D","g"), "]"); // Column 5   

                                }

            }

          }catch(err){alert(err)}

    return folderPathListbox;

    }

var UI = createUserInterface(this,res,"Better RQ");

var myList = UI.folderPathListbox;

var lsRq = listRQ(myList);

{ // buttons action

UI.buttonGroup.refButton.onClick = function () {

                                                          

                                                                        lsRq.removeAll();

                                                                        lsRq = listRQ(myList);

                                                                     

    }

UI.buttonGroup.dupButton.onClick = function () {

    alert ("Dup");

    }

UI.buttonGroup.selButton.onClick = function () {

    alert ("Sel");

    }

UI.buttonGroup.expButton.onClick = function () {

    alert ("Exp");

    }

}

}

catch(err){

    alert ("Error at line # " + err.line.toString() + "\r" + err.toString());

    }

TOPICS
Scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 28, 2016 Jun 28, 2016

"Object is invalid" usually means that the object or item no longer exists.  it might be that you are deleting something before you hit the button for the sixth or seventh time.  Make sure that any loops in your code don't reference a render queue item that doesn't exist.  You could also benefit by placing a break point near where the code is error'ing and step through the lines of code to see where the issue is.

If you say it's coming from around line 66, then it might be that renderItem is in fact non-existant.

Hope this helps!

—Arie

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 28, 2016 Jun 28, 2016
LATEST

i figured it out.. it seems that if you try to run the code from extend script it will crush (in different times) but if you run the script via Window menu from within after it'll run just fine..

thanks

D

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines