BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bug in IsDefaultPropertyValue?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OpenToolsAPI
View previous topic :: View next topic  
Author Message
Mattias Andersson
Guest





PostPosted: Fri Nov 17, 2006 12:59 am    Post subject: Bug in IsDefaultPropertyValue? Reply with quote



Hi all,

I'm writing my own custom streaming routines for TPersistent based objects
in Delphi 7.

Now, it seems that I've come across a glitch in one of the streaming
functions. The function that causes the problem is 'IsDefaultPropertyValue',
which I believe is used to highlight non-default values in the Object
Inspector. Apparently this is also one of two functions that were added to
the Classes unit in Delphi 7.

The problem is a nil-pointer dereference error inside IsDefaultMethodProp at
the following line:

Result := (Value.Code = DefaultCode) or
((Value.Code <> nil) and (LookupRoot.MethodName(Value.Code) = ''));

I think an additional test is needed here to ensure that LookupRoot is
actually assigned.

See the test case below in order to reproduce the problem.

Do you think that this should be reported to QC?

Kind regards,

Mattias Andersson


uses
Classes, TypInfo;

type
TMyClass = class(TPersistent)
private
FOnEvent: TNotifyEvent;
procedure DummyMethod(Sender: TObject);
published
property OnEvent: TNotifyEvent read FOnEvent write FOnEvent;
end;

procedure TMyClass.DummyMethod(Sender: TObject);
begin
end;

procedure TForm1.Button1Click(Sender: TObject);
var
MyClass: TMyClass;
PropInfo: PPropInfo;
begin
MyClass := TMyClass.Create;
try
MyClass.OnEvent := MyClass.DummyMethod;
PropInfo := GetPropInfo(MyClass, 'OnEvent');
IsDefaultPropertyValue(MyClass, PropInfo, nil);
finally
MyClass.Free;
end;
end;
Back to top
Sebastian Modersohn
Guest





PostPosted: Wed Nov 22, 2006 7:03 am    Post subject: Re: Bug in IsDefaultPropertyValue? Reply with quote



Quote:
Do you think that this should be reported to QC?

I'd say yes, especially since you've got a handy small test-case. Note that
..opentoolsapi is not best group since this applies to the VCL and the QC
should also be filed against the VCL\Core VCL Classes\Streaming area.

--
Sebastian
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OpenToolsAPI All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.