prevent panic messages from being hidden due to ui.Init() race condition

This commit is contained in:
Bradley Cicenas 2017-06-08 17:19:34 -03:00
parent b009a260a4
commit 6392d63ff8
1 changed files with 10 additions and 7 deletions

17
main.go
View File

@ -11,6 +11,7 @@ import (
"github.com/bcicen/ctop/logging"
"github.com/bcicen/ctop/widgets"
ui "github.com/gizak/termui"
tm "github.com/nsf/termbox-go"
)
var (
@ -72,6 +73,12 @@ func main() {
config.Toggle("sortReversed")
}
defer Shutdown()
// init grid, cursor, header
cursor = NewGridCursor()
cGrid = compact.NewCompactGrid()
header = widgets.NewCTopHeader()
// init ui
if *invertFlag {
InvertColorMap()
@ -81,12 +88,6 @@ func main() {
panic(err)
}
defer Shutdown()
// init grid, cursor, header
cursor = NewGridCursor()
cGrid = compact.NewCompactGrid()
header = widgets.NewCTopHeader()
for {
exit := Display()
if exit {
@ -98,7 +99,9 @@ func main() {
func Shutdown() {
log.Notice("shutting down")
log.Exit()
ui.Close()
if tm.IsInit {
ui.Close()
}
}
// ensure a given sort field is valid