jsui Causing Max to Crash

Teerath Majumder's icon

Hi all

I am making a custom user interface for a project using jsui. To explain briefly what it does: The user can create containers and controls within each container. Properties of each control is stored in the parent container object, and all container objects are stored in an array named containers. What I want to do is embed the state of the user interface when the patch is saved so that when the patch is closed and reopened, the jsui object is initiated with its last saved state. To that end, I tried two methods following Tim Schenk's js reference. They are:

  1. Using the save() method of jsthis:

    function containersSave(val){
        containers = val;
        mgraphics.redraw();
    }
    
    function save(){
        embedmessage('containersSave', [containers]);
    }
  2. Using the declareattribute() method:

    declareattribute('containers', null, null, 1);

Both methods lead to Max crashing when reopening the patch. So I haven't been able to establish if either method is actually saving anything. Any ideas about what could be causing the crash, and if there's a better way to do what I'm trying to do?

jsui user interface