mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 21:42:51 +02:00
IDEIntf: WritePublishedProperties: safer align, bug #19109
git-svn-id: trunk@32568 -
This commit is contained in:
parent
1a1ce97b16
commit
dbb71f8379
@ -1687,11 +1687,25 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
|
||||||
|
function AlignToPtr(const p: Pointer): Pointer;
|
||||||
|
begin
|
||||||
|
{$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
|
||||||
|
Result := Align(p, SizeOf(Pointer));
|
||||||
|
{$ELSE}
|
||||||
|
Result := p;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
|
||||||
procedure WritePublishedProperties(Instance: TPersistent);
|
procedure WritePublishedProperties(Instance: TPersistent);
|
||||||
var
|
var
|
||||||
TypeInfo: PTypeInfo;
|
TypeInfo: PTypeInfo;
|
||||||
TypeData: PTypeData;
|
TypeData: PTypeData;
|
||||||
PropInfo: PPropInfo;
|
PropInfo: PPropInfo;
|
||||||
|
PropData: ^TPropData;
|
||||||
CurCount: integer;
|
CurCount: integer;
|
||||||
begin
|
begin
|
||||||
TypeInfo:=Instance.ClassInfo;
|
TypeInfo:=Instance.ClassInfo;
|
||||||
@ -1706,10 +1720,10 @@ begin
|
|||||||
// read all property infos of current class
|
// read all property infos of current class
|
||||||
TypeData:=GetTypeData(TypeInfo);
|
TypeData:=GetTypeData(TypeInfo);
|
||||||
// skip unitname
|
// skip unitname
|
||||||
PropInfo:=PPropInfo(PByte(@TypeData^.UnitName)+Length(TypeData^.UnitName)+1);
|
PropData:=AlignToPtr(PByte(@TypeData^.UnitName)+Length(TypeData^.UnitName)+1);
|
||||||
// read property count
|
// read property count
|
||||||
CurCount:=PWord(PropInfo)^;
|
CurCount:=PWord(PropData)^;
|
||||||
inc(PtrUInt(PropInfo),SizeOf(Word));
|
PropInfo:=PPropInfo(@PropData^.PropList);
|
||||||
debugln(' UnitName=',TypeData^.UnitName,' Type=',TypeInfo^.Name,' CurPropCount=',dbgs(CurCount));
|
debugln(' UnitName=',TypeData^.UnitName,' Type=',TypeInfo^.Name,' CurPropCount=',dbgs(CurCount));
|
||||||
|
|
||||||
{writeln('TPropInfoList.Create D ',CurCount,' TypeData^.ClassType=',DbgS(TypeData^.ClassType));
|
{writeln('TPropInfoList.Create D ',CurCount,' TypeData^.ClassType=',DbgS(TypeData^.ClassType));
|
||||||
@ -1731,7 +1745,7 @@ begin
|
|||||||
// point PropInfo to next propinfo record.
|
// point PropInfo to next propinfo record.
|
||||||
// Located at Name[Length(Name)+1] !
|
// Located at Name[Length(Name)+1] !
|
||||||
debugln(' Property ',PropInfo^.Name,' Type=',PropInfo^.PropType^.Name);
|
debugln(' Property ',PropInfo^.Name,' Type=',PropInfo^.PropType^.Name);
|
||||||
PropInfo:=PPropInfo(pointer(@PropInfo^.Name)+PByte(@PropInfo^.Name)^+1);
|
PropInfo:=PPropInfo(AlignToPtr(pointer(@PropInfo^.Name)+PByte(@PropInfo^.Name)^+1));
|
||||||
dec(CurCount);
|
dec(CurCount);
|
||||||
end;
|
end;
|
||||||
TypeInfo:=TypeData^.ParentInfo;
|
TypeInfo:=TypeData^.ParentInfo;
|
||||||
@ -1787,19 +1801,6 @@ const
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
);
|
);
|
||||||
|
|
||||||
// -----------------------------------------------------------
|
|
||||||
|
|
||||||
function AlignToPtr(const p: Pointer): Pointer;
|
|
||||||
begin
|
|
||||||
{$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
|
|
||||||
Result := Align(p, SizeOf(Pointer));
|
|
||||||
{$ELSE}
|
|
||||||
Result := p;
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------
|
|
||||||
|
|
||||||
var
|
var
|
||||||
PropertyEditorMapperList:TList;
|
PropertyEditorMapperList:TList;
|
||||||
PropertyClassList:TList;
|
PropertyClassList:TList;
|
||||||
|
Loading…
Reference in New Issue
Block a user