Default Translator crashs because TColumTitle isn't a TComponent derived
Original Reporter info from Mantis: mingodad
-
Reporter name: Domingo Alvarez Duarte
Original Reporter info from Mantis: mingodad
- Reporter name: Domingo Alvarez Duarte
Description:
When trying to use the DefaultTranslator my application crahs because TColumTitle isn't a TComponent derived, debugging I found where is the problem, the minor addition bellow prevents the crash but doesn't solve the translation problem.
Additional information:
procedure TDefaultTranslator.TranslateStringProperty(Sender: TObject;
const Instance: TPersistent; PropInfo: PPropInfo; var Content: string);
var
s: String;
Section: String;
Component: TComponent;
begin
if not Assigned(FMOFile) then exit;
if not Assigned(PropInfo) then exit;
// do not translate at design time
if Instance is TComponent then
if csDesigning in (Instance as TComponent).ComponentState then exit;
if (UpperCase(PropInfo^.PropType^.Name)<>'TTRANSLATESTRING') then exit;
s:=FMOFile.Translate(Content);
if (s = '') and (Instance is TComponent) then //<<==== here a check to prevent crash
begin
Component := Instance as TComponent;
if Component.Owner<>nil then
Section := UpperCase(Component.Owner.Name) + '.';
Section := 'T' + Section + UpperCase(Component.Name) + '.' +
UpperCase(PropInfo^.Name);
s := FMoFile.Translate(Section + #4 + Content);
end;
if s<>'' then Content:=s;
end;
Mantis conversion info:
- Mantis ID: 14984
- Version: 0.9.29 (SVN)
- Fixed in version: 0.9.29 (SVN)
- Fixed in revision: 23223 (#d4b181ab)
- Target version: 0.9.30