IDE: Take care of component palette page names that differ only by character case. Issue #27516.

git-svn-id: trunk@47979 -
This commit is contained in:
juha 2015-02-24 11:35:56 +00:00
parent 6a30dafffd
commit 125625ee6a
2 changed files with 25 additions and 5 deletions

View File

@ -182,6 +182,8 @@ type
FUpdateLock: integer;
fChanged: boolean;
fChangeStamp: integer;
// Used to find names that differ in character case only.
fOrigPageHelper: TStringList;
procedure AddHandler(HandlerType: TComponentPaletteHandlerType;
const AMethod: TMethod; AsLast: boolean = false);
procedure RemoveHandler(HandlerType: TComponentPaletteHandlerType;
@ -588,6 +590,8 @@ begin
fPages:=TBaseComponentPageList.Create;
fComps:=TRegisteredComponentList.Create;
fOrigPagePriorities:=TPagePriorityList.Create;
fOrigPageHelper:=TStringList.Create; // Note: CaseSensitive = False
fOrigPageHelper.Sorted:=True;
end;
destructor TBaseComponentPalette.Destroy;
@ -595,6 +599,7 @@ var
HandlerType: TComponentPaletteHandlerType;
begin
Clear;
FreeAndNil(fOrigPageHelper);
FreeAndNil(fOrigPagePriorities);
FreeAndNil(fComps);
FreeAndNil(fPages);
@ -614,6 +619,7 @@ begin
fComps[i].RealPage:=nil;
fComps.Clear;
fOrigPagePriorities.Clear;
fOrigPageHelper.Clear;
end;
procedure TBaseComponentPalette.AddHandler(HandlerType: TComponentPaletteHandlerType;
@ -780,15 +786,24 @@ begin
fComps.Insert(InsertIndex,NewComponent);
OnPageAddedComponent(NewComponent);
// Store a list of page names and their priorities.
if (NewComponent.OrigPageName <> '')
and (fOrigPagePriorities.IndexOf(NewComponent.OrigPageName) = -1) then
begin
if NewComponent.FOrigPageName = '' then Exit;
// See if page was added with different char case. Use the first version always.
if fOrigPageHelper.Find(NewComponent.FOrigPageName, InsertIndex) then begin
NewComponent.FOrigPageName := fOrigPageHelper[InsertIndex]; // Possibly different case
Assert(fOrigPagePriorities.IndexOf(NewComponent.FOrigPageName) >= 0,
'TBaseComponentPalette.AddComponent: FOrigPageName not found!');
end
else begin
fOrigPageHelper.Add(NewComponent.FOrigPageName);
Assert(fOrigPagePriorities.IndexOf(NewComponent.FOrigPageName) = -1,
'TBaseComponentPalette.AddComponent: FOrigPageName exists but it should not!');
// Store a list of page names and their priorities.
InsertIndex:=0;
while (InsertIndex<fOrigPagePriorities.Count)
and (ComparePriority(NewPriority, fOrigPagePriorities.Data[InsertIndex])<=0) do
inc(InsertIndex);
fOrigPagePriorities.InsertKeyData(InsertIndex, NewComponent.OrigPageName, NewPriority);
fOrigPagePriorities.InsertKeyData(InsertIndex, NewComponent.FOrigPageName, NewPriority);
end;
end;

View File

@ -280,6 +280,7 @@ begin
begin
PgName := FComponentPages[PageI];
DstComps := TStringList.Create;
DstComps.CaseSensitive := True;
FComponentPages.Objects[PageI] := DstComps;
i := fOptions.ComponentPages.IndexOf(PgName);
if i >= 0 then // Add components reordered by user.
@ -934,6 +935,7 @@ begin
Format('CacheComponentPages: %s already cached.', [PgName]));
// Add a cache StringList for this page name.
sl := TStringList.Create;
sl.CaseSensitive := True;
fOrigComponentPageCache.AddObject(PgName, sl);
// Find all components for this page and add them to cache.
for CompI := 0 to fComps.Count-1 do begin
@ -1020,9 +1022,11 @@ begin
fComponentCache:=TAVLTree.Create(@CompareRegisteredComponents);
fOrigComponentPageCache:=TStringList.Create;
fOrigComponentPageCache.OwnsObjects:=True;
fOrigComponentPageCache.CaseSensitive:=True;
fOrigComponentPageCache.Sorted:=True;
fUserComponentPageCache:=TStringList.Create;
fUserComponentPageCache.OwnsObjects:=True;
fUserComponentPageCache.CaseSensitive:=True;
fUserComponentPageCache.Sorted:=True;
OnComponentIsInvisible:=@CheckComponentDesignerVisible;
end;
@ -1101,6 +1105,7 @@ begin
[PgName, Pg.PageName]));
// New cache page
UserComps := TStringList.Create;
UserComps.CaseSensitive := True;
fUserComponentPageCache.AddObject(PgName, UserComps);
// Associate components belonging to this page
aVisibleCompCnt := 0;