Skip to content

Commit 7dc14a0

Browse files
committed
Optimize Qt6 menu fix: conditional check and reduce ProcessMessages
- Only run the menu rebuild workaround on Qt5/Qt6 widgetsets - GTK and Win32 users no longer pay any cost for this fix - Reduce ProcessMessages calls from 2 to 1 (sufficient for the fix) - Add Qt5 coverage since it likely has the same issue
1 parent adb1d52 commit 7dc14a0

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

lazpaint/lazpaintmainform.pas

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -905,9 +905,9 @@ TFMain = class(TForm)
905905

906906
implementation
907907

908-
uses LCLIntf, BGRAUTF8, ugraph, math, umac, uclipboard, ucursors,
909-
ufilters, ULoadImage, ULoading, UFileExtensions, UBrushType,
910-
ugeometricbrush, UPreviewDialog, UQuestion, BGRALayerOriginal,
908+
uses LCLIntf, InterfaceBase, LCLPlatformDef, BGRAUTF8, ugraph, math, umac,
909+
uclipboard, ucursors, ufilters, ULoadImage, ULoading, UFileExtensions,
910+
UBrushType, ugeometricbrush, UPreviewDialog, UQuestion, BGRALayerOriginal,
911911
BGRATransform, LCVectorPolyShapes, URaw, UFileSystem,
912912
UTranslation, UPython, BCTypes;
913913

@@ -1218,11 +1218,14 @@ procedure TFMain.FormShow(Sender: TObject);
12181218
m.Apply;
12191219
FLayout.Menu := m;
12201220

1221-
// Force Qt6 to rebuild main menu by detaching and reattaching
1222-
Self.Menu := nil;
1223-
Application.ProcessMessages;
1224-
Self.Menu := MainMenu1;
1225-
Application.ProcessMessages;
1221+
// Force Qt5/Qt6 to rebuild main menu by detaching and reattaching
1222+
// This works around menu items randomly not displaying on Qt widgetsets
1223+
if WidgetSet.LCLPlatform in [lpQt5, lpQt6] then
1224+
begin
1225+
Self.Menu := nil;
1226+
Self.Menu := MainMenu1;
1227+
Application.ProcessMessages;
1228+
end;
12261229

12271230
SVGImageList1.Width := iconSize;
12281231
SVGImageList1.Height := iconSize;

0 commit comments

Comments
 (0)