IDE: Show Frame's contents in designer also when its component package is installed in palette. Issue #39488.

(cherry picked from commit 05382f4ddf)
This commit is contained in:
Juha 2021-11-26 21:17:20 +02:00 committed by Maxim Ganetsky
parent 8b4a580354
commit 69e9028c85
5 changed files with 28 additions and 28 deletions

View File

@ -748,8 +748,8 @@ begin
FCollapsedComps := TAVLTree.Create; FCollapsedComps := TAVLTree.Create;
FRoot2CollapasedMap[RootObject] := FCollapsedComps; FRoot2CollapasedMap[RootObject] := FCollapsedComps;
end; end;
RestoreExpand(RootNode); // then restore the Expanded/Collapsed state.
end; end;
RestoreExpand(RootNode); // then restore the Expanded/Collapsed state.
MakeSelectionVisible; MakeSelectionVisible;
end; end;
EndUpdate; EndUpdate;

View File

@ -9,7 +9,7 @@ object CheckLFMDialog: TCheckLFMDialog
ClientWidth = 552 ClientWidth = 552
OnClose = FormClose OnClose = FormClose
OnCreate = CheckLFMDialogCreate OnCreate = CheckLFMDialogCreate
LCLVersion = '1.1' LCLVersion = '2.3.0.0'
object NoteLabel: TLabel object NoteLabel: TLabel
Left = 0 Left = 0
Height = 15 Height = 15
@ -17,7 +17,6 @@ object CheckLFMDialog: TCheckLFMDialog
Width = 552 Width = 552
Align = alTop Align = alTop
Caption = 'NoteLabel' Caption = 'NoteLabel'
ParentColor = False
WordWrap = True WordWrap = True
end end
object LFMGroupBox: TGroupBox object LFMGroupBox: TGroupBox
@ -585,7 +584,6 @@ object CheckLFMDialog: TCheckLFMDialog
Caption = 'Cancel' Caption = 'Cancel'
Kind = bkCancel Kind = bkCancel
ModalResult = 2 ModalResult = 2
NumGlyphs = 0
TabOrder = 0 TabOrder = 0
end end
object RemoveAllButton: TBitBtn object RemoveAllButton: TBitBtn
@ -597,7 +595,6 @@ object CheckLFMDialog: TCheckLFMDialog
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Remove all invalid properties' Caption = 'Remove all invalid properties'
NumGlyphs = 0
OnClick = RemoveAllButtonClick OnClick = RemoveAllButtonClick
TabOrder = 1 TabOrder = 1
end end
@ -605,12 +602,6 @@ object CheckLFMDialog: TCheckLFMDialog
object SynLFMSyn1: TSynLFMSyn object SynLFMSyn1: TSynLFMSyn
DefaultFilter = 'Lazarus Form Files (*.lfm)|*.lfm' DefaultFilter = 'Lazarus Form Files (*.lfm)|*.lfm'
Enabled = False Enabled = False
CommentAttri.FrameEdges = sfeAround
IdentifierAttri.FrameEdges = sfeAround
KeyAttri.FrameEdges = sfeAround
NumberAttri.FrameEdges = sfeAround
SpaceAttri.FrameEdges = sfeAround
StringAttri.FrameEdges = sfeAround
left = 129 left = 129
top = 104 top = 104
end end

View File

