From abf3836ae2e5441d6ffbf9b3d2e7f63c152f10ed Mon Sep 17 00:00:00 2001 From: Javad Rajabzadeh Date: Sat, 21 Dec 2024 19:48:32 +0330 Subject: [PATCH] fix(gtk): panic on windows 11 and mac (#1650) --- cmd/gtk/assets/ui/widget_node.ui | 2 +- cmd/gtk/dialog_about.go | 8 ++++++-- cmd/gtk/main.go | 8 ++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/gtk/assets/ui/widget_node.ui b/cmd/gtk/assets/ui/widget_node.ui index 5380aee2b..31e1a17b2 100644 --- a/cmd/gtk/assets/ui/widget_node.ui +++ b/cmd/gtk/assets/ui/widget_node.ui @@ -304,7 +304,7 @@ start True True - 📡 Connections + 📡 Connections: 0 diff --git a/cmd/gtk/dialog_about.go b/cmd/gtk/dialog_about.go index e6a04fd7c..947416a9a 100644 --- a/cmd/gtk/dialog_about.go +++ b/cmd/gtk/dialog_about.go @@ -7,6 +7,7 @@ import ( "github.com/gotk3/gotk3/gdk" "github.com/gotk3/gotk3/gtk" + "github.com/pactus-project/pactus/cmd" "github.com/pactus-project/pactus/version" ) @@ -25,9 +26,12 @@ func aboutDialog() *gtk.AboutDialog { dlg := getAboutDialogObj(builder, "id_dialog_about") pxLogo, err := gdk.PixbufNewFromBytesOnly(pactusLogo) - fatalErrorCheck(err) + if err != nil { + cmd.PrintErrorMsgf("Failed to load Logo Pixbuf: %v", err) + } else { + dlg.SetLogo(pxLogo) + } - dlg.SetLogo(pxLogo) dlg.SetVersion(version.NodeVersion.StringWithAlias()) return dlg diff --git a/cmd/gtk/main.go b/cmd/gtk/main.go index 5f0fcc505..f503aa88b 100644 --- a/cmd/gtk/main.go +++ b/cmd/gtk/main.go @@ -34,11 +34,11 @@ func init() { passwordOpt = flag.String("password", "", "wallet password") testnetOpt = flag.Bool("testnet", false, "initializing for the testnet") version.NodeAgent.AppType = "gui" + // the gtk on macos should run on main thread. - if runtime.GOOS == "darwin" { - runtime.UnlockOSThread() - runtime.LockOSThread() - } + runtime.UnlockOSThread() + runtime.LockOSThread() + gtk.Init(nil) }