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

View File

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