@ -178,6 +178,8 @@ var
end; end;
procedure FindMissingClass(ObjNode: TLFMObjectNode); procedure FindMissingClass(ObjNode: TLFMObjectNode);
// Add a missing or nested class to MissingClasses.
// A nested class means a TFrame installed as a component.
var var
i: Integer; i: Integer;
AClassName: String; AClassName: String;
@ -194,14 +196,16 @@ var
// search in designer base classes // search in designer base classes
if BaseFormEditor1.FindDesignerBaseClassByName(AClassName,true)<>nil then if BaseFormEditor1.FindDesignerBaseClassByName(AClassName,true)<>nil then
exit; exit;
// search in registered classes
RegComp:=IDEComponentPalette.FindRegComponent(ObjNode.TypeName);
if (RegComp<>nil) and (RegComp.GetUnitName<>'') then exit;
// search in global registered classes // search in global registered classes
if GetClass(ObjNode.TypeName)<>nil then if GetClass(ObjNode.TypeName)<>nil then
Exit; exit;
// search in registered classes
RegComp:=IDEComponentPalette.FindRegComponent(ObjNode.TypeName);
if (RegComp<>nil) and (RegComp.GetUnitName<>'')
and not RegComp.ComponentClass.InheritsFrom(TCustomFrame) then // Nested TFrame
exit;
// class is missing // class is missing
DebugLn(['FindMissingClass ',ObjNode.Name,':',ObjNode.TypeName,' IsInherited=',ObjNode.IsInherited]); DebugLn(['QuickCheckLFMBuffer->FindMissingClass ',ObjNode.Name,':',ObjNode.TypeName,' IsInherited=',ObjNode.IsInherited]);
if MissingClasses=nil then if MissingClasses=nil then
MissingClasses:=TStringList.Create; MissingClasses:=TStringList.Create;
MissingClasses.Add(AClassName); MissingClasses.Add(AClassName);

View File

@ -2220,12 +2220,13 @@ begin
or (IndexOfDesignerBaseClass(TComponentClass(AClass))>=0) then begin or (IndexOfDesignerBaseClass(TComponentClass(AClass))>=0) then begin
exit; exit;
end; end;
//DebugLn(['TCustomFormEditor.JITListFindAncestors Class=',DbgSName(AClass)]); DebugLn(['TCustomFormEditor.JITListFindAncestors Class=',DbgSName(AClass)]);
AnUnitInfo:=Project1.UnitWithComponentClass(TComponentClass(AClass)); AnUnitInfo:=Project1.UnitWithComponentClassName(AClass.ClassName);
//AnUnitInfo:=Project1.UnitWithComponentClass(TComponentClass(AClass));
while AnUnitInfo<>nil do begin while AnUnitInfo<>nil do begin
{$IFDEF VerboseFormEditor} {.$IFDEF VerboseFormEditor}
DebugLn(['TCustomFormEditor.JITListFindAncestors FOUND ancestor ',DbgSName(AnUnitInfo.Component),', streaming ...']); DebugLn(['TCustomFormEditor.JITListFindAncestors FOUND ancestor ',DbgSName(AnUnitInfo.Component),', streaming ...']);
{$ENDIF} {.$ENDIF}
Ancestor:=AnUnitInfo.Component; Ancestor:=AnUnitInfo.Component;
BinStream:=nil; BinStream:=nil;
if SaveUnitComponentToBinStream(AnUnitInfo,BinStream)<>mrOk then begin if SaveUnitComponentToBinStream(AnUnitInfo,BinStream)<>mrOk then begin
@ -2254,7 +2255,9 @@ var
begin begin
//DebugLn(['TCustomFormEditor.JITListFindClass ',ComponentClassName]); //DebugLn(['TCustomFormEditor.JITListFindClass ',ComponentClassName]);
RegComp:=IDEComponentPalette.FindRegComponent(ComponentClassName); RegComp:=IDEComponentPalette.FindRegComponent(ComponentClassName);
if RegComp<>nil then begin if (RegComp<>nil) and
not RegComp.ComponentClass.InheritsFrom(TCustomFrame) then // Nested TFrame
begin
//DebugLn(['TCustomFormEditor.JITListFindClass ',ComponentClassName,' is registered as ',DbgSName(RegComp.ComponentClass)]); //DebugLn(['TCustomFormEditor.JITListFindClass ',ComponentClassName,' is registered as ',DbgSName(RegComp.ComponentClass)]);
ComponentClass:=RegComp.ComponentClass; ComponentClass:=RegComp.ComponentClass;
end else begin end else begin
@ -2264,7 +2267,7 @@ begin
AnUnitInfo:=TUnitInfo(JITList.ContextObject); AnUnitInfo:=TUnitInfo(JITList.ContextObject);
if AnUnitInfo.ComponentFallbackClasses<>nil then if AnUnitInfo.ComponentFallbackClasses<>nil then
for i:=0 to AnUnitInfo.ComponentFallbackClasses.Count-1 do begin for i:=0 to AnUnitInfo.ComponentFallbackClasses.Count-1 do begin
if SysUtils.CompareText(AnUnitInfo.ComponentFallbackClasses[i],ComponentClassName)=0 if CompareText(AnUnitInfo.ComponentFallbackClasses[i],ComponentClassName)=0
then begin then begin
{$IFDEF EnableNestedComponentsWithoutLFM} {$IFDEF EnableNestedComponentsWithoutLFM}
ComponentClass:=TComponentClass(Pointer(AnUnitInfo.ComponentFallbackClasses.Objects[i])); ComponentClass:=TComponentClass(Pointer(AnUnitInfo.ComponentFallbackClasses.Objects[i]));
@ -2281,7 +2284,7 @@ begin
AnUnitInfo:=Project1.FirstUnitWithComponent; AnUnitInfo:=Project1.FirstUnitWithComponent;
while AnUnitInfo<>nil do begin while AnUnitInfo<>nil do begin
Component:=AnUnitInfo.Component; Component:=AnUnitInfo.Component;
if SysUtils.CompareText(Component.ClassName,ComponentClassName)=0 then if CompareText(Component.ClassName,ComponentClassName)=0 then
begin begin
DebugLn(['TCustomFormEditor.JITListFindClass found nested class '+DbgSName(Component)+' in unit '+AnUnitInfo.Filename]); DebugLn(['TCustomFormEditor.JITListFindClass found nested class '+DbgSName(Component)+' in unit '+AnUnitInfo.Filename]);
ComponentClass:=TComponentClass(Component.ClassType); ComponentClass:=TComponentClass(Component.ClassType);
@ -2293,8 +2296,7 @@ begin
//DebugLn(['TCustomFormEditor.JITListFindClass Searched=',ComponentClassName,' Found=',DbgSName(ComponentClass)]); //DebugLn(['TCustomFormEditor.JITListFindClass Searched=',ComponentClassName,' Found=',DbgSName(ComponentClass)]);
end; end;
function TCustomFormEditor.GetDesignerBaseClasses(Index: integer function TCustomFormEditor.GetDesignerBaseClasses(Index: integer): TComponentClass;
): TComponentClass;
begin begin
Result:=TComponentClass(FDesignerBaseClasses[Index]); Result:=TComponentClass(FDesignerBaseClasses[Index]);
end; end;

