From 9d7293734a65f9064d0f46b0c5993292e6622692 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 3 Mar 2018 21:34:42 -0800 Subject: [PATCH] SendableChooser: Do not automatically add to LiveWindow. (#964) SendableChooser::InitSendable() is written such that it saves the table being used in an instance variable. This doesn't work if the chooser is added to both LiveWindow and SmartDashboard. Normally it is not added to LiveWindow because the name is empty, but if setName() is called this could still happen. Note adding the same SendableChooser to SmartDashboard with two different names is also not currently supported, for the same reason. The correct solution will be to remove the instance variable, but this is too high risk to implement mid-season, so instead just remove from LiveWindow. --- .../main/native/cpp/SmartDashboard/SendableChooserBase.cpp | 5 +++++ .../main/native/include/SmartDashboard/SendableChooserBase.h | 1 + .../wpi/first/wpilibj/smartdashboard/SendableChooser.java | 1 + 3 files changed, 7 insertions(+) diff --git a/wpilibc/src/main/native/cpp/SmartDashboard/SendableChooserBase.cpp b/wpilibc/src/main/native/cpp/SmartDashboard/SendableChooserBase.cpp index 3edd099f7f..e90eb243e3 100644 --- a/wpilibc/src/main/native/cpp/SmartDashboard/SendableChooserBase.cpp +++ b/wpilibc/src/main/native/cpp/SmartDashboard/SendableChooserBase.cpp @@ -12,3 +12,8 @@ using namespace frc; const char* SendableChooserBase::kDefault = "default"; const char* SendableChooserBase::kOptions = "options"; const char* SendableChooserBase::kSelected = "selected"; + +/** + * Instantiates a SendableChooser. + */ +SendableChooserBase::SendableChooserBase() : SendableBase(false) {} diff --git a/wpilibc/src/main/native/include/SmartDashboard/SendableChooserBase.h b/wpilibc/src/main/native/include/SmartDashboard/SendableChooserBase.h index de504a0afb..c996ee3c73 100644 --- a/wpilibc/src/main/native/include/SmartDashboard/SendableChooserBase.h +++ b/wpilibc/src/main/native/include/SmartDashboard/SendableChooserBase.h @@ -23,6 +23,7 @@ namespace frc { */ class SendableChooserBase : public SendableBase { public: + SendableChooserBase(); ~SendableChooserBase() override = default; protected: diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java index 0a1b1bc303..c79521de39 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableChooser.java @@ -51,6 +51,7 @@ public class SendableChooser extends SendableBase implements Sendable { * Instantiates a {@link SendableChooser}. */ public SendableChooser() { + super(false); } /**