[wpilibc] Check for invalid handle in destructors (#7212)

Moved-from objects have invalid handles.
This commit is contained in:
Ryan Blue
2024-10-15 22:56:13 -04:00
committed by GitHub
parent 0bada2e102
commit 2b1c5aa4fc
5 changed files with 29 additions and 18 deletions

View File

@@ -45,9 +45,11 @@ PWM::PWM(int channel, bool registerSendable) {
}
PWM::~PWM() {
int32_t status = 0;
HAL_SetPWMDisabled(m_handle, &status);
FRC_ReportError(status, "Channel {}", m_channel);
if (m_handle != HAL_kInvalidHandle) {
int32_t status = 0;
HAL_SetPWMDisabled(m_handle, &status);
FRC_ReportError(status, "Channel {}", m_channel);
}
}
void PWM::SetPulseTime(units::microsecond_t time) {