aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-04-16 23:01:59 +0300
committerTulir Asokan <tulir@maunium.net>2018-04-16 23:01:59 +0300
commite9141f6577579febe698aedd65c2ba06e7175183 (patch)
tree16a49658e24e4f0bd878c9c07fabdc204be49cbe /lib
parentb728678f0ce07c239d377829ee886616918c30c8 (diff)
Recover panics in ANSImage.Render()
Diffstat (limited to 'lib')
-rw-r--r--lib/ansimage/ansimage.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/ansimage/ansimage.go b/lib/ansimage/ansimage.go
index b117b3d..73425be 100644
--- a/lib/ansimage/ansimage.go
+++ b/lib/ansimage/ansimage.go
@@ -26,6 +26,7 @@ import (
_ "golang.org/x/image/bmp" // initialize decoder
_ "golang.org/x/image/tiff" // initialize decoder
_ "golang.org/x/image/webp" // initialize decoder
+ "maunium.net/go/gomuks/debug"
"maunium.net/go/gomuks/ui/messages/tstring"
"maunium.net/go/tcell"
)
@@ -126,6 +127,11 @@ func (ai *ANSImage) Render() []tstring.TString {
ch := make(chan renderData, ai.maxprocs)
for n, row := 0, y; (n <= ai.maxprocs) && (2*row+1 < ai.h); n, row = n+1, y+n {
go func(row, y int) {
+ defer func() {
+ err := recover()
+ debug.Print("Panic rendering ANSImage:", err)
+ ch <- renderData{row: row, render: tstring.NewColorTString("ERROR", tcell.ColorRed)}
+ }()
str := make(tstring.TString, ai.w)
for x := 0; x < ai.w; x++ {
topPixel := ai.pixmap[y][x]