From d16f05f2c87e18733cd84a372084ec52a1122f12 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Mon, 30 Nov 2020 19:24:12 -0800 Subject: [PATCH] [wpilib] Fix SmartDashboard update order (#2896) We need to execute listener tasks first, then execute value updates. Otherwise local changes can fight with dashboard-made changes. --- wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp | 4 ++-- .../edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp index 5e70a4c64d..1fdf22f890 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2011-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -257,7 +257,7 @@ void SmartDashboard::PostListenerTask(std::function task) { void SmartDashboard::UpdateValues() { auto& registry = SendableRegistry::GetInstance(); auto& inst = Singleton::GetInstance(); + listenerExecutor.RunListenerTasks(); std::scoped_lock lock(inst.tablesToDataMutex); for (auto& i : inst.tablesToData) registry.Update(i.getValue()); - listenerExecutor.RunListenerTasks(); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java index 1b022c18b0..e68b867e78 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.java @@ -528,10 +528,10 @@ public final class SmartDashboard { * Puts all sendable data to the dashboard. */ public static synchronized void updateValues() { + // Execute posted listener tasks + listenerExecutor.runListenerTasks(); for (Sendable data : tablesToData.values()) { SendableRegistry.update(data); } - // Execute posted listener tasks - listenerExecutor.runListenerTasks(); } }