[fpc-devel] LocalReferenceFixup

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Oct 8 08:35:44 CEST 2010


On Thu, 7 Oct 2010 20:30:06 +0200
Martin Schreiber <mse00000 at gmail.com> wrote:

> On Thursday, 7. October 2010 17.25:28 José Mejuto wrote:
> > Hello FPC,
> >
> > Thursday, October 7, 2010, 8:27:23 AM, you wrote:
> >
> > MS> Maybe you mix up component creation order and form/datamodule creation
> > order? MS> I wrote about form/datamodule creation order.
> >
> > The datamodule is created just in program load, before any dependent
> > component is created, so my execution layout is:
> >
> > 1) Main form create (only a bunch of visual options).
> > 2) Datamodules are being created and will keep loaded up to main form
> > destroy.
> > 3) When user selects an option in main form, the new form, with some
> > SQLQuery components inside linked with the already loaded
> > datamodule(s), is being created and the problem happends.
> >
> Aha. In MSEgui application.createform()/createdatamodule() must be called in 
> order to allow component linking with already loaded modules, t*form.create() 
> is not enough. I don't know how this works in Lazarus.

In Lazarus both use the same loading mechanism. Referenced
datamodules are automatically found if they already exist. The main difference is that CreateForm sets the variable (e.g. Form1) before it creates and loads the form, while Form1:=TForm1.Create(nil) sets Form1 after creation and loading.

It is up to the programmer to create the forms and datamodules in the
right order. If you have circle dependencies, follow Martin's advice
and enclose the creation of datamodule and forms in
Begin/Notify/EndGlobalLoading.

Theoretically the IDE could do this, but this would be quite some work
to implement.


Mattias



More information about the fpc-devel mailing list