This splash screen OK button might be exiting without causing a GTK panic
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
eb9ddc3d5b
commit
287dff1a08
|
@ -10,7 +10,6 @@ import _ "github.com/andlabs/ui/winmanifest"
|
|||
var mainwin *ui.Window
|
||||
var hbox *ui.Box
|
||||
var vbox *ui.Box
|
||||
var newgroup *ui.Group
|
||||
|
||||
func makeSplashPage() ui.Control {
|
||||
hbox = ui.NewHorizontalBox()
|
||||
|
@ -43,8 +42,48 @@ func makeSplashPage() ui.Control {
|
|||
return hbox
|
||||
}
|
||||
|
||||
func showSplash() {
|
||||
splashWin := ui.NewWindow("Splash Screen", 640, 480, false)
|
||||
splashWin.OnClosing(func(*ui.Window) bool {
|
||||
ui.Quit()
|
||||
return true
|
||||
})
|
||||
ui.OnShouldQuit(func() bool {
|
||||
splashWin.Destroy()
|
||||
return true
|
||||
})
|
||||
|
||||
tab := ui.NewTab()
|
||||
splashWin.SetChild(tab)
|
||||
splashWin.SetMargined(true)
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
|
||||
group := ui.NewGroup("Numbers")
|
||||
group.SetMargined(true)
|
||||
hbox.Append(group, true)
|
||||
|
||||
vbox = ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
group.SetChild(vbox)
|
||||
|
||||
okButton := ui.NewButton("OK")
|
||||
okButton.OnClicked(func(*ui.Button) {
|
||||
log.Println("OK. Closing window.")
|
||||
splashWin.Destroy()
|
||||
ui.Quit()
|
||||
})
|
||||
vbox.Append(okButton, false)
|
||||
|
||||
tab.Append("WIT Splash", hbox)
|
||||
tab.SetMargined(0, true)
|
||||
|
||||
splashWin.Show()
|
||||
}
|
||||
|
||||
func setupUI() {
|
||||
mainwin = ui.NewWindow("gui-example1", 300, 200, false)
|
||||
mainwin := ui.NewWindow("gui-example1", 300, 200, false)
|
||||
mainwin.OnClosing(func(*ui.Window) bool {
|
||||
ui.Quit()
|
||||
return true
|
||||
|
@ -65,29 +104,35 @@ func setupUI() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
go ui.Main(setupUI)
|
||||
ui.Main(showSplash)
|
||||
|
||||
ui.Main(setupUI)
|
||||
|
||||
// locks up GTK after a while (50 times)
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
count := 0
|
||||
for {
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
log.Println("sleep")
|
||||
|
||||
if (newgroup == nil) {
|
||||
name := "Test " + fmt.Sprintf("%d", count)
|
||||
log.Println("name=",name)
|
||||
newgroup = ui.NewGroup(name)
|
||||
newgroup.SetMargined(true)
|
||||
hbox.Append(newgroup, false)
|
||||
// newgroup = append(newgroup, group)
|
||||
count += 1
|
||||
} else {
|
||||
hbox.Delete(1)
|
||||
// newgroup.Delete()
|
||||
// can't destroy when there is a parent
|
||||
newgroup.Destroy()
|
||||
newgroup = nil
|
||||
}
|
||||
var newgroup *ui.Group
|
||||
|
||||
name := "Test " + fmt.Sprintf("%d", count)
|
||||
log.Println("name=",name)
|
||||
newgroup = ui.NewGroup(name)
|
||||
newgroup.SetMargined(true)
|
||||
hbox.Append(newgroup, false)
|
||||
|
||||
// display the splash screen info
|
||||
log.Println("sleep for 3")
|
||||
time.Sleep(3000 * time.Millisecond)
|
||||
|
||||
hbox.Delete(1)
|
||||
// newgroup.Delete()
|
||||
// can't destroy when there is a parent
|
||||
newgroup.Destroy()
|
||||
newgroup = nil
|
||||
|
||||
// wait forever here
|
||||
for {
|
||||
log.Println("sleep for 3 forever here")
|
||||
time.Sleep(3000 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
run:
|
||||
go run *.go
|
|
@ -0,0 +1,35 @@
|
|||
2019/05/17 10:59:15 name= Test 128
|
||||
2019/05/17 10:59:15 sleep
|
||||
2019/05/17 10:59:15 sleep
|
||||
2019/05/17 10:59:15 name= Test 129
|
||||
2019/05/17 10:59:16 sleep
|
||||
fatal error: unexpected signal during runtime execution
|
||||
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f8c000000b8 pc=0x7f8cbfb2f8e5]
|
||||
|
||||
runtime stack:
|
||||
runtime.throw(0x50c4b8, 0x2a)
|
||||
/usr/lib/go-1.11/src/runtime/panic.go:608 +0x72
|
||||
runtime.sigpanic()
|
||||
/usr/lib/go-1.11/src/runtime/signal_unix.go:374 +0x2f2
|
||||
|
||||
goroutine 19 [syscall]:
|
||||
runtime.cgocall(0x4b5490, 0xc00004df78, 0xc0000ac048)
|
||||
/usr/lib/go-1.11/src/runtime/cgocall.go:128 +0x5e fp=0xc00004df48 sp=0xc00004df10 pc=0x41688e
|
||||
github.com/andlabs/ui._Cfunc_uiMain()
|
||||
_cgo_gotypes.go:2518 +0x41 fp=0xc00004df78 sp=0xc00004df48 pc=0x4a9711
|
||||
github.com/andlabs/ui.Main(0x50d890, 0xc00003a701, 0xc0000842c0)
|
||||
/home/jcarr/go/src/github.com/andlabs/ui/main.go:41 +0xfd fp=0xc00004dfc8 sp=0xc00004df78 pc=0x4ad6cd
|
||||
runtime.goexit()
|
||||
/usr/lib/go-1.11/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc00004dfd0 sp=0xc00004dfc8 pc=0x466461
|
||||
created by main.main
|
||||
/home/jcarr/go/src/git.wit.com/wit/cloud-control-panel/example-splash/main.go:68 +0x53
|
||||
|
||||
goroutine 1 [sleep, locked to thread]:
|
||||
time.Sleep(0x11e1a300)
|
||||
/usr/lib/go-1.11/src/runtime/time.go:105 +0x14f
|
||||
main.main()
|
||||
/home/jcarr/go/src/git.wit.com/wit/cloud-control-panel/example-splash/main.go:74 +0x74
|
||||
exit status 2
|
||||
make: *** [Makefile:2: run] Error 1
|
||||
jcarr@librem15:~/go/src/git.wit.com/wit/cloud-control-panel/example-splash$ git diff
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package main
|
||||
|
||||
import "time"
|
||||
import "log"
|
||||
import "fmt"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
var mainwin *ui.Window
|
||||
var hbox *ui.Box
|
||||
var vbox *ui.Box
|
||||
var newgroup *ui.Group
|
||||
|
||||
func makeSplashPage() ui.Control {
|
||||
hbox = ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
|
||||
group := ui.NewGroup("Numbers")
|
||||
group.SetMargined(true)
|
||||
hbox.Append(group, true)
|
||||
|
||||
vbox = ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
group.SetChild(vbox)
|
||||
|
||||
spinbox := ui.NewSpinbox(47, 100)
|
||||
slider := ui.NewSlider(21, 100)
|
||||
pbar := ui.NewProgressBar()
|
||||
|
||||
spinbox.OnChanged(func(*ui.Spinbox) {
|
||||
slider.SetValue(spinbox.Value())
|
||||
pbar.SetValue(spinbox.Value())
|
||||
})
|
||||
slider.OnChanged(func(*ui.Slider) {
|
||||
spinbox.SetValue(slider.Value())
|
||||
pbar.SetValue(slider.Value())
|
||||
})
|
||||
vbox.Append(spinbox, false)
|
||||
vbox.Append(slider, false)
|
||||
vbox.Append(pbar, false)
|
||||
|
||||
return hbox
|
||||
}
|
||||
|
||||
func setupUI() {
|
||||
mainwin = ui.NewWindow("gui-example1", 300, 200, false)
|
||||
mainwin.OnClosing(func(*ui.Window) bool {
|
||||
ui.Quit()
|
||||
return true
|
||||
})
|
||||
ui.OnShouldQuit(func() bool {
|
||||
mainwin.Destroy()
|
||||
return true
|
||||
})
|
||||
|
||||
tab := ui.NewTab()
|
||||
mainwin.SetChild(tab)
|
||||
mainwin.SetMargined(true)
|
||||
|
||||
tab.Append("WIT Splash", makeSplashPage())
|
||||
tab.SetMargined(0, true)
|
||||
|
||||
mainwin.Show()
|
||||
}
|
||||
|
||||
func main() {
|
||||
go ui.Main(setupUI)
|
||||
|
||||
// locks up GTK after a while (50 times)
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
count := 0
|
||||
for {
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
log.Println("sleep")
|
||||
|
||||
if (newgroup == nil) {
|
||||
name := "Test " + fmt.Sprintf("%d", count)
|
||||
log.Println("name=",name)
|
||||
newgroup = ui.NewGroup(name)
|
||||
newgroup.SetMargined(true)
|
||||
hbox.Append(newgroup, false)
|
||||
// newgroup = append(newgroup, group)
|
||||
count += 1
|
||||
} else {
|
||||
hbox.Delete(1)
|
||||
// newgroup.Delete()
|
||||
// can't destroy when there is a parent
|
||||
newgroup.Destroy()
|
||||
newgroup = nil
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue