From 7954524bacfccac08a62728f7dbf670cccb46b0d Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Wed, 31 Dec 2025 12:50:34 -0500 Subject: [PATCH] fix(ui): Prevent crash from nil raster image for enabled modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The diagonal stripe pattern raster function was returning nil for enabled modules, causing a nil pointer dereference when Fyne tried to process the texture. Fixed by always returning a valid image - transparent for enabled modules, striped for disabled modules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- internal/ui/components.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/internal/ui/components.go b/internal/ui/components.go index 7272389..bf1b091 100644 --- a/internal/ui/components.go +++ b/internal/ui/components.go @@ -179,24 +179,26 @@ func (m *ModuleTile) CreateRenderer() fyne.WidgetRenderer { // Diagonal stripe overlay for disabled modules disabledStripe := canvas.NewRaster(func(w, h int) image.Image { - if m.enabled { - return nil - } img := image.NewRGBA(image.Rect(0, 0, w, h)) - // Semi-transparent dark stripes - darkStripe := color.NRGBA{R: 0, G: 0, B: 0, A: 100} - lightStripe := color.NRGBA{R: 0, G: 0, B: 0, A: 30} - for y := 0; y < h; y++ { - for x := 0; x < w; x++ { - // Thicker diagonal stripes (dividing by 8 instead of 4) - if ((x + y) / 8 % 2) == 0 { - img.Set(x, y, darkStripe) - } else { - img.Set(x, y, lightStripe) + // Only draw stripes if disabled + if !m.enabled { + // Semi-transparent dark stripes + darkStripe := color.NRGBA{R: 0, G: 0, B: 0, A: 100} + lightStripe := color.NRGBA{R: 0, G: 0, B: 0, A: 30} + + for y := 0; y < h; y++ { + for x := 0; x < w; x++ { + // Thicker diagonal stripes (dividing by 8 instead of 4) + if ((x + y) / 8 % 2) == 0 { + img.Set(x, y, darkStripe) + } else { + img.Set(x, y, lightStripe) + } } } } + // Return transparent image for enabled modules return img })