[fpc-pascal] TPersistent does not call IFPObserved.FPONotifyObservers

2016-04-22 Thread Dennis

I have a class inheriting from Tpersistent:
type
  TCondition=class( TPersistent, ICondition)

var
  aCondition : TCondition;

 but surprisingly,  when I call
  aCondition.FPOAttachObserver(someobj);

I discovered that nothing was executed.
I used debugger to step through this line and nothing was executed.

As a result, when this aCondition is destroyed, it won't notify the 
observers.


I checked the source code  "persist.inc", it is indeed implemented!

procedure TPersistent.FPOAttachObserver(AObserver: TObject);
Var
   I : IFPObserver;

begin
   If Not AObserver.GetInterface(SGUIDObserver,I) then
 Raise EObserver.CreateFmt(SErrNotObserver,[AObserver.ClassName]);
   If not Assigned(FObservers) then
 FObservers:=TFPList.Create;
   FObservers.Add(I);
end;


What is wrong?  I am using FPC 3.1.1 trunk downloaded a few days ago.

From the documentation, there is this line:

TPersistent implements the IFPObserved 
 
interface for the benefit of descendent classes, but does not call 
IFPObserved.FPONotifyObservers 
. 
Descendents such as TStrings 
 and 
TCollection 
 and 
TCollectionItem 
 
do use it.




But the source code DOES CALL IFPObserved.FPONotifyObservers 
!


destructor TPersistent.Destroy;
begin
  If Assigned(FObservers) then
begin
FPONotifyObservers(Self,ooFree,Nil);
FreeAndNil(FObservers);
end;
  inherited Destroy;
end;

Why did the documentation say that?  Why was those code seemed not 
linked at all?  Some compiler options I messed up?


Dennis

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Unit path search order

2016-04-22 Thread Martin Schreiber
Hi,
http://www.freepascal.org/docs-html/current/user/usersu7.html#x21-280003.1.2
states:
"
You can add a directory to the unit search path with the (-Fu (see page 100)) 
option. Every occurrence of one of these options will insert a directory to 
the unit search path. i.e. the last path on the command line will be searched 
first.
"
Does this still apply? My experiments seem to indicate that the first path on 
commandline is searched first.

Martin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal