mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[glass] Fix NT view UpdateClients() bug (#4808)
If UpdateClients() was called in the same update batch as an entry removal, it could crash in GetEntry() due to a null entry caused by deletion before a removal erase pass was made.
This commit is contained in:
@@ -478,6 +478,10 @@ void NetworkTablesModel::Update() {
|
||||
entry->info.type_str == "msgpack") {
|
||||
// meta topic handling
|
||||
if (entry->info.name == "$clients") {
|
||||
// need to remove deleted entries as UpdateClients() uses GetEntry()
|
||||
if (updateTree) {
|
||||
std::erase(m_sortedEntries, nullptr);
|
||||
}
|
||||
UpdateClients(entry->value.GetRaw());
|
||||
} else if (entry->info.name == "$serverpub") {
|
||||
m_server.UpdatePublishers(entry->value.GetRaw());
|
||||
@@ -505,9 +509,7 @@ void NetworkTablesModel::Update() {
|
||||
}
|
||||
|
||||
// remove deleted entries
|
||||
m_sortedEntries.erase(
|
||||
std::remove(m_sortedEntries.begin(), m_sortedEntries.end(), nullptr),
|
||||
m_sortedEntries.end());
|
||||
std::erase(m_sortedEntries, nullptr);
|
||||
|
||||
RebuildTree();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user