mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-14 06:42:34 +00:00
InkHUD crash fix when nodes get deleted from NodeDB (#8428)
* InkHUD crash fix * trunk fix
This commit is contained in:
@@ -127,6 +127,11 @@ void InkHUD::NodeListApplet::onRender()
|
|||||||
// Y value (top) of the current card. Increases as we draw.
|
// Y value (top) of the current card. Increases as we draw.
|
||||||
uint16_t cardTopY = headerDivY + padDivH;
|
uint16_t cardTopY = headerDivY + padDivH;
|
||||||
|
|
||||||
|
// Clean up deleted nodes before drawing
|
||||||
|
cards.erase(
|
||||||
|
std::remove_if(cards.begin(), cards.end(), [](const CardInfo &c) { return nodeDB->getMeshNode(c.nodeNum) == nullptr; }),
|
||||||
|
cards.end());
|
||||||
|
|
||||||
// -- Each node in list --
|
// -- Each node in list --
|
||||||
for (auto card = cards.begin(); card != cards.end(); ++card) {
|
for (auto card = cards.begin(); card != cards.end(); ++card) {
|
||||||
|
|
||||||
@@ -141,6 +146,11 @@ void InkHUD::NodeListApplet::onRender()
|
|||||||
|
|
||||||
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeNum);
|
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeNum);
|
||||||
|
|
||||||
|
// Skip deleted nodes
|
||||||
|
if (!node) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// -- Shortname --
|
// -- Shortname --
|
||||||
// Parse special chars in the short name
|
// Parse special chars in the short name
|
||||||
// Use "?" if unknown
|
// Use "?" if unknown
|
||||||
@@ -188,7 +198,7 @@ void InkHUD::NodeListApplet::onRender()
|
|||||||
drawSignalIndicator(signalX, signalY, signalW, signalH, signal);
|
drawSignalIndicator(signalX, signalY, signalW, signalH, signal);
|
||||||
}
|
}
|
||||||
// Otherwise, print "hops away" info, if available
|
// Otherwise, print "hops away" info, if available
|
||||||
else if (hopsAway != CardInfo::HOPS_UNKNOWN) {
|
else if (hopsAway != CardInfo::HOPS_UNKNOWN && node) {
|
||||||
std::string hopString = to_string(node->hops_away);
|
std::string hopString = to_string(node->hops_away);
|
||||||
hopString += " Hop";
|
hopString += " Hop";
|
||||||
if (node->hops_away != 1)
|
if (node->hops_away != 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user