Fix new CommandScheduler.cancelAll() (#2251)

When called outside the run loop, it would result in a CME in Java.
This commit is contained in:
Peter Johnson
2020-01-10 16:10:16 -08:00
committed by GitHub
parent 10e8fdb724
commit bf7012fa2d
5 changed files with 45 additions and 6 deletions

View File

@@ -15,6 +15,7 @@
#include <hal/HALBase.h>
#include <networktables/NetworkTableEntry.h>
#include <wpi/DenseMap.h>
#include <wpi/SmallVector.h>
#include "frc2/command/CommandGroupBase.h"
#include "frc2/command/CommandState.h"
@@ -310,9 +311,11 @@ void CommandScheduler::Cancel(std::initializer_list<Command*> commands) {
}
void CommandScheduler::CancelAll() {
wpi::SmallVector<Command*, 16> commands;
for (auto&& command : m_impl->scheduledCommands) {
Cancel(command.first);
commands.emplace_back(command.first);
}
Cancel(commands);
}
double CommandScheduler::TimeSinceScheduled(const Command* command) const {