Menu designer: Do not crash when MainMenu contains a separator. Issue #41130.

This commit is contained in:
Juha 2024-09-10 12:52:49 +03:00
parent c8c6533768
commit d869f6a082
2 changed files with 10 additions and 21 deletions

View File

@ -297,8 +297,7 @@ var
procedure ShowMenuEditor(aMenu: TMenu);
begin
if (aMenu = nil) then
RaiseGDBException(lisMenuEditorShowMenuEditorTMenuParameterIsNil);
Assert(Assigned(aMenu), 'ShowMenuEditor: aMenu parameter is nil');
MenuDesigner.FGui.SetMenu(aMenu, nil);
SetPopupModeParentForPropertyEditor(MenuDesigner.FGui);
MenuDesigner.FGui.ShowOnTop;
@ -811,31 +810,24 @@ end;
procedure TShadowMenu.RecursiveCreateShadows(aParentBox: TShadowBox; aMI: TMenuItem);
var
j: integer;
i: integer;
sb: TShadowBox;
begin
TShadowItem.CreateWithBoxAndItem(Self, aParentBox, aMI);
if (aMI.Count > 0) then
begin
sb:=TShadowBox.CreateWithParentBox(Self, aParentBox, aMI);
for j:=0 to aMI.Count-1 do
RecursiveCreateShadows(sb, aMI.Items[j]);
end;
if aMI.Count = 0 then Exit;
sb:=TShadowBox.CreateWithParentBox(Self, aParentBox, aMI);
for i:=0 to aMI.Count-1 do
RecursiveCreateShadows(sb, aMI.Items[i]);
end;
procedure TShadowMenu.CreateShadowBoxesAndItems;
var
i: integer;
begin
if (FMenu.Items.Count > 0) then
begin
FRootBox:=TShadowBox.CreateWithParentBox(Self, nil, FMenu.Items);
for i:=0 to FMenu.Items.Count-1 do begin
if IsMainMenu and FMenu.Items[i].IsLine then
RaiseGDBException(lisMenuEditorSomeWidgetsetsDoNotAllowSeparatorsInTheMainMenubar);
RecursiveCreateShadows(FRootBox, FMenu.Items[i]);
end;
end;
if FMenu.Items.Count = 0 then Exit;
FRootBox:=TShadowBox.CreateWithParentBox(Self, nil, FMenu.Items);
for i:=0 to FMenu.Items.Count-1 do
RecursiveCreateShadows(FRootBox, FMenu.Items[i]);
end;
procedure TShadowMenu.DeleteChildlessShadowAndItem(anExistingSI: TShadowItem);

View File

@ -4870,14 +4870,11 @@ resourcestring
lisMenuEditorShortcutsDAndAcceleratorKeysD = 'Shortcuts (%d) and Accelerator keys (%d)';
lisMenuEditorShortcutsUsedInS = 'Shortcuts used in %s';
lisMenuEditorShortcutsUsedInSD = 'Shortcuts used in %s (%d)';
lisMenuEditorShowMenuEditorTMenuParameterIsNil = 'ShowMenuEditor: TMenu parameter is nil';
lisMenuEditorSInS = '"%s" in %s';
lisMenuEditorSIsAlreadyInUse = '"%s" is '
+'already in use in %s as a shortcut.' + sLineBreak + 'Try a different shortcut.';
lisMenuEditorSIsNotASufficientDescriptionPleaseExpand = 'Please expand: "%s" is not a '
+'sufficient Description';
lisMenuEditorSomeWidgetsetsDoNotAllowSeparatorsInTheMainMenubar = 'Some '
+'widgetsets do not allow separators in the main menubar';
lisMenuEditorSShortcuts = '%s: Shortcuts';
lisMenuEditorSShortcutsAndAcceleratorKeys = '%s: Shortcuts and accelerator keys';
lisMenuEditorSSSOnClickS = '%s.%s.%s - OnClick: %s';