IDE: Prevent a crash when adding a component palette tab with an existing name.

git-svn-id: trunk@46840 -
This commit is contained in:
juha 2014-11-14 01:40:07 +00:00
parent c57b1c69bc
commit 084dd37ed0

View File

@ -722,11 +722,13 @@ var
PageInd: Integer; PageInd: Integer;
PanelRight: TPanel; PanelRight: TPanel;
BtnRight: TSpeedButton; BtnRight: TSpeedButton;
TabControl: TCustomTabControl;
begin begin
if not aCompPage.Visible then Exit; if not aCompPage.Visible then Exit;
TabControl := TCustomTabControl(FPageControl);
if aCompPage.PageComponent=nil then begin if aCompPage.PageComponent=nil then begin
// insert a new PageControl page // insert a new PageControl page
TCustomTabControl(FPageControl).Pages.Insert(aVisPageIndex, aCompPage.PageName); TabControl.Pages.Insert(aVisPageIndex, aCompPage.PageName);
aCompPage.PageComponent := FPageControl.Page[aVisPageIndex]; aCompPage.PageComponent := FPageControl.Page[aVisPageIndex];
with TScrollBox.Create(aCompPage.PageComponent) do begin with TScrollBox.Create(aCompPage.PageComponent) do begin
Align := alClient; Align := alClient;
@ -763,13 +765,13 @@ var
OnMouseWheel := @OnPageMouseWheel; OnMouseWheel := @OnPageMouseWheel;
Parent := PanelRight; Parent := PanelRight;
end; end;
inc(aVisPageIndex);
end else begin end else begin
// move to the right position // move to the right position
PageInd := aCompPage.PageComponent.PageIndex; PageInd := aCompPage.PageComponent.PageIndex;
if PageInd<>aVisPageIndex then if (PageInd<>aVisPageIndex) and (aVisPageIndex < TabControl.Pages.Count) then
TCustomTabControl(FPageControl).Pages.Move(PageInd, aVisPageIndex); TabControl.Pages.Move(PageInd, aVisPageIndex);
end; end;
inc(aVisPageIndex);
end; end;
procedure CreateSelectionButton(aCompPage: TBaseComponentPage; aButtonUniqueName: string; procedure CreateSelectionButton(aCompPage: TBaseComponentPage; aButtonUniqueName: string;