Infinite recursion constucting an ActionGroup

i need to add a set of dynamically created menu items to a menu group, so I tried doing something like this:

plugin.xml:
...
]]>
...

Group.java:
public class Group extends ActionGroup {
...
public Group() {
System.out.println("ctor");
for (AnAction a : actions) {
System.out.println("add");
add(a);
}
}
}

This results in a stack overflow exception, with console output like

ctor
add
ctor
add
ctor
add
...

Why does calling add() in the constructor cause the constructor to be called again? What's the correct way to do this?

L.

2 comments

Any suggestions on this one? Calling add() from an ActionGroup constructor to create the group's items seems like a natural thing to do to me...

L.

0

You should post a more complete example and the stack trace you're getting. Also, ActionGroup doesn't have an add() method and I don't see how DefaultActionGroup (if that is what you're actually using - if not, use it) could cause an infinite recursion here.

Sascha

0

Please sign in to leave a comment.