Am 25.08.2010 15:46, schrieb Alexander Grau:
Sven Barth schrieb:
You can read this thread on the fpc-pascal list:
http://www.hu.freepascal.org/lists/fpc-pascal/2010-July/025939.html
Jonas has implemented a possibilty for external C threads to work, but
you need to use a SVN FPC and you need to create at least one thread
in FPC (it can terminate immediatly, it's just needed to initialise
the threading subsystem). (And this fix is *nix only)
If you read this thread carefully, you can notice that I already posted
this here in my first answer to Maik ;-)
That was on 3rd August... How am I supposed to remember this? :P
I also showed in a test program in a later post that this problem
doesn't seem to exist in the Win32 target, it was just the Darwin
target. Here's again the test program I wrote . I creates a non-FPC
thread and inside that thread it calls back a FPC funtion and object.
This fully works without crashes.
I looked at your example program and I also looked into FPC's Thread
implementation for Windows. You need to play around with the Heap a bit
more to make things interesting:
Modify someFunc like in the following and someObj.someMethod won't be
executed any more, because an exception is raised somewhere after the
second Writeln.
Regards,
Sven
procedure someFunc(param: pchar); cdecl;
var
t: TObject;
begin
WriteLn('External is called - ThreadID=', GetCurrentThreadId);
if assigned(param) then writeln('blub');
writeln('param=', param);
t := TObject.Create;
try
Writeln(t.ClassName);
finally
t.Free;
end;
// this point will not be reached
someObj.someMethod();
end;
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus