Lazarus

Programming => General => Topic started by: petevick on February 02, 2023, 08:26:03 am

Title: [Solved] Initialization sequence of Units, Linux/Windows
Post by: petevick on February 02, 2023, 08:26:03 am
I have a project that I compile in Linux and Windows, this project has several Units, let's call them Unit2 and Unit3. In Linux I know that in the TForm1.FormActivate procedure, Unit2 and 3 have been initialized, which seems reasonable, but they haven't been initialized in Windows at that point, so at what point would these Unit2 and 3 get initialized in Windows ??
Title: Re: Initialization sequence of Units, Linux/Windows
Post by: TRon on February 02, 2023, 08:45:07 am
Perhaps the following link is able to help you out ?
https://wiki.freepascal.org/Event_order
Title: Re: Initialization sequence of Units, Linux/Windows
Post by: KodeZwerg on February 02, 2023, 08:53:50 am
You can easy find out on your own:
Code: Pascal  [Select][+][-]
  1. unit UnitX;
  2. interface
  3. implementation
  4.  
  5. initialization
  6. // ShowMessage('UnitX Initialized!');
  7. // WriteLn('UnitX Initialized');
  8.  
  9. end.
Title: Re: Initialization sequence of Units, Linux/Windows
Post by: Thaddy on February 02, 2023, 08:58:01 am
I have a project that I compile in Linux and Windows, this project has several Units, let's call them Unit2 and Unit3. In Linux I know that in the TForm1.FormActivate procedure, Unit2 and 3 have been initialized, which seems reasonable, but they haven't been initialized in Windows at that point, so at what point would these Unit2 and 3 get initialized in Windows ??
There is no difference between windows and linux.
And initialization is *before* FormActivate not in FormActivate.
Activation is after newinstance (allocation) and subsequently initinstance (initialization) is called.
Whole units are usually initialized left to right if they actually need to be initialized, that is..
Title: Re: Initialization sequence of Units, Linux/Windows
Post by: PascalDragon on February 02, 2023, 09:08:38 pm
I have a project that I compile in Linux and Windows, this project has several Units, let's call them Unit2 and Unit3. In Linux I know that in the TForm1.FormActivate procedure, Unit2 and 3 have been initialized, which seems reasonable, but they haven't been initialized in Windows at that point, so at what point would these Unit2 and 3 get initialized in Windows ??

How do you assume that these units haven't been “initialized”?
Title: Re: Initialization sequence of Units, Linux/Windows
Post by: petevick on February 04, 2023, 12:20:48 pm
This is has been doing my head in, I've obviously changed something as I'm not getting the error that originally prompted me to make this topic. So unfortunately I now can't replicate whatever was causing the problem  %) I'll mark as solved and move on along  :-[
TinyPortal © 2005-2018