diff options
| author | Jeff Carr <[email protected]> | 2024-02-09 09:29:55 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-09 09:29:55 -0600 |
| commit | c7ea23ddb6559030d0be98bff090bf919b0c4265 (patch) | |
| tree | 8c2cbd57709c683914e0ffd639e86e07950529a6 | |
| parent | 8317fa28e2da1d22d7248874ebc794189faf23b5 (diff) | |
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | action.go | 6 | ||||
| -rw-r--r-- | main.go | 52 | ||||
| -rw-r--r-- | plugin.go | 5 |
3 files changed, 39 insertions, 24 deletions
@@ -160,7 +160,11 @@ func sendAction(n *Node, atype widget.ActionType) { // sends the action/event to each toolkit via a golang plugin channel func sendActionToPlugin(a *widget.Action) { for _, aplug := range allPlugins { - log.Log(PLUG, "send to toolkit =", aplug.name, "Action type=", a.ActionType, a.WidgetId) + log.Log(CHANGE, "send to toolkit =", aplug.name, "Action type=", a.ActionType, a.WidgetId) + if aplug.dead { + // log.Log(WARN, "skiping dead toolkit =", aplug.name, "Action type=", a.ActionType, a.WidgetId) + return + } if aplug.pluginChan == nil { log.Log(PLUG, "Action() retrieving the aplug.PluginChannel()", aplug.name) aplug.pluginChan = aplug.PluginChannel() @@ -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") @@ -24,6 +24,10 @@ type aplug struct { filename string plug *plugin.Plugin + // set this to true if the plugin dies + // TODO: remove the plugin from the pool + dead bool + // this tells the toolkit plugin how to send events // back here // @@ -269,6 +273,7 @@ func (n *Node) LoadToolkit(name string) *Node { if plug == nil { return n } + plug.dead = false log.Log(PLUG, "LoadToolkit() sending Toolkit Init action to the plugin channel") var a widget.Action |
