[fpc-pascal] Sigsegv with refcounting interface
Joao Morais
jcmoraisjr at gmail.com
Thu Mar 7 23:38:48 CET 2013
On Thu, Mar 7, 2013 at 9:27 AM, José Mejuto <joshyfun at gmail.com> wrote:
>
> Hello,
>
> AFAIK you are casting a IUnknown to iintf instead requesting the iintf
> interface. I think the right procedure should be:
>
> v1 := vintf[0] as iintf;
Hello, thanks for your reply.
You are right, changing to a safe typecast, don't know exactly why,
works flawlessly. Anyway the following code reproduce the exact
problem I have here. The 'sucess!' message isn't called.
Using 2.6.2 and 2.7.1 (2013/03/03)
Joao Morais
=============
program project1;
{$mode objfpc}{$H+}
uses
heaptrc,
sysutils,
Classes;
var
vintfl: TInterfaceList;
procedure addintf(const aintf: IUnknown);
begin
if vintfl.IndexOf(aintf) = -1 then
vintfl.Add(aintf);
end;
begin
vintfl := TInterfaceList.Create;
try
writeln('starting...');
addintf(TInterfacedObject.Create);
writeln('success!');
finally
FreeAndNil(vintfl);
end;
end.
More information about the fpc-pascal
mailing list