disable Fyne thread checks, fix async for connect to server workflow

This commit is contained in:
Drew Weymouth
2025-02-11 17:09:03 -03:00
parent 513a9f53d0
commit 253c08cbf3
2 changed files with 26 additions and 18 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ build:
# so the last 3 cmds move it over manually. This is a bit fragile though # so the last 3 cmds move it over manually. This is a bit fragile though
# since it assumes a specific location and version of the dependency # since it assumes a specific location and version of the dependency
package_macos: package_macos:
CGO_CFLAGS="-I/usr/local/include -I/opt/homebrew/include" CGO_LDFLAGS="-L/usr/local/lib -L/opt/homebrew/lib" fyne package -os darwin CGO_CFLAGS="-I/usr/local/include -I/opt/homebrew/include" CGO_LDFLAGS="-L/usr/local/lib -L/opt/homebrew/lib" fyne package -os darwin -tags migrated_fynedo
bundledeps_macos_homebrew: bundledeps_macos_homebrew:
dylibbundler -od -b -x ./Supersonic.app/Contents/MacOS/supersonic -d ./Supersonic.app/Contents/Frameworks/ -p @executable_path/../Frameworks/ dylibbundler -od -b -x ./Supersonic.app/Contents/MacOS/supersonic -d ./Supersonic.app/Contents/Frameworks/ -p @executable_path/../Frameworks/
+25 -17
View File
@@ -438,7 +438,6 @@ func (c *Controller) DoConnectToServerWorkflow(server *backend.ServerConfig) {
// try connecting to last used server - set up cancelable modal dialog // try connecting to last used server - set up cancelable modal dialog
canceled := false canceled := false
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel()
dlg := dialog.NewCustom(lang.L("Connecting"), lang.L("Cancel"), dlg := dialog.NewCustom(lang.L("Connecting"), lang.L("Cancel"),
widget.NewLabel(fmt.Sprintf(lang.L("Connecting to")+" %s", server.Nickname)), c.MainWindow) widget.NewLabel(fmt.Sprintf(lang.L("Connecting to")+" %s", server.Nickname)), c.MainWindow)
dlg.SetOnClosed(func() { dlg.SetOnClosed(func() {
@@ -447,25 +446,34 @@ func (c *Controller) DoConnectToServerWorkflow(server *backend.ServerConfig) {
}) })
c.haveModal = true c.haveModal = true
dlg.Show() dlg.Show()
// try to connect // try to connect
if err := c.tryConnectToServer(ctx, server, pass); err != nil { go func() {
dlg.Hide() defer cancel() // make sure to free up ctx resources if user does not cancel
c.haveModal = false
if canceled { if err := c.tryConnectToServer(ctx, server, pass); err != nil {
c.PromptForLoginAndConnect() fyne.Do(func() {
} else { dlg.Hide()
// connection failure c.haveModal = false
dlg := dialog.NewError(err, c.MainWindow) if canceled {
dlg.SetOnClosed(func() { c.PromptForLoginAndConnect()
c.PromptForLoginAndConnect() } else {
// connection failure
dlg := dialog.NewError(err, c.MainWindow)
dlg.SetOnClosed(func() {
c.PromptForLoginAndConnect()
})
c.haveModal = true
dlg.Show()
}
})
} else {
fyne.Do(func() {
dlg.Hide()
c.haveModal = false
}) })
c.haveModal = true
dlg.Show()
} }
} else { }()
dlg.Hide()
c.haveModal = false
}
} }
func (m *Controller) PromptForLoginAndConnect() { func (m *Controller) PromptForLoginAndConnect() {