mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
prevent panic messages from being hidden due to ui.Init() race condition
This commit is contained in:
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
|
||||
|
||||
Reference in New Issue
Block a user