Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-11 Thread José Mejuto
Hello FPC,

Monday, October 11, 2010, 9:07:44 AM, you wrote:

 Attached is the example. One form that load a menu which opens a new
 form which display a table in a grid. You will need to change the
 password setup, and maybe database (I'm using aliases instead full
 path), and of course the sql line.
 Example is an small Lazarus project.
MS I converted the example to MSEgui, works OK.

So or the problem is in LCL or I'm suffering some kind of poltergeist.
Thank you taking the time to perform the test.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-08 Thread José Mejuto
Hello FPC,

Friday, October 8, 2010, 8:35:44 AM, you wrote:

 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.
MG In Lazarus both use the same loading mechanism. Referenced
MG datamodules are automatically found if they already exist.
MG The main difference is that CreateForm sets the variable (e.g.
MG Form1) before it creates and loads the form, while
MG Form1:=TForm1.Create(nil) sets Form1 after creation and loading.
MG It is up to the programmer to create the forms and datamodules in the
MG right order. If you have circle dependencies, follow Martin's advice
MG and enclose the creation of datamodule and forms in
MG Begin/Notify/EndGlobalLoading.

I'm not aware about any cycle dependency, but I'm not completly sure
as I do not know which kind of dependency (from the technical point of
view I think) you are talking about, so I'll explain a layuot to try
to narrow the source of the problem (my design or library design):

I have a very simple application, 2 forms and 1 datamodule. The first
form is a simple select your option which will load all forms on
demand. When this main form is loaded the datamodule is being created
also, but not the second form.

Datamodule
--
In datamodule I have 1 firebird connection and 1 firebird transaction.
The connection is at design time linked with the transaction via
property and proper connect data is filled in.

Secondary form
--
It have a simple SQLQuery, linked with the firebird connection in the
datamodule. Transaction property is automagically filled with the
firebird connection transaction. The Active property is set to true
and at design time if I drop a grid I can see that data is being
retrieved.

Relationship


  MainSecond form  Datamodule
+--+  +--++---+
|  |  | SQLQuery |+--- SQLConnection --+
|Button--|| ||   |   | |
+--+  ++--+--- Transaction ---+
  +---+

Creation order
--
1) Create main form
2) Create data module
3) Wait in main form for user input
4) Create second form

I had put some writeln in the source code at the property sets of
active and database of SQLQuery and the expected sequece is:

--
qryGroupClientsWatch set active to: -1
qryGroupClientsWatch set to database
qryGroupClientsWatch set active to: -1
--

First line receives the Active:=true, but as csLoading is present it
sets a flag to activate after complete loading, second line sets the
database property and the third line should came from the Loaded
event which checks the flag and if not csLoading is present try to
open the dataset. This layout must work.

But the layout that I receive is:

--
qryGroupClientsWatch set active to: -1
qryGroupClientsWatch set active to: -1
--

First line is the Active:=true, as csLoading is present the activate
is delayed. The reader reads the database property, as it is a tkClass
it add it to LocalReferenceFixups and do not set the property (so no
call to property set), and them the Loaded event is fired and as
csLoading is not present it tries to open the dataset raising the
database not set exception.

I hope I had explained it in detail.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-08 Thread José Mejuto
Hello FPC,

Friday, October 8, 2010, 1:41:39 PM, you wrote:

 Creation order
 --
 1) Create main form
MS  application.createform() or t*form.create()
 2) Create data module
MS  application.createdatamodule();
 3) Wait in main form for user input
 4) Create second form
MS  application.createform() or t*form.create()
MS Such a scenario works in MSEgui.


Application.Initialize;
Application.CreateForm(TfrmWorkbench, frmWorkbench);
Application.CreateForm(TdmCharting, dmCharting);
Application.Run;


procedure TfrmWorkbench.BitBtn5Click(Sender: TObject);
var
  r: TfrmReportByFile;
begin
  Application.CreateForm(TfrmReportByFile,r);
  r.Show;
end;


Does not work in Lazarus almost up to date SVN, and fpc 2.5.1 July
2010

But if my memory serves me, it does not work at least since Lazarus
0.9.26 and the related fpc version.

I had not reported it before because I think that the problem was the
missing datamodules, so I converted everything to use datamodules, but
the problem remains.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-08 Thread Mattias Gärtner

Zitat von José Mejuto joshy...@gmail.com:


Hello FPC,

Friday, October 8, 2010, 1:41:39 PM, you wrote:


Creation order
--
1) Create main form

