Designer: Name Menu separators as "SeparatorX" to make name clashes less likely. Issue #39471.

This commit is contained in:
Juha 2021-11-17 17:24:17 +02:00
parent dda96a3864
commit 641c3a73f0
2 changed files with 11 additions and 6 deletions

View File

@ -5994,7 +5994,7 @@ begin
begin begin
Designer:=FindRootDesigner(MI); Designer:=FindRootDesigner(MI);
if Designer<>nil then if Designer<>nil then
MI.Name:=Designer.UniqueName('N'); MI.Name:=Designer.UniqueName('Separator');
end; end;
end; end;
SetStrValue(NewValue); SetStrValue(NewValue);

View File

@ -724,7 +724,7 @@ begin
begin begin
FEditedMenuItem.Caption:=s; FEditedMenuItem.Caption:=s;
if (s = cLineCaption) and AnsiStartsStr('MenuItem', FEditedMenuItem.Name) then if (s = cLineCaption) and AnsiStartsStr('MenuItem', FEditedMenuItem.Name) then
FEditedMenuItem.Name:=FEditorDesigner.CreateUniqueComponentName('N'); FEditedMenuItem.Name:=FEditorDesigner.CreateUniqueComponentName('Separator');
GlobalDesignHook.RefreshPropertyValues; GlobalDesignHook.RefreshPropertyValues;
GlobalDesignHook.Modified(FEditedMenuItem); GlobalDesignHook.Modified(FEditedMenuItem);
EditedShadow.Invalidate; EditedShadow.Invalidate;
@ -1971,17 +1971,22 @@ procedure TShadowBox.AddItemAndShadow(existingSI: TShadowItem;
var var
idx: integer; idx: integer;
newMI: TMenuItem; newMI: TMenuItem;
nm: string;
begin begin
FShadowMenu.HideFakes; FShadowMenu.HideFakes;
idx:=existingSI.RealItem.MenuIndex; idx:=existingSI.RealItem.MenuIndex;
if not addBefore then if not addBefore then
Inc(idx); Inc(idx);
newMI:=TMenuItem.Create(FShadowMenu.LookupRoot); newMI:=TMenuItem.Create(FShadowMenu.LookupRoot);
newMI.Name:=FShadowMenu.FEditorDesigner.CreateUniqueComponentName(newMI.ClassName); if isSeparator then begin
if isSeparator then nm:='Separator';
newMI.Caption:=cLineCaption newMI.Caption:=cLineCaption;
else end
else begin
nm:=newMI.ClassName;
newMI.Caption:=newMI.Name; newMI.Caption:=newMI.Name;
end;
newMI.Name:=FShadowMenu.FEditorDesigner.CreateUniqueComponentName(nm);
existingSI.RealItem.Parent.Insert(idx, newMI); existingSI.RealItem.Parent.Insert(idx, newMI);
TShadowItem.CreateWithBoxAndItem(FShadowMenu, existingSI.ParentBox, newMI); TShadowItem.CreateWithBoxAndItem(FShadowMenu, existingSI.ParentBox, newMI);
FShadowMenu.UpdateBoxLocationsAndSizes; FShadowMenu.UpdateBoxLocationsAndSizes;