Page 1 of 1

Problem with const section

Posted: Wed Sep 17, 2003 10:56 am
by Anske
I'm currently evaluating TsiLang Components and have some problems with translating the const section. After translating the strings I'm trying to run my program, but is fails to start giving me a Stack Overflow message.

Any help would be apreciated.

Regards
Anske

Posted: Wed Sep 17, 2003 11:46 am
by isiticov
It looks like in your code there is circular calling of some procedure. Please try to reproduce the problem on simple sample test project and check if error gone. And then just compare sources of your unit with sample test units to check the differences.

Posted: Wed Sep 17, 2003 12:46 pm
by Anske
This works fine.
I'm using the components on a datamodule which is autocreated before the mainform (in both apps)
I put for testing a breakpoint on the 'Updatestrings' in both the 'oncreate' as well as in the 'changelanguage' procedures and found out that in my 'problem' app the oncreate is never called (property settings are OK) in the little demo app this works fine

Posted: Wed Sep 17, 2003 2:52 pm
by Anske
Digging a little deeper.
Somehow the procedure ChangeLanguage is run twice before the oncreate of the datamodule. This is not happening in my little demo app.
any clou?

Posted: Thu Sep 18, 2003 7:15 am
by isiticov
This looks like somewhere in your "problem" application code you're manually calling OnCreate event of datamodule. Please check this and let us know if this is the origin of problem.

Posted: Thu Sep 18, 2003 7:56 am
by Anske
Nope.
I have at this moment 2 TsiLang components (1 on the datamodule and 1 on the main form) linked to the dispatcher. If I cut lose both links to the dispatcher all is going well.

Posted: Thu Sep 18, 2003 12:38 pm
by isiticov
In such case the situation with calling twice ChangeLanguage is normal because it is calling for each TsiLang. Then I suppose the problem with Stack Overflow is somewhere in your code.

Same Error in current TSILang 6.0.4

Posted: Wed Oct 05, 2005 7:18 am
by terryk
Hi!
In my (big) project I have the same problem with Stack-Overflow.
Now I found the error. It is a problem of TSILang-Expert that can be reproduced. My project has some inherited frames and when Expert modifies code of const section, it adds (by mistake?) the line "UpdateStrings" in the same procedure UpdateStrings which causes this infinte loop. Here's what the Expert does:

// Complete proc added by Expert
procedure TMyFrame.siLang1ChangeLanguage(Sender: TObject);
begin
UpdateStrings;
inherited;
end;

// Complete proc added by Expert
procedure TMyFrame.UpdateStrings;
begin
sAlarm_1000 := siLang.GetTextOrDefault('strsAlarm_1000');
sTooHigh := siLang.GetTextOrDefault('strsTooHigh');
sTooLow := siLang.GetTextOrDefault('strsTooLow');
sOK := siLang.GetTextOrDefault('strsOK');
UpdateStrings; // ERROR!!!!
inherited;
end;

Well I also found out, that Expert will not always produce this error. My project has about 50 Frames an the error occured only in about 35-40 Frames.
Any suggestion about this?

Regards

Posted: Wed Oct 05, 2005 8:23 am
by isiticov
We will try to improve this, but currently the workaround would be only manually check the source generated by expert and fix if it is inappropriate. :(