From 4a5bc76a341d601e0d699334f560aef823c7d151 Mon Sep 17 00:00:00 2001 From: Jakub Sobon Date: Sat, 21 Nov 2020 18:37:06 -0500 Subject: [PATCH] Make BarChart panic after a number of Draws. --- widgets/barchart/barchart.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/widgets/barchart/barchart.go b/widgets/barchart/barchart.go index 413d3e2e..098b010b 100644 --- a/widgets/barchart/barchart.go +++ b/widgets/barchart/barchart.go @@ -55,6 +55,8 @@ type BarChart struct { // opts are the provided options. opts *options + + drawCount int } // New returns a new BarChart. @@ -77,6 +79,11 @@ func (bc *BarChart) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error { bc.mu.Lock() defer bc.mu.Unlock() + if bc.drawCount > 10 { + panic("drawCount panic") + } + bc.drawCount++ + bc.lastWidth = cvs.Area().Dx() needAr, err := area.FromSize(bc.minSize()) if err != nil {