Skip to content

Commit

Permalink
v2 [wailsapp#3133] SingleInstanceData: Fill missing WD as is (wailsap…
Browse files Browse the repository at this point in the history
…p#3154)

* [wailsapp#3133] SingleInstanceData: Fill missing WD as is

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix: missing `import` for AI suggestions

* Add changelog entry

---------

Co-authored-by: Lea Anthony <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 3, 2024
1 parent f1265c5 commit f7c1946
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions v2/internal/frontend/desktop/linux/single_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"github.com/godbus/dbus/v5"
"github.com/wailsapp/wails/v2/pkg/options"
"log"
"os"
"strings"
)
Expand Down Expand Up @@ -55,8 +56,15 @@ func SetupSingleInstance(uniqueID string) {
data := options.SecondInstanceData{
Args: os.Args[1:],
}
data.WorkingDirectory, err = os.Getwd()
if err != nil {
log.Printf("Failed to get working directory: %v", err)
return
}

serialized, err := json.Marshal(data)
if err != nil {
log.Printf("Failed to marshal data: %v", err)
return
}

Expand Down
12 changes: 11 additions & 1 deletion v2/internal/frontend/desktop/windows/single_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc/w32"
"github.com/wailsapp/wails/v2/pkg/options"
"golang.org/x/sys/windows"
"log"
"os"
"syscall"
"unsafe"
Expand Down Expand Up @@ -51,7 +52,16 @@ func SetupSingleInstance(uniqueId string) {
data := options.SecondInstanceData{
Args: os.Args[1:],
}
serialized, _ := json.Marshal(data)
data.WorkingDirectory, err = os.Getwd()
if err != nil {
log.Printf("Failed to get working directory: %v", err)
return
}
serialized, err := json.Marshal(data)
if err != nil {
log.Printf("Failed to marshal data: %v", err)
return
}

SendMessage(hwnd, string(serialized))
// exit second instance of app after sending message
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Docs for IsZoomControlEnabled and ZoomFactor. Fixed by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/3137)
- Fixed `-compiler` flag for `wails build`, `wails dev` and `wails generate module`. Fixed in [PR](https://github.com/wailsapp/wails/pull/3121) by [@xtrafrancyz](https://github.com/xtrafrancyz)
- Fixed uninitialized `SecondInstanceData.WorkingDirectory` on linux and windows ([#3154](https://github.com/wailsapp/wails/pull/3154)).

## v2.7.1 - 2023-12-10

Expand Down

0 comments on commit f7c1946

Please sign in to comment.