[Lazarus] Some thoughts about the global 'Application' instance.
Martin Friebe
lazarus at mfriebe.de
Sun Jun 21 23:26:15 CEST 2009
Mattias Gaertner wrote:
> On Sun, 21 Jun 2009 19:39:17 +0100
> Martin Friebe <lazarus at mfriebe.de> wrote:
>
>> So the question I was raising was: Is forcefully avoiding any
>> multi-app scenario the right solution?
>>
>> The problem was started due to being forced to use a unit, that the
>> developer didn't want. IMHO this must be solved, the rest is
>> responsibility of the developer.
>>
>
> Unit interfaces adds a LCL widgetset into you program.
> Unit forms requires some LCL widgetset.
> These both units are interdependent, you can not get one without the
> other. If you want to use forms in a non gui application, use the nogui
> widgetset.
>
True Interfaces and forms unit are closely linked, infactneither makes
sense without the other.
But unless I misunderstand the beginning of this whole thread: That is
not the issue here.
The beginning of this thread was, that 2 applications existed, because
the developer was *forced* to included "interfaces":
Jost wrote in the initial mail of this thread:
> I always thought that an application always had one Application-instance
> from the TCustomAppliction class. But at this moment this is not the
> case for fcl-web applications, or daemon-applications which are using
> Lazarus-forms.
>
....
> But nowadays we are forced to include the 'interfaces' unit, which uses
> the 'forms' unit which has it's own global Application variable. So
> there are two TCustomApplication descdendents initialized during the
> program!
Somehow the whole thread then picked up, the first half of this, and
everyone started to discuss (at least this is the impression I got,
apologies, if I overlooked anything) , how you could avoid having the
application from the Forms unit, even if you use that unit (because
apparently you have to). So the forms unit would have to detect the
presence of another application....
But all this only means work around the consequences, instead of
tackling the cause.
If I understand correctly, Interfaces now needs to be there, because of
the smart-link - linker-alias trick used to reduce the exe size.
I haven't verified this. I would normally assume this should only be
needed, if you do use anything that uses the widgetset, and I did hope
that if you do not touch anything widget related, you should still be
able to compile without even using interfaces.
However the whole last sentence may be taken once more to the test, if
for some reason you do not smart-link your application.
In any case. as far as I am concerned there is no point in having any
checks in Forms, or any other unit, to detect a multiple application
situation. It comes down to *not* using units that would cause this.
And if indeed there is a situation where dependencies force you to do so
(which is what I thought the initial mail suggested, despite my
disbelieve), then the discussion should go how this dependencies can be
broken. So no one is forced to use anything they do not want or need.
Best Regards
Martin
More information about the Lazarus
mailing list