MS  application.createform() or t*form.create()

2) Create data module

MS  application.createdatamodule();

3) Wait in main form for user input
4) Create second form

MS  application.createform() or t*form.create()
MS Such a scenario works in MSEgui.


Application.Initialize;
Application.CreateForm(TfrmWorkbench, frmWorkbench);
Application.CreateForm(TdmCharting, dmCharting);
Application.Run;


procedure TfrmWorkbench.BitBtn5Click(Sender: TObject);
var
  r: TfrmReportByFile;
begin
  Application.CreateForm(TfrmReportByFile,r);
  r.Show;
end;


Does not work in Lazarus almost up to date SVN, and fpc 2.5.1 July
2010


Please provide an example.
Either you are misusing the sql components or there is a bug in the  
sql components.




But if my memory serves me, it does not work at least since Lazarus
0.9.26 and the related fpc version.

I had not reported it before because I think that the problem was the
missing datamodules, so I converted everything to use datamodules, but
the problem remains.


Database components should work independent of the owner class.

Mattias


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-07 Thread José Mejuto
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.

MS MSEide does not create the code for loading additional forms and datamodules
MS exactly because it is necessary that the user knows what is going on there.
MS Please have a look into the program file of your application. I repeat:
MS If there are interlinked forms/datamodules either:
MS - Avoid circular component references.
MS - Create the referencing forms/datamodules after the referenced 
MS forms/datamodules.

I'm not using MSEide, but of course all referenced objects (databases
in this case) are being created before the conflictive
forms/components.

MS Or:
MS - Call msebegingloballoading.
MS - Create the forms/datamodules.
MS - Create mseendgloballoading.

I'll check this approach, but just to circunvent the problem. A
different thing is that maybe the bug/problem is in SQLQuery, in
TReader, in Lazarus logic or in any other piece of code.

MS A Lazarus adept may write the necessary steps for Lazarus.
MS If you get the exception in a single form without external component
MS references, that would be another story...

I'm not sure 100%, changed the database connections to datamodules to
keep forms a bit cleaner, but I'm quite sure that the same problem
happends using a single form with all needed components in the form
(as in the past).

As you are the only one replaying (a lot of thanks) this makes me
think that other developers think that this behavior is OK in TReader,
so I'll try to post a simple form code in the Lazarus list and ask for
feedback about how it should work.

Thank you again for your support.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-07 Thread José Mejuto
Hello FPC,

Thursday, October 7, 2010, 8:30:06 PM, you wrote:

MS Aha. In MSEgui application.createform()/createdatamodule() must be called in
MS order to allow component linking with already loaded modules, 
t*form.create()
MS is not enough. I don't know how this works in Lazarus.

Thank you, I'll try to gather more information from Lazarus list, but
if that's the case it completly defeats the advantages of a datamodule
and/or the presence of a published Active property in the SQLQuery (as
it is only valid if it is false at runtime) :-?

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-07 Thread José Mejuto
Hello FPC,

Thursday, October 7, 2010, 9:21:18 PM, you wrote:

 Thank you, I'll try to gather more information from Lazarus list, but
 if that's the case it completly defeats the advantages of a datamodule
 and/or the presence of a published Active property in the SQLQuery (as
 it is only valid if it is false at runtime) :-?
MS No, no, in MSEgui it works OK if you call
MS application.createform(t*form,*forminstance);
MS  instead of  
MS *forminstance:= t*form.create();
MS I assume in Lazarus it works too.

Hm... I was not aware that both modes does not end in the same
functionality... (I allways use n:=TNewForm.Create(Self)) I'll check
it. Thank you again.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-06 Thread José Mejuto
Hello FPC,

Wednesday, October 6, 2010, 8:37:44 AM, you wrote:

 Yes, but it is not set, because BeginGlobalLoading is not called at
[...]
MS Avoid circular component references in the forms and adjust the creation 
order
MS that the referencing forms are created later or use
[...]
MS Lazarus:
MS 
MS  begingloballoading;
MS [...] create the forms
MS  notifygloballoading;
MS  endgloballoading;
MS 
MS (not tested).

I think I can see your point, but from the end user point of view
this is not a possibility. How to tell to the user, Remeber you must
call beginglobal... and notifyglobal... and finally endglobal... when
you create forms with components that need a global loading link
reference fixup :-?

