Re[3]: [fpc-devel] LocalReferenceFixup

2010-10-05 Thread Michael Van Canneyt



On Tue, 5 Oct 2010, José Mejuto wrote:


Hello FPC,

Tuesday, October 5, 2010, 1:10:43 PM, you wrote:


I do not have too much experience with components, but calling
"Loaded" several times does not look very fine.

MVC> To the best of my knowledge: it should be called once only, after the 
fixups.
MVC> If it isn't so, this is a bug.

Extracted from "reader.inc", comments below...

--
[...]
--

As you can see the "Loaded" event is called (marked with some //-)
before calling "GlobalFixupReferences", I'll try to add some writeln's
here and there to catch the event sequence and post it here for
further comments.


That would be good, thank you.

If we can pinpoint the issue, the solution will probably be easy and 
straightforward.

Michael.___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[3]: [fpc-devel] LocalReferenceFixup

2010-10-05 Thread José Mejuto
Hello FPC,

Tuesday, October 5, 2010, 1:10:43 PM, you wrote:

>> I do not have too much experience with components, but calling
>> "Loaded" several times does not look very fine.
MVC> To the best of my knowledge: it should be called once only, after the 
fixups.
MVC> If it isn't so, this is a bug.

Extracted from "reader.inc", comments below...

--
[...]
procedure TReader.FixupReferences;
var
  i: Integer;
begin
  DoFixupReferences;
  GlobalFixupReferences;
  for i := 0 to FLoaded.Count - 1 do
TComponent(FLoaded[I]).Loaded;
end;
[...]

function TReader.ReadRootComponent(ARoot: TComponent): TComponent;
[...]
  if Assigned(GlobalLoaded) then
FLoaded := GlobalLoaded
  else
FLoaded := TFpList.Create;

  try
if FLoaded.IndexOf(FRoot) < 0 then
  FLoaded.Add(FRoot);
FOwner := FRoot;
FRoot.FComponentState := FRoot.FComponentState + [csLoading, csReading];
FRoot.ReadState(Self);
Exclude(FRoot.FComponentState, csReading);

if not Assigned(GlobalLoaded) then begin
  for i := 0 to FLoaded.Count - 1 do
TComponent(FLoaded[i]).Loaded;//
end;

  finally
if not Assigned(GlobalLoaded) then
  FLoaded.Free;
FLoaded := nil;
  end;
  GlobalFixupReferences;
[...]
end;

procedure TReader.ReadData(Instance: TComponent);
[...]
  { Fixup references if necessary (normally only if this is the root) }
  If (Instance=FRoot) then
DoFixupReferences;
end;
[...]
--

As you can see the "Loaded" event is called (marked with some //-)
before calling "GlobalFixupReferences", I'll try to add some writeln's
here and there to catch the event sequence and post it here for
further comments.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel