-
-
Notifications
You must be signed in to change notification settings - Fork 62
Description
Description
When building LazPaint with the Qt6 widgetset (--ws=qt6), menus randomly fail to appear in the main menu bar. The "Image" menu is particularly affected, but other menus can also be missing on any given launch.
Steps to Reproduce
- Build LazPaint with Qt6 widgetset:
lazbuild --ws=qt6 lazpaint.lpi - Launch the application multiple times
- Observe that menus are intermittently missing from the menu bar
Expected Behavior
All menus should appear consistently on every launch.
Actual Behavior
Menus randomly fail to display with roughly 30-70% failure rate across multiple launches. Testing showed only 2/6 launches had the Image menu visible before investigating.
Environment
- OS: Arch Linux
- Qt6Pas: 6.2.9
- FPC: 3.2.2
- Lazarus: 3.8
Investigation & Root Causes
After debugging, three issues were identified:
1. TActionList.ActionByName Race Condition
ActionByName appears to have timing issues during Qt6 initialization, sometimes returning nil for actions that exist. This causes menu items to silently fail to populate.
2. Missing Visibility Flags
Qt6 sometimes fails to render TMenuItem items even when they're correctly populated. Setting Visible := true explicitly resolves this.
3. Menu Bar Widget Handle Not Refreshed
Qt6's menu bar widget handle needs to be forcibly refreshed after menu population. Without this, the internal Qt widget state doesn't reflect the populated menu structure.
Proposed Fix
A fix has been submitted in PR #623 which:
- Replaces
ActionByNamecalls with a direct iteration helper (FindActionByNameDirect) that doesn't rely on hash-based lookup - Adds explicit
Visible := truefor all active menus - Forces menu bar refresh via detach/reattach with
ProcessMessagescalls
After the fix, testing achieved 6/6 successful launches (100% success rate).