I have an application that was leaking. The odd thing is it worked before moving it from XE to XE3. So what's I find out?

I have an application that was leaking. The odd thing is it worked before moving it from XE to XE3. So what's I find out?
I have a class inheriting from TObjectList. In the constructor, it was calling "inherited" and I realized that XE3 doesn't behave like XE.  In XE3 "inherited" called the TObject.Create rather than the immediate parent TObjectList.Create, thus not setting FOwnsObjects := True;.

type
  TOList = class(TObjectList)
  public
    constructor Create;
  end;

{ TOList }

constructor TOList.Create;
begin
  inherited;
end;

The solution? Changed it to "inherited Create".

constructor TOList.Create;
begin
  inherited Create;
end;

Is this a bug? It looks to me like a HUGE one!

Comments

  1. Agreed. I think the bug was in XE then, it was confusing the old and the new.

    Regards,

    A

    ReplyDelete
  2. The bug is in XE3 because inherited without specifying a name should call the parents method with the same signature (which TObjectList has) but skips it.

    ReplyDelete

Post a Comment