[wpilib] Fix Shuffleboard SuppliedValueWidget (#4559)

It was creating duplicate publishers.
This commit is contained in:
Peter Johnson
2022-11-02 22:49:52 -07:00
committed by GitHub
parent a9606ce870
commit 1831ef3e19
2 changed files with 16 additions and 8 deletions

View File

@@ -36,12 +36,16 @@ class SuppliedValueWidget : public ShuffleboardWidget<SuppliedValueWidget<T>> {
void BuildInto(std::shared_ptr<nt::NetworkTable> parentTable,
std::shared_ptr<nt::NetworkTable> metaTable) override {
this->BuildMetadata(metaTable);
m_controllablePub =
nt::BooleanTopic{metaTable->GetTopic("Controllable")}.Publish();
m_controllablePub.Set(false);
if (!m_controllablePub) {
m_controllablePub =
nt::BooleanTopic{metaTable->GetTopic("Controllable")}.Publish();
m_controllablePub.Set(false);
}
m_entry =
parentTable->GetTopic(this->GetTitle()).GenericPublish(m_typeString);
if (!m_entry) {
m_entry =
parentTable->GetTopic(this->GetTitle()).GenericPublish(m_typeString);
}
m_setter(m_entry, m_supplier());
}