From 950bb6016ba354af0205cbfc73128f58c3169868 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 27 Jul 2024 20:15:20 -0400 Subject: [PATCH] validate nodes exist to prevent crash --- components/home/HomeItem.bs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/components/home/HomeItem.bs b/components/home/HomeItem.bs index 83efe5645..c5546d5ab 100644 --- a/components/home/HomeItem.bs +++ b/components/home/HomeItem.bs @@ -6,12 +6,12 @@ import "pkg:/source/roku_modules/log/LogMixin.brs" sub init() m.log = log.Logger("HomeItem") - m.itemText = m.top.findNode("itemText") - m.itemPoster = m.top.findNode("itemPoster") + initItemText() + initItemPoster() m.itemProgress = m.top.findNode("progress") m.itemProgressBackground = m.top.findNode("progressBackground") m.itemIcon = m.top.findNode("itemIcon") - m.itemTextExtra = m.top.findNode("itemTextExtra") + initItemTextExtra() m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged") m.unplayedCount = m.top.findNode("unplayedCount") m.unplayedEpisodeCount = m.top.findNode("unplayedEpisodeCount") @@ -34,6 +34,17 @@ sub init() m.backdrop.color = backdropColor end sub +sub initItemText() + m.itemText = m.top.findNode("itemText") +end sub + +sub initItemPoster() + m.itemPoster = m.top.findNode("itemPoster") +end sub + +sub initItemTextExtra() + m.itemTextExtra = m.top.findNode("itemTextExtra") +end sub sub itemContentChanged() if isValid(m.unplayedCount) then m.unplayedCount.visible = false @@ -43,6 +54,11 @@ sub itemContentChanged() itemData.Title = itemData.name ' Temporarily required while we move from "HomeItem" to "JFContentItem" + ' validate to prevent crash + if not isValid(m.itemPoster) then initItemPoster() + if not isValid(m.itemText) then initItemText() + if not isValid(m.itemTextExtra) then initItemTextExtra() + m.itemPoster.width = itemData.imageWidth m.itemText.maxWidth = itemData.imageWidth m.itemTextExtra.width = itemData.imageWidth