XML Feeds

.

[java-dev] getParentPatcher().getPath() does not always work in the constructor

Adam Murray adamjmurray at gmail.com
Tue Mar 4 00:45:07 MST 2008


I noticed some inconsistent behavior with getParentPatcher().getPath() when used inside a constructor. 

When I open the patch for the first time, it will return null. If I delete the mxj object and undo, then it will return the correct path. It's like the parent patcher doesn't initialize until after the mxj object, which seems backwards to me. Is it a bug?

I can work around this problem by using a MaxQelem, which so far seems to work flawlessly. 


import com.cycling74.max.Executable;
import com.cycling74.max.MaxObject;
import com.cycling74.max.MaxQelem;

public class test extends MaxObject {

	public test() {
		post("path: " + getParentPatcher().getPath());
		initializer.set();
	}

	private MaxQelem initializer = new MaxQelem(new Executable() {
		public void execute() {
			post("inside qelem, path: " + getParentPatcher().getPath());
		}
	});

	protected void notifyDeleted() {
		initializer.release();
	}

}


--
Adam Murray
compusition.com


More information about the java-dev mailing list