On 08/03/2012 13:34, Martin wrote:
On 08/03/2012 13:08, michael.vancann...@wisa.be wrote:


On Thu, 8 Mar 2012, Martin wrote:

Further more:

the program below, does not crash in delphi (turbo delphi)

I also noticed. I suspect the problem is the owner; If it gets a free notification, it should pass it to all the children.

I don't think that is it.

In the example below C1 is no longer owned, when C2 is destroyed, so the problem would persist.

The problem is that opRemove breaks the bi-directional bounding of FreeNotifications.

When C2 gets the opREmove, it must mot just remove it's own entry, but also remove the entry C1 has


In the following code, I thing is the problem:

Procedure TComponent.Notification(AComponent: TComponent;
  Operation: TOperation);
Var Runner : Longint;
begin
  If (Operation=opRemove) and Assigned(FFreeNotifies) then
    begin
    FFreeNotifies.Remove(AComponent);
...

It removes only one of the 2 notify entries.

If opRemove is to remove FreeNotifications, then it mus remove them bi-directional, same as RemoveFreeNotification does




On 08/03/2012 09:56, Martin wrote:

program Project1;
{$mode objfpc}{$H+}
uses  Classes;
var
  Owner, C1, C2: TComponent;
begin
  Owner := TComponent.Create(nil);
  C1 := TComponent.Create(Owner);
  C2 := TComponent.Create(Owner);

  C1.FreeNotification(c2);

  Owner.RemoveComponent(C1); // C2 Gets on opRemove
  C2.Free;
  C1.Free; // crash

  ReadLn;
end.


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

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

Reply via email to