Skip to content

Commit 35fa418

Browse files
authored
InkHUD crash fix when nodes get deleted from NodeDB (#8428)
* InkHUD crash fix * trunk fix
1 parent 585d9d3 commit 35fa418

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/graphics/niche/InkHUD/Applets/Bases/NodeList/NodeListApplet.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ void InkHUD::NodeListApplet::onRender()
127127
// Y value (top) of the current card. Increases as we draw.
128128
uint16_t cardTopY = headerDivY + padDivH;
129129

130+
// Clean up deleted nodes before drawing
131+
cards.erase(
132+
std::remove_if(cards.begin(), cards.end(), [](const CardInfo &c) { return nodeDB->getMeshNode(c.nodeNum) == nullptr; }),
133+
cards.end());
134+
130135
// -- Each node in list --
131136
for (auto card = cards.begin(); card != cards.end(); ++card) {
132137

@@ -141,6 +146,11 @@ void InkHUD::NodeListApplet::onRender()
141146

142147
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeNum);
143148

149+
// Skip deleted nodes
150+
if (!node) {
151+
continue;
152+
}
153+
144154
// -- Shortname --
145155
// Parse special chars in the short name
146156
// Use "?" if unknown
@@ -188,7 +198,7 @@ void InkHUD::NodeListApplet::onRender()
188198
drawSignalIndicator(signalX, signalY, signalW, signalH, signal);
189199
}
190200
// Otherwise, print "hops away" info, if available
191-
else if (hopsAway != CardInfo::HOPS_UNKNOWN) {
201+
else if (hopsAway != CardInfo::HOPS_UNKNOWN && node) {
192202
std::string hopString = to_string(node->hops_away);
193203
hopString += " Hop";
194204
if (node->hops_away != 1)

0 commit comments

Comments
 (0)