Skip to content

Commit 557fb36

Browse files
committed
qt/server: ignore -psn_xxxx flags on macOS
This is a blind attempt to fix the issue that the app does not start on macOS the first time, somtimes. The args are logged so we can inspect if the weird arg was really passed or not.
1 parent 1c74f06 commit 557fb36

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

frontends/qt/server/server.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ import "C"
4141

4242
import (
4343
"flag"
44+
"os"
45+
"runtime"
46+
"strings"
4447
"unsafe"
4548

4649
"github.com/digitalbitbox/bitbox-wallet-app/backend/bridgecommon"
4750
btctypes "github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/types"
4851
"github.com/digitalbitbox/bitbox-wallet-app/backend/devices/usb"
52+
"github.com/digitalbitbox/bitbox-wallet-app/util/logging"
4953
"github.com/digitalbitbox/bitbox-wallet-app/util/system"
5054
)
5155

@@ -76,11 +80,24 @@ func serve(
7680
responseCallback C.responseCallback,
7781
notifyUserCallback C.notifyUserCallback,
7882
) {
83+
log := logging.Get().WithGroup("server")
84+
log.WithField("args", os.Args).Info("Started Qt application")
7985
// workaround: this flag is parsed by qtwebengine, but flag.Parse() quits the app on
8086
// unrecognized flags
8187
// _ = flag.Int("remote-debugging-port", 0, "")
8288
testnet := flag.Bool("testnet", false, "activate testnets")
8389

90+
if runtime.GOOS == "darwin" {
91+
// eat "-psn_xxxx" on Mac, which is passed when starting an app from Finder for the first time.
92+
// See also: https://stackoverflow.com/questions/10242115/os-x-strange-psn-command-line-parameter-when-launched-from-finder
93+
for _, arg := range os.Args[1:] {
94+
trimmed := strings.TrimLeft(arg, "-")
95+
if strings.HasPrefix(trimmed, "psn_") {
96+
flag.Bool(trimmed, false, "<ignored>")
97+
}
98+
}
99+
}
100+
84101
gapLimitsReceive := flag.Uint("gapLimitReceive", 0, "gap limit for receive addresses. Do not use this unless you know what this means.")
85102
gapLimitsChange := flag.Uint("gapLimitChange", 0, "gap limit for change addresses. Do not use this unless you know what this means.")
86103

0 commit comments

Comments
 (0)