wails/v3/pkg
Lea Anthony d863e525e3
Fix Windows crash bug (#4460)
* ## Summary

I've successfully fixed the nil pointer dereference bug in the Wails v3 system tray functionality on Windows. Here's what I addressed:

**Root Cause**: The bug occurred in `systemtray_windows.go:80` where `*trayBounds = PhysicalToDipRect(*trayBounds)` was dereferencing a potentially nil pointer without checking.

**Fixes Applied**:

1. **`positionWindow` method (lines 80-82)**: Added nil check for `trayBounds` before dereferencing
2. **`bounds` method (lines 121-123, 129-131)**: Added checks for uninitialized `hwnd` and nil return from `GetSystrayBounds`
3. **`iconIsInTrayBounds` method (lines 147-149, 155-157, 160-162)**: Added similar protective checks and taskbar position validation
4. **`getScreen` method (lines 173-175)**: Added `hwnd` initialization check
5. **`openMenu` method (lines 45-47)**: Added nil check for `trayBounds`

**Key Improvements**:
- Added proper initialization checks for `s.hwnd == 0`
- Added nil pointer checks for all Windows API return values
- Ensured graceful error handling instead of panics
- Maintained existing functionality while preventing race conditions

The fix addresses the race condition where system tray operations could be called before the tray was fully initialized, preventing the nil pointer dereference panic described in issue #4456.

* Update changelog
2025-08-04 20:45:01 +10:00
..
application Fix Windows crash bug (#4460) 2025-08-04 20:45:01 +10:00
events [V3] Drag-n-Drop Zones and improvements (#4318) 2025-08-04 20:40:19 +10:00
icons [v3 windows] Small icon updates 2023-06-10 10:19:33 +10:00
mac [v3] Add start_at_login plugin 2023-04-05 21:22:02 +10:00
services [v3] bugfix/windows linux notifications (#4450) 2025-07-30 12:40:58 +00:00
w32 [V3] Drag-n-Drop Zones and improvements (#4318) 2025-08-04 20:40:19 +10:00