When using an @OpModeRegistrar annotated method to register OpModes and registering one with OpModeManager.register(OpModeMeta name, Class<? extends OpMode> class) the group from the meta is not used. Instead the default group is used.
This issue seems to stem from org.firstinspires.ftc.robotcore.internal.opmode.AnnotatedOpModeClassFilter#addUserNamedOpMode because it always overwrites the group name with the default one instead of checking if the meta doesn't have a group name in it and then setting the default group name. The problematic method is reproduced below.
private boolean addUserNamedOpMode(Class<OpMode> clazz, OpModeMeta meta) {
OpModeMetaAndClass opModeMetaAndClass = new OpModeMetaAndClass(meta, clazz);
this.classNameOverrides.put(clazz, opModeMetaAndClass);
return addToOpModeGroup(defaultOpModeGroupName, opModeMetaAndClass);
}
An sample to reproduce the issue is provided. When ran notice how the two OpModes are in different groups despite having the same group name.
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.OpModeManager;
import com.qualcomm.robotcore.eventloop.opmode.OpModeRegistrar;
import org.firstinspires.ftc.robotcore.internal.opmode.OpModeMeta;
public class OpModeRegistrarTest {
public static class OpModeOne extends LinearOpMode {
@Override
public void runOpMode() throws InterruptedException {}
}
public static class OpModeTwo extends LinearOpMode {
@Override
public void runOpMode() throws InterruptedException {}
}
@OpModeRegistrar
public static void register(OpModeManager manager) {
manager.register(
new OpModeMeta.Builder()
.setName("Test OpMode One")
.setGroup("Test Group")
.setFlavor(OpModeMeta.Flavor.TELEOP)
.setSource(OpModeMeta.Source.ANDROID_STUDIO)
.build(),
OpModeOne.class
);
manager.register(
new OpModeMeta.Builder()
.setName("Test OpMode Two")
.setGroup("Test Group")
.setFlavor(OpModeMeta.Flavor.TELEOP)
.setSource(OpModeMeta.Source.ANDROID_STUDIO)
.build(),
new OpModeTwo()
);
}
}
When using an
@OpModeRegistrarannotated method to register OpModes and registering one withOpModeManager.register(OpModeMeta name, Class<? extends OpMode> class)the group from the meta is not used. Instead the default group is used.This issue seems to stem from
org.firstinspires.ftc.robotcore.internal.opmode.AnnotatedOpModeClassFilter#addUserNamedOpModebecause it always overwrites the group name with the default one instead of checking if the meta doesn't have a group name in it and then setting the default group name. The problematic method is reproduced below.An sample to reproduce the issue is provided. When ran notice how the two OpModes are in different groups despite having the same group name.