BUG: fix potential 'nil' reference
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
6d401ea14a
commit
ccb91460ca
6
box.go
6
box.go
|
@ -120,6 +120,12 @@ func HardBox(gw *GuiWindow, axis int, name string) *GuiBox {
|
||||||
func HorizontalBreak(box *GuiBox) {
|
func HorizontalBreak(box *GuiBox) {
|
||||||
log.Println("VerticalSeparator added to box =", box.Name)
|
log.Println("VerticalSeparator added to box =", box.Name)
|
||||||
tmp := ui.NewHorizontalSeparator()
|
tmp := ui.NewHorizontalSeparator()
|
||||||
|
if (box == nil) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (box.UiBox == nil) {
|
||||||
|
return
|
||||||
|
}
|
||||||
box.UiBox.Append(tmp, false)
|
box.UiBox.Append(tmp, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
entry.go
2
entry.go
|
@ -10,7 +10,7 @@ import "github.com/davecgh/go-spew/spew"
|
||||||
// functions for handling text entry boxes
|
// functions for handling text entry boxes
|
||||||
|
|
||||||
func NewLabel(box *GuiBox, text string) {
|
func NewLabel(box *GuiBox, text string) {
|
||||||
box.UiBox.Append(ui.NewLabel(text), false)
|
box.Append(ui.NewLabel(text), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetText(box *GuiBox, name string) string {
|
func GetText(box *GuiBox, name string) string {
|
||||||
|
|
|
@ -105,6 +105,13 @@ func (s GuiBox) SetTitle(title string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s GuiBox) Append(child ui.Control, x bool) {
|
||||||
|
if (s.UiBox == nil) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.UiBox.Append(child, x)
|
||||||
|
}
|
||||||
|
|
||||||
func (s GuiBox) InitTab(title string) *ui.Tab {
|
func (s GuiBox) InitTab(title string) *ui.Tab {
|
||||||
if (s.Window == nil) {
|
if (s.Window == nil) {
|
||||||
return nil
|
return nil
|
||||||
|
|
50
window.go
50
window.go
|
@ -45,21 +45,17 @@ func ErrorWindow(gw *GuiWindow, msg1 string, msg2 string) {
|
||||||
// actual window but that does not appear to work on the MacOS or Windows
|
// actual window but that does not appear to work on the MacOS or Windows
|
||||||
//
|
//
|
||||||
func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
|
func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
|
||||||
window := Data.WindowMap[name]
|
log.Println("InitGuiWindow() START")
|
||||||
if (window != nil) {
|
|
||||||
box := window.BoxMap["MAINBOX"]
|
var box *GuiBox
|
||||||
log.Println("gui.InitWindow() tab already exists name =", name)
|
if (gw == nil) {
|
||||||
ErrorWindow(box.Window, "Create Window Error", "Window " + name + " already exists")
|
box = mapWindow(nil, name, Config.Height, Config.Width)
|
||||||
return nil
|
} else {
|
||||||
|
box = mapWindow(gw.UiWindow, name, Config.Height, Config.Width)
|
||||||
}
|
}
|
||||||
|
|
||||||
// return mapWindow(window, name, Config.Height, Config.Width)
|
// box.Window = &newGuiWindow
|
||||||
log.Println("InitGuiWindow() START")
|
newGuiWindow := box.Window
|
||||||
var newGuiWindow GuiWindow
|
|
||||||
newGuiWindow.Height = Config.Height
|
|
||||||
newGuiWindow.Width = Config.Width
|
|
||||||
newGuiWindow.Axis = axis
|
|
||||||
newGuiWindow.Name = name
|
|
||||||
|
|
||||||
// This is the first window. One must create it here
|
// This is the first window. One must create it here
|
||||||
if (gw == nil) {
|
if (gw == nil) {
|
||||||
|
@ -75,7 +71,7 @@ func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
|
||||||
ui.Quit()
|
ui.Quit()
|
||||||
} else {
|
} else {
|
||||||
// allow a custom exit function
|
// allow a custom exit function
|
||||||
Config.Exit(&newGuiWindow)
|
Config.Exit(newGuiWindow)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
@ -102,15 +98,9 @@ func InitWindow(gw *GuiWindow, name string, axis int) *GuiBox {
|
||||||
newGuiWindow.TabNumber = &tabnum
|
newGuiWindow.TabNumber = &tabnum
|
||||||
}
|
}
|
||||||
|
|
||||||
Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
|
Data.WindowMap[newGuiWindow.Name] = newGuiWindow
|
||||||
|
|
||||||
var box *GuiBox
|
log.Println("InitGuiWindow() END *GuiWindow =", newGuiWindow)
|
||||||
if (axis == Xaxis) {
|
|
||||||
box = HardBox(&newGuiWindow, Xaxis, name)
|
|
||||||
} else {
|
|
||||||
box = HardBox(&newGuiWindow, Yaxis, name)
|
|
||||||
}
|
|
||||||
log.Println("InitGuiWindow() END *GuiWindow =", &newGuiWindow)
|
|
||||||
return box
|
return box
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +171,18 @@ func initBlankWindow() ui.Control {
|
||||||
return hbox
|
return hbox
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var master = 0
|
||||||
|
|
||||||
func mapWindow(window *ui.Window, title string, x int, y int) *GuiBox {
|
func mapWindow(window *ui.Window, title string, x int, y int) *GuiBox {
|
||||||
|
if (Data.WindowMap[title] != nil) {
|
||||||
|
log.Println("Data.WindowMap[title] already exists title =", title)
|
||||||
|
title = title + string(master)
|
||||||
|
}
|
||||||
|
if (Data.WindowMap[title] != nil) {
|
||||||
|
log.Println("Data.WindowMap[title] already exists title =", title)
|
||||||
|
panic("Data.WindowMap[newGuiWindow.Name] already exists")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
var newGuiWindow GuiWindow
|
var newGuiWindow GuiWindow
|
||||||
newGuiWindow.Width = x
|
newGuiWindow.Width = x
|
||||||
newGuiWindow.Height = y
|
newGuiWindow.Height = y
|
||||||
|
@ -191,11 +192,6 @@ func mapWindow(window *ui.Window, title string, x int, y int) *GuiBox {
|
||||||
newGuiWindow.BoxMap = make(map[string]*GuiBox)
|
newGuiWindow.BoxMap = make(map[string]*GuiBox)
|
||||||
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
|
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
|
||||||
|
|
||||||
if (Data.WindowMap[newGuiWindow.Name] != nil) {
|
|
||||||
log.Println("Data.WindowMap[newGuiWindow.Name] already exists\n")
|
|
||||||
panic("Data.WindowMap[newGuiWindow.Name] already exists")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
|
Data.WindowMap[newGuiWindow.Name] = &newGuiWindow
|
||||||
|
|
||||||
var box GuiBox
|
var box GuiBox
|
||||||
|
|
Loading…
Reference in New Issue