Moreover user can not take care of creation order, it is not
deterministic (AFAIK), there is no way to change it in Lazarus and
finally it defeats the drag/drop/design paradigm. I have a form with
25 SQLQuery, 23 of them are chained in some way, if I need a new one
at the beginning I must delete 23, add the new one, create or paste
the 23 again and relink manually again ?

So the final question, should this moved from fpc-devel to Lazarus
mailing list ? Is it not considered a bug in the TReader ?

Thank you.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-05 Thread José Mejuto
Hello Martin,

Tuesday, October 5, 2010, 9:56:41 AM, you wrote:

 I find a problem that I'm unable to resolve, with my limited skills.
 In TReader when a property is a TClass it is being added to be
 resolved after all components are loaded, but the Loaded call is
 performed before this fixup, so when a component receive the Loaded
 signal some fields are still not completly filled in.
MS Use
MS 
MS procedure BeginGlobalLoading;
MS procedure NotifyGlobalLoading;
MS procedure EndGlobalLoading;
MS 

I see, but there is still a problem, I think. Let me explain:

1) Component is being read, it reads Active property, if set and
csLoading then the active is postponed to afterload.
2) The Database property is being read, but as it is a TClass it is
added to LocalFixups.
3) The remaining properties are beign read.
4) Component is notified with Loaded signal, so it tries to active
itself, but database is not set.
5) Fixups are performed.
6) Component is notified again with Loaded signal.

I do not know how to instruct the component to skip the first Loaded
signal and wait for the next one, specially because if Database is
not set (trully error) the second Loaded signal will not be fired.
Maybe a component state like csFixupsPending ?

I do not have too much experience with components, but calling
Loaded several times does not look very fine.

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-05 Thread Michael Van Canneyt



On Tue, 5 Oct 2010, José Mejuto wrote:


Hello Martin,

Tuesday, October 5, 2010, 9:56:41 AM, you wrote:


I find a problem that I'm unable to resolve, with my limited skills.
In TReader when a property is a TClass it is being added to be
resolved after all components are loaded, but the Loaded call is
performed before this fixup, so when a component receive the Loaded
signal some fields are still not completly filled in.

MS Use
MS 
MS procedure BeginGlobalLoading;
MS procedure NotifyGlobalLoading;
MS procedure EndGlobalLoading;
MS 

I see, but there is still a problem, I think. Let me explain:

1) Component is being read, it reads Active property, if set and
csLoading then the active is postponed to afterload.
2) The Database property is being read, but as it is a TClass it is
added to LocalFixups.
3) The remaining properties are beign read.
4) Component is notified with Loaded signal, so it tries to active
itself, but database is not set.
5) Fixups are performed.
6) Component is notified again with Loaded signal.

I do not know how to instruct the component to skip the first Loaded
signal and wait for the next one, specially because if Database is
not set (trully error) the second Loaded signal will not be fired.
Maybe a component state like csFixupsPending ?

I do not have too much experience with components, but calling
Loaded several times does not look very fine.


To the best of my knowledge: it should be called once only, after the fixups. 
If it isn't so, this is a bug.


Michael.___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re[2]: [fpc-devel] LocalReferenceFixup

2010-10-05 Thread José Mejuto
Hello FPC,

Tuesday, October 5, 2010, 4:08:08 PM, you wrote:

 As you can see the Loaded event is called (marked with some //-)
 before calling GlobalFixupReferences, 
MS Not if GlobalLoaded is set.

Yes, but it is not set, because BeginGlobalLoading is not called at
all from any point in the code, nor in fpc/rtl nor in Lazarus lcl, nor
in Lazarus IDE, but the IDE is not the important thing as the main
problem is at runtime. Only LNet httpsvlt is calling the
BeginGlobalLoading unless some other call it using some kind of
opaque pointer :-?

-
F:\Lazarusfind begingloballoading *.pas;*.pp;*.inc /s

  0 lines in  0 files

F:\Lazarus\fpc\svn\

F:\fpc\svnfind begingloballoading *.pas;*.pp;*.inc /s

 F:\fpc\svn\packages\fcl-net\src\httpsvlt.pp
  BeginGlobalLoading;

 F:\fpc\svn\rtl\objpas\classes\classes.inc
procedure BeginGlobalLoading;
  { Free the memory occupied by BeginGlobalLoading }

 F:\fpc\svn\rtl\objpas\classes\classesh.inc
procedure BeginGlobalLoading;

  4 lines in  3 files
-

Is each component which must call BeginGlobalLoading ? or is the
read logic which must decide when activate the globalloading ?

-- 
Best regards,
 José

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel