Designer: Give names for the side components of PairSplitter. Don't crash when deleting. Issue #38227.

git-svn-id: trunk@64225 -
This commit is contained in:
juha 2020-12-18 10:51:37 +00:00
parent 4c9264496d
commit 5cf724ae46
3 changed files with 15 additions and 5 deletions

View File

@ -747,7 +747,6 @@ begin
FPersToChange := APersistent; FPersToChange := APersistent;
FZOrderDelete := AZOrder; FZOrderDelete := AZOrder;
BuildComponentNodes(False); BuildComponentNodes(False);
Assert(FPersToChange=nil, 'TComponentTreeView.ChangeCompZOrder: FPersToChange is assigned.');
end; end;
procedure TComponentTreeView.DeleteComponentNode(APersistent: TPersistent); procedure TComponentTreeView.DeleteComponentNode(APersistent: TPersistent);
@ -755,7 +754,6 @@ begin
FPersToChange := APersistent; FPersToChange := APersistent;
FZOrderDelete := zoDelete; FZOrderDelete := zoDelete;
BuildComponentNodes(False); BuildComponentNodes(False);
Assert(FPersToChange=nil, 'TComponentTreeView.DeleteComponentNode: FPersToChange is assigned.');
end; end;
procedure TComponentTreeView.UpdateCompNode(ANode: TTreeNode); procedure TComponentTreeView.UpdateCompNode(ANode: TTreeNode);

View File

@ -37,8 +37,9 @@ interface
{off $DEFINE VerboseDesignerSelect} {off $DEFINE VerboseDesignerSelect}
uses uses
// RTL + FCL + LCL // RTL + FCL
Types, Classes, Math, SysUtils, variants, TypInfo, Types, Classes, Math, SysUtils, Variants, TypInfo,
// LCL
LCLProc, LCLType, LResources, LCLIntf, LMessages, InterfaceBase, LCLProc, LCLType, LResources, LCLIntf, LMessages, InterfaceBase,
Forms, Controls, GraphType, Graphics, Dialogs, ExtCtrls, Menus, ClipBrd, Forms, Controls, GraphType, Graphics, Dialogs, ExtCtrls, Menus, ClipBrd,
// LazUtils // LazUtils
@ -1631,10 +1632,21 @@ begin
end; end;
procedure TDesigner.NotifyComponentAdded(AComponent: TComponent); procedure TDesigner.NotifyComponentAdded(AComponent: TComponent);
var
i: Integer;
SubContrl: TControl;
begin begin
try try
if AComponent.Name='' then if AComponent.Name='' then
AComponent.Name:=UniqueName(AComponent.ClassName); AComponent.Name:=UniqueName(AComponent.ClassName);
// Iterating Controls is needed at least for Side1 and Side2 of TPairSplitter.
if AComponent is TWinControl then
for i:=0 to TWinControl(AComponent).ControlCount-1 do
begin
SubContrl:=TWinControl(AComponent).Controls[i];
if SubContrl.Name='' then
SubContrl.Name:=UniqueName(SubContrl.ClassName);
end;
GlobalDesignHook.PersistentAdded(AComponent,false); GlobalDesignHook.PersistentAdded(AComponent,false);
except except
on E: Exception do on E: Exception do

View File

@ -1363,7 +1363,7 @@ begin
AParent:=AParent.Parent; AParent:=AParent.Parent;
end; end;
end; end;
DebugLn('Parent is '''+dbgsName(AParent)+''''); //DebugLn('TCustomFormEditor.CreateComponent: Parent is '''+dbgsName(AParent)+'''');
end else begin end else begin
// create a toplevel component // create a toplevel component
// -> a form or a datamodule or a custom component // -> a form or a datamodule or a custom component