[fpc-devel] Can someone confirm if this is a bug? (ancestor in TWRiter.WriteProperty)
Paul Ishenin
webpirat at mail.ru
Tue Aug 18 12:56:31 CEST 2009
Michael Van Canneyt wrote:
>>
>> when you get to write TPersistenChild you enter the following code
>>
>> tkClass:
>> begin
>> ObjValue := TObject(GetObjectProp(Instance, PropInfo));
>> if HasAncestor then
>> begin
>> AncestorObj := TObject(GetObjectProp(Ancestor, PropInfo));
>> if Assigned(AncestorObj) then
>> if Assigned(ObjValue) and
>> (TComponent(AncestorObj).Owner = FRootAncestor) and
>> (TComponent(ObjValue).Owner = Root) and
>> (UpperCase(TComponent(AncestorObj).Name) =
>> UpperCase(TComponent(ObjValue).Name)) then
>> AncestorObj := ObjValue
>> // else
>> // AncestorObj := nil;
>> end else
>> AncestorObj := nil;
>> --------------
>>
>> TObject(GetObjectProp(Ancestor, PropInfo)); returns the TpersistentChil
>> as well as ObjValue being TPersistent
>>
>>
>> both get casted to TComponent with no check?
> I may have mis-judged t, but the problem is still the same:
>
> Ancestors can only be a TComponent.
Ancestor (in this report http://bugs.freepascal.org/view.php?id=14364)
is TLabel, HasAncestor = True (since Ancestor is TLabel and
Instance.ClassType = Ancestor.ClassType) and both ObjValue and
AncestorObj are TAnchorSide (descendant of TPersistent and not
TComponent). Therefore it accessing TAnchorSide property (TPersistent)
as TComponent and we have a crash.
But maybe the problem is somewhere else. For example can Ancestor be
TLabel or it is usually some form, frame or datamodule?
Best regards,
Paul Ishenin.
More information about the fpc-devel
mailing list