[Lazarus] Some thoughts about the global 'Application' instance.
Mattias Gaertner
nc-gaertnma at netcologne.de
Sun Jun 21 22:10:11 CEST 2009
On Sun, 21 Jun 2009 19:39:17 +0100
Martin Friebe <lazarus at mfriebe.de> wrote:
>
>
> Graeme Geldenhuys wrote:
> > Martin Friebe wrote:
> >>
> >> Example: I may write a cgi-application (therefore it must have the
> >> web-fcl CgiApplication, right?), but I want to use this app to
> >> report the current screen resolution on the Server, so I do want
> >> to access the Screen object from the forms unit,
> >
> > As a side note:
> > CGI applications are actually non-GUI applications. Which also
> > means they can run on for example a Linux server that doesn't have
> > a GUI running or even installed. So including Forms unit or any GUI
> > units for that matter is going to causes that CGI application to
> > fail or report errors on startup anyway because they cannot find
> > the DISPLAY environment variable or open a connection to the
> > running X11 server. I have first hand experience with this and had
> > to rework the core tiOPF framework units to be truly non-gui, at
> > which point my CGI apps and console based unit test suite started
> > working correctly.
> >
> > Windows users never detect this problem, because you don't get
> > Windows severs without a GUI (though I believe Microsoft is working
> > on such a Server release now).
>
> True, but not the point, sorry.
>
> The point I was trying to make, is that a developer may, for whatever
> reason, under whatever conditions and assumptions *intentionally* add
> more than one unit wich creates an application. And this developer
> may access all of those created applications for different scenarios.
> This may not be common, this may be rare indeed, but possible.
Please give an example.
> 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.
Creating a second application instance is not portable. It is not
enough to create two Application objects.
For example cgi+gui makes no sense under linux, and widgetsets like gtk
and qt are more than gui frameworks.
Mattias
More information about the Lazarus
mailing list