[fpc-devel]patch for ReadPropValue

Darek Mazur darekm at emadar.com
Sun Dec 14 22:15:09 CET 2003


   Hi

  I investigated read property from Lazarus LRS, and I noticed that tColor
property with Identifies don't work and crash  program (for example
tForm.COLOR:=clWindow)

I write small patch to avoid this

this is new function in CLASSES.INC
// ********************start patch
function GlobalIdentToInt(const Ident: String; var Int: LongInt):boolean;
var
  i : Integer;
begin

  with IntConstList.LockList do
  try
    for i := 0 to Count - 1 do
         if TIntConst(Items[I]).IdentToIntFn(Ident, Int) then exit(True);
    Result := false;
  finally
    IntConstList.UnlockList;
  end;

end;
//  *************stop patch

and changes in READER.INC
in procedure TReader.ReadPropValue(Instance: TPersistent; PropInfo:
Pointer);

from:
 case PropType^.Kind of
    tkInteger:
      if FDriver.NextValue = vaIdent then
      begin
        Ident := ReadIdent;
// *************start patch
        if GlobalIdentToInt(Ident,Value) then
          SetOrdProp(Instance, PropInfo, Value)
        else
          raise EReadError.Create(SInvalidPropertyValue);
//  *************stop patch
      end else
        SetOrdProp(Instance, PropInfo, ReadInteger);
    tkBool:
      SetOrdProp(Instance, PropInfo, Ord(ReadBoolean));

with this patch Delphi DFM converted to Lazarus LRS works fine

Darek





More information about the fpc-devel mailing list