summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go52
1 files changed, 29 insertions, 23 deletions
diff --git a/main.go b/main.go
index 3b8dfc5..df716e3 100644
--- a/main.go
+++ b/main.go
@@ -65,12 +65,35 @@ func pluginCounter(a *widget.Action) {
found = true
}
}
- if ! found {
+ if !found {
// TODO: fix this by making seperate channels for each plugin?
log.Log(WARN, "ListToolkits() got event from unidentified plugin")
}
}
+func toolkitPanic(pname string) {
+ log.Log(WARN, "toolkitPanic() in", pname)
+ log.Log(WARN, "toolkitPanic() unload toolkit plugin here", pname)
+ me.rootNode.ListToolkits()
+ for _, aplug := range allPlugins {
+ if aplug.name == pname {
+ log.Log(WARN, "toolkitPanic() FOUND PLUGIN =", aplug.name)
+ log.Log(WARN, "toolkitPanic() unload here aplug.dead =", aplug.dead)
+ log.Log(WARN, "toolkitPanic() TODO: stop talking to plugin:", pname)
+ aplug.dead = true
+ log.Log(WARN, "toolkitPanic() unload here aplug.dead =", aplug.dead)
+ // me.rootNode.CloseToolkit(aplug.name)
+ // panic("panic trapped!")
+ // log.Sleep(.5)
+ // me.rootNode.LoadToolkit("gocui")
+ }
+ }
+ // log.UnsetTmp()
+ // StandardExit()
+ log.Log(WARN, "toolkitPanic() attempt to load nocui")
+ me.rootNode.LoadToolkit("nocui")
+}
+
func watchCallback() {
log.Log(INFO, "guiChan() START")
for {
@@ -79,6 +102,11 @@ func watchCallback() {
case a := <-me.guiChan:
pluginCounter(&a)
+ if a.ActionType == widget.ToolkitPanic {
+ toolkitPanic(a.ProgName)
+ break
+ }
+
// 99.9% of events are just widget changes
n := me.rootNode.findId(a.WidgetId)
if n != nil {
@@ -93,28 +121,6 @@ func watchCallback() {
log.Exit("wit/gui toolkit.UserQuit")
break
}
- if a.ActionType == widget.ToolkitPanic {
- log.Log(WARN, "guiChan() Toolkit panic() in", a.ProgName)
- log.Log(WARN, "guiChan() unload toolkit plugin here", a.ProgName)
- me.rootNode.ListToolkits()
- for _, aplug := range allPlugins {
- log.Log(WARN, "ListToolkits() already loaded toolkit plugin =", aplug.name)
- if aplug.name == a.ProgName {
- log.Log(WARN, "FOUND PLUGIN =", aplug.name)
- log.Log(WARN, "unload here")
- log.Log(WARN, "panic on purpose")
- me.rootNode.CloseToolkit(aplug.name)
- // panic("panic trapped!")
- // log.Sleep(.5)
- // me.rootNode.LoadToolkit("gocui")
- break
- }
- }
- log.UnsetTmp()
- // StandardExit()
- me.rootNode.LoadToolkit("nocui")
- break
- }
if a.ActionType == widget.ToolkitLoad {
newPlug := widget.GetString(a.Value)
log.Log(WARN, "Attempt to load a new toolkit", newPlug, "here")