View File

@ -6602,7 +6602,8 @@ var
if FoundComponentClass=nil then if FoundComponentClass=nil then
begin begin
RegComp:=IDEComponentPalette.FindRegComponent(aClassName); RegComp:=IDEComponentPalette.FindRegComponent(aClassName);
if RegComp<>nil then if (RegComp<>nil) and
not RegComp.ComponentClass.InheritsFrom(TCustomFrame) then // Nested TFrame
FoundComponentClass:=RegComp.ComponentClass; FoundComponentClass:=RegComp.ComponentClass;
end; end;
if FoundComponentClass=nil then if FoundComponentClass=nil then
@ -6820,7 +6821,8 @@ var
// search ancestor in registered classes // search ancestor in registered classes
if TryRegisteredClasses(AncestorClassName,AncestorClass,TheModalResult) then if TryRegisteredClasses(AncestorClassName,AncestorClass,TheModalResult) then
exit(true); raise Exception.Create('TryFindDeclaration: TryRegisteredClasses returned True!');
//exit(true);
{$IFDEF VerboseLFMSearch} {$IFDEF VerboseLFMSearch}
debugln(['TryFindDeclaration declaration of ',AComponentClassName,' found at ',NewTool.CleanPosToStr(NewNode.StartPos),' Ancestor="',AncestorClassName,'", but no lfm and no registered class found']); debugln(['TryFindDeclaration declaration of ',AComponentClassName,' found at ',NewTool.CleanPosToStr(NewNode.StartPos),' Ancestor="',AncestorClassName,'", but no lfm and no registered class found']);
@ -6868,7 +6870,8 @@ var
end; end;
StoreComponentClassDeclaration(UnitFilename); StoreComponentClassDeclaration(UnitFilename);
if TryRegisteredClasses(AncestorClassName,AncestorClass,TheModalResult) then if TryRegisteredClasses(AncestorClassName,AncestorClass,TheModalResult) then
exit(true); raise Exception.Create('TryUsedUnitInterface: TryRegisteredClasses returned True!');
//exit(true);
end; end;
var var