diff --git a/v3/UNRELEASED_CHANGELOG.md b/v3/UNRELEASED_CHANGELOG.md index e53610b87..88f19d96c 100644 --- a/v3/UNRELEASED_CHANGELOG.md +++ b/v3/UNRELEASED_CHANGELOG.md @@ -27,6 +27,10 @@ After processing, the content will be moved to the main changelog and this file ## Fixed +- Fix Windows nil pointer dereference bug reported in [#4456](https://github.com/wailsapp/wails/issues/4456) by @leaanthony in [#4460](https://github.com/wailsapp/wails/pull/4460) +- Add support for `allowsBackForwardNavigationGestures` in macOS WKWebView to enable two-finger swipe navigation gestures (#1857) +- Fixes issue where onClick didn't work for menu items initially set as disabled by @leaanthony in [PR #4469](https://github.com/wailsapp/wails/pull/4469). Thanks to @IanVS for the initial investigation. +- Fix Vite server not being cleaned up when build fails (#4403) - Fixed panic when closing or cancelling a `SaveFileDialog` on windows. Fixed in [PR](https://github.com/wailsapp/wails/pull/4284) by @hkhere - Fixed HTML level drag and drop on Windows by [@mbaklor](https://github.com/mbaklor) in [#4259](https://github.com/wailsapp/wails/pull/4259) diff --git a/v3/pkg/application/systemtray_windows.go b/v3/pkg/application/systemtray_windows.go index ca30cafce..abf01d140 100644 --- a/v3/pkg/application/systemtray_windows.go +++ b/v3/pkg/application/systemtray_windows.go @@ -42,6 +42,9 @@ func (s *windowsSystemTray) openMenu() { if err != nil { return } + if trayBounds == nil { + return + } // Show the menu at the tray bounds s.menu.ShowAt(trayBounds.X, trayBounds.Y) @@ -77,6 +80,9 @@ func (s *windowsSystemTray) positionWindow(window *WebviewWindow, offset int) er if err != nil { return err } + if trayBounds == nil { + return errors.New("failed to get system tray bounds") + } *trayBounds = PhysicalToDipRect(*trayBounds) centerAlignX = trayBounds.X + (trayBounds.Width / 2) - (windowBounds.Width / 2) centerAlignY = trayBounds.Y + (trayBounds.Height / 2) - (windowBounds.Height / 2) @@ -115,10 +121,17 @@ func (s *windowsSystemTray) positionWindow(window *WebviewWindow, offset int) er } func (s *windowsSystemTray) bounds() (*Rect, error) { + if s.hwnd == 0 { + return nil, errors.New("system tray window handle not initialized") + } + bounds, err := w32.GetSystrayBounds(s.hwnd, s.uid) if err != nil { return nil, err } + if bounds == nil { + return nil, errors.New("GetSystrayBounds returned nil") + } monitor := w32.MonitorFromWindow(s.hwnd, w32.MONITOR_DEFAULTTONEAREST) if monitor == 0 { @@ -134,12 +147,22 @@ func (s *windowsSystemTray) bounds() (*Rect, error) { } func (s *windowsSystemTray) iconIsInTrayBounds() (bool, error) { + if s.hwnd == 0 { + return false, errors.New("system tray window handle not initialized") + } + bounds, err := w32.GetSystrayBounds(s.hwnd, s.uid) if err != nil { return false, err } + if bounds == nil { + return false, errors.New("GetSystrayBounds returned nil") + } taskbarRect := w32.GetTaskbarPosition() + if taskbarRect == nil { + return false, errors.New("failed to get taskbar position") + } inTasksBar := w32.RectInRect(bounds, &taskbarRect.Rc) if inTasksBar { @@ -150,6 +173,9 @@ func (s *windowsSystemTray) iconIsInTrayBounds() (bool, error) { } func (s *windowsSystemTray) getScreen() (*Screen, error) { + if s.hwnd == 0 { + return nil, errors.New("system tray window handle not initialized") + } // Get the screen for this systray return getScreenForWindowHwnd(s.hwnd) }