mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
prevent panic messages from being hidden due to ui.Init() race condition
This commit is contained in:
parent
b009a260a4
commit
6392d63ff8
17
main.go
17
main.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user