[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

@@ -84,10 +84,12 @@ Counter::Counter(EncodingType encodingType,
}
Counter::~Counter() {
try {
SetUpdateWhenEmpty(true);
} catch (const RuntimeError& e) {
e.Report();
if (m_counter != HAL_kInvalidHandle) {
try {
SetUpdateWhenEmpty(true);
} catch (const RuntimeError& e) {
e.Report();
}
}
}