Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Things to be aware in Delphi 12 (where EMB broke lots of code out there)
After some more time playing with Delphi 12 and supporting different applications

1) Indexes in lists are now NativeInt. It means that in 32 bits, nothing changes, but in 64 bits it becomes a Int64.

Whatever TList, TStringList, TObjectList, etc. descendants that you have in your code where you have new Get() and Put() methods for the list you will need to rewrite and (the worst part) probably declare a new alias for the NativeInt type if you need to code to keep compatibility with older Delphi versions.
Warning: The compiler doesn't give you clear messages for this case.

I have really no idea why Embarcadero decided to do that, really. I asked Marco Cantu on his blog but seems that he didn't like/approve my question. Funny.  Tongue

2) OnCreate/OnDestroy events of Forms are triggered from AfterContruction/BeforeDestruction methods, not from Create/Destroy as before. It means that code where you override the contructor of the form and then initializes data inside OnCreate may start failing. Check this example:

  TMyForm = class(TForm)
    procedure FormCreate(Sender: TObject);
    FMyList: TStringList;
    constructor CreateEx(AOwner: TComponent; aSomeItem: string);

constructor TMyForm.CreateEx(aOwner: TComponent; aSomeItem: string);
  inherited Create(aOwner);

procedure Tv6LayerEditor.FormCreate(Sender: TObject);
  FMyList := TStringList.Create;
The code above works perfectly fine since Delphi 1 but now on Delphi 12 it fails with an AV inside the CreateEx() constructor. This happens because FMyList is created only inside Form's OnCreate event (FormCreate above) which will only happen after the AfterConstruction has been executed. Until Delphi 11, the event would fire when calling the inherited Create() constructor.

Although I believe that this is "correct", especially because exceptions inside OnCreate event wouldn't cause the constructor to  fail, the fact that there is no way to keep the old behavior is problematic.
There is no simple way to detect this problem unless through code inspection. In a huge code base it can take a long time and it's very error prone.
This is another change that I see no reason for and don't know how it got approved...

Messages In This Thread
Things to be aware in Delphi 12 (where EMB broke lots of code out there) - by Alexandre Machado - 02-14-2024, 01:04 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)