Access Violation error using IInterfaceList Delphi XE3 -
i have encountered access violation error [access violation @ address 5005f6e in module 'rtl170'. read of address 0000000a] using iinterfacelist. code looks this:
if not assigned(foroutingcodes) exit; := 0 foroutingcodes.ncount - 1 begin ... end;
the declaration of foroutingcodes is:
foroutingcodes : iroutingcodelist;
and definition of iroutingcodelist
iroutingcodelist = interface function getcount: integer; ... property ncount: integer read getcount; end;
the implementation of ncount property is:
function troutingcodelist.getcount: integer; begin result := 0; if assigned(foitems) result := foitems.count; // here access violation error end;
where troutingcodelist implementation of iroutingcodelist , foitems declared as:
foitems: iinterfacelist;
i have fixed using
foitems: tlist<iroutingcode>;
instead of
foitems: iinterfacelist;
i new delphi, can me understand wrong previous approach. don't know if relevant because there many other changes our product, issue appeared after moved delphi xe delphi xe3.
thanks in advance.
update: in response uwe raabe
i have changed foitems initialisation from
constructor troutingcodelist.create; begin foitems := tinterfacelist.create; end;
to
constructor troutingcodelist.create; begin foitems := tlist<iroutingcode>.create; end;
considering code posted far, can´t see problem. however, since know exact location of error, advice set breakpoint @ line in code , evaluate (ctrl+f7) member foitems see it.
usually, when suspect have bad object reference, evalute it´s classname (in case, foitems.classname). if reference invalid, method raises exception of returns strange name.
also, set breakpoint in constructor in order sure foitems indeed being instantiated.
i hope helps!
Comments
Post a Comment