Browse Source

* Add TReader.SetName for Delphi compatibility

Michaël Van Canneyt 1 year ago
parent
commit
7506277dc1
2 changed files with 10 additions and 3 deletions
  1. 1 0
      rtl/objpas/classes/classesh.inc
  2. 9 3
      rtl/objpas/classes/reader.inc

+ 1 - 0
rtl/objpas/classes/classesh.inc

@@ -1845,6 +1845,7 @@ type
     procedure ReadPropValue(Instance: TPersistent; PropInfo: Pointer);
     procedure PropertyError;
     procedure ReadData(Instance: TComponent);
+    procedure SetName(aComponent: TComponent; aName : string); virtual;
     property PropName: rawbytestring read FPropName;
     property CanHandleExceptions: Boolean read FCanHandleExcepts;
     function CreateDriver(Stream: TStream; BufSize: Integer): TAbstractObjectReader; virtual;

+ 9 - 3
rtl/objpas/classes/reader.inc

@@ -923,6 +923,14 @@ begin
   ReadListEnd;
 end;
 
+procedure TReader.SetName(aComponent: TComponent; aName : string);
+
+begin
+  if Assigned(FOnSetName) then 
+    FOnSetName(Self,aComponent,aName);
+  aComponent.Name:=aName;
+end;
+
 function TReader.ReadComponent(Component: TComponent): TComponent;
 var
   Flags: TFilerFlags;
@@ -1022,9 +1030,7 @@ begin
         if not (ffInherited in Flags) then
           try
             Result.SetParentComponent(Parent);
-            if Assigned(FOnSetName) then
-              FOnSetName(Self, Result, Name);
-            Result.Name := Name;
+            SetName(Result,Name);
             if FindGlobalComponent(Name) = Result then
               Include(Result.FComponentState, csInline);
           except