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)
(02-14-2024, 01:04 AM)Alexandre Machado Wrote: 2) OnCreate/OnDestroy events of Forms are triggered from AfterContruction/BeforeDestruction methods, not from Create/Destroy as before.

As it should be. That has been the default behavior for over 25 years. If you wanted the events triggered during the (base class) constructor/destructor, you had to set the OldCreateOrder property to True (it was False by default). That property was first introduced in Delphi 4 or 5 (not sure which one, but definitely one of them), and was (finally!) removed in Delphi 11.

(02-14-2024, 01:04 AM)Alexandre Machado Wrote: It means that code where you override the contructor of the form and then initializes data inside OnCreate may start failing.

If you are overriding the constructor, why are you also using the OnCreate event? Seems counter-productive to me. Use one or the other, never both together.

(02-14-2024, 01:04 AM)Alexandre Machado Wrote: The code above works perfectly fine since Delphi 1

In Delphi 1-3 yes, because there was no other option back then. But that changed once OnCreate was moved to AfterConstruction() and OldCreateOrder was introduced to let people go back to the old behavior if they wanted it. But the default behavior since Delphi 4/5 has always been to trigger OnCreate in AfterConstruction() (and trigger OnDestroy in BeforeDestruction()).

(02-14-2024, 01:04 AM)Alexandre Machado Wrote: but now on Delphi 12 it fails with an AV inside the CreateEx() constructor.

As it should be, because that code you showed is just bonkers. It should NEVER have worked in the first place, unless you had OldCreateOrder set to True (which you never should).

(02-14-2024, 01:04 AM)Alexandre Machado Wrote: Until Delphi 11, the event would fire when calling the inherited Create() constructor.

The only way that could ever have happened is if you had set OldCreateOrder to True. That is no longer an option in Delphi 11 onward.


Messages In This Thread
RE: Things to be aware in Delphi 12 (where EMB broke lots of code out there) - by rlebeau - 02-14-2024, 05:29 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)