[fpc-devel] Streaming readonly properties
Vincent Snijders
vsnijders at quicknet.nl
Thu Dec 14 00:11:14 CET 2006
Michael Van Canneyt schreef:
>> Should I amend to patch to allow streaming properties of readonly
>> subcomponents?
> =
> Yes, please do. It should be quite like the check you made before...
> =
Next attempt, see attached patch.
Vincent
-------------- next part --------------
Index: writer.inc
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- writer.inc (revision 5588)
+++ writer.inc (working copy)
@@ -633,16 +633,25 @@
Handled: Boolean;
=
begin
-
- if (not Assigned(PPropInfo(PropInfo)^.SetProc)) or
- (not Assigned(PPropInfo(PropInfo)^.GetProc)) then
+ // do not stream properties without getter
+ if not Assigned(PPropInfo(PropInfo)^.GetProc) then
exit;
+ =
+ // properties without setter are only allowed, if they are subcomponents
+ PropType :=3D PPropInfo(PropInfo)^.PropType;
+ if not Assigned(PPropInfo(PropInfo)^.SetProc) then begin
+ if PropType^.Kind<>tkClass then
+ exit;
+ ObjValue :=3D TObject(GetObjectProp(Instance, PropInfo));
+ if not ObjValue.InheritsFrom(TComponent) or
+ not (csSubComponent in TComponent(ObjValue).ComponentStyle) then
+ exit;
+ end;
=
{ Check if the ancestor can be used }
HasAncestor :=3D Assigned(Ancestor) and ((Instance =3D Root) or
(Instance.ClassType =3D Ancestor.ClassType));
=
- PropType :=3D PPropInfo(PropInfo)^.PropType;
case PropType^.Kind of
tkInteger, tkChar, tkEnumeration, tkSet:
begin
More information about the fpc-devel
mailing list