cogentcore / core

A free and open source framework for building powerful, fast, and elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the Web with a single pure Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.32k stars 71 forks source link

Crash in giv.ColorView, from editing etable eplot2d column color #861

Closed rcoreilly closed 5 months ago

rcoreilly commented 5 months ago

Describe the bug

Crash in giv.ColorView, from editing etable eplot2d column color

How to reproduce

etable/examples/plot -- edit plotted col, click on color, change it, hit Ok.

Example code

This assumption of *color.RGBA is clearly sus:

    NewColorView(d).SetColor(dclr).SetTmpSave(vv.TmpSave)
    return true, func() {
        cclr := laser.OnePtrValue(vv.TmpSave.Val()).Interface().(*color.RGBA)
        vv.SetColor(*cclr)
        vv.UpdateWidget()
    }

Relevant output

Running on GPU: Apple M3 Max: id=235013104 idx=0
panic: interface conversion: interface {} is *color.Color, not *color.RGBA

----- START OF STACK TRACE: -----
goroutine 40721 [running]:
runtime/debug.Stack()
    /opt/homebrew/Cellar/go/1.21.4/libexec/src/runtime/debug/stack.go:24 +0x64
cogentcore.org/core/goosi.HandleRecoverBase({0x10755d5e0, 0x1402caf2900})
    /Users/oreilly/go/src/cogentcore.org/core/goosi/recover.go:50 +0x38
cogentcore.org/core/gi.HandleRecover({0x10755d5e0, 0x1402caf2900})
    /Users/oreilly/go/src/cogentcore.org/core/gi/recover.go:26 +0x40
cogentcore.org/core/gi.(*RenderWin).EventLoop.func1()
    /Users/oreilly/go/src/cogentcore.org/core/gi/renderwin.go:589 +0x34
panic({0x10755d5e0?, 0x1402caf2900?})
    /opt/homebrew/Cellar/go/1.21.4/libexec/src/runtime/panic.go:914 +0x218
cogentcore.org/core/giv.(*ColorValue).ConfigDialog.func1()
    /Users/oreilly/go/src/cogentcore.org/core/giv/colorview.go:631 +0x8c
cogentcore.org/core/giv.OpenValueDialog.func2.1({0x1402def5600?, 0x10770a460?})
    /Users/oreilly/go/src/cogentcore.org/core/giv/value.go:955 +0x40
cogentcore.org/core/giv.OpenValueDialog.func2.(*WidgetBase).OnClick.(*WidgetBase).On.func2({0x107717168, 0x1403104eee0})
    /Users/oreilly/go/src/cogentcore.org/core/gi/events.go:49 +0x7c
cogentcore.org/core/events.(*Listeners).Call(0x1402def5d38, {0x107717168, 0x1403104eee0})

Platform

macOS