Hindsight, schmindsight, but here is another question:

Where does the call queued from a thread, return to ?

As in, the thread calls Queue() on a method of the
object we're interested in; and that in turn calls
a method / procedure more like / from the 'main form' unit.

The object's lifetime is controlled by the dedicated thread
(meaning only one thread is allowed to Free() it);

But when, during the course of Queue()d callback,
I FreeAndNil() the object that had the pointer to the callback procedure, I get SIGSEGV pointing at CheckSynchronize in Application. (address F0F0F0F0).

I guess, easiest way to avoid this, is 'don't do that', so i did, and
the SIGSEGV went away.

Hence the question is, how can I know it is safe to free the object,
that has the callback subscribed to it?
One of the ways would be, to have a flag in that object, that the
callback proc will set, and so the thread will know it's now safe to
Free(andNil)() it.

But are there any other, better?

Thanks in advance,
-L.

On 14-Jun-17 14:01, Lukasz Sokol via Lazarus wrote:
On 14/06/17 11:33, Mattias Gaertner via Lazarus wrote:
On Wed, 14 Jun 2017 11:12:11 +0100
Lukasz Sokol via Lazarus <lazarus@lists.lazarus-ide.org> wrote:

[...]
       SomeClassLockedList := SomeClassList.LockedList; // there are 
try/excepts around all here, but did not want to muddle the picture
       Queue(TSomeClass(SomeClassLockedList.Items[i]).Processed);

Queue(@TSomeClass(SomeClassLockedList.Items[i]).Processed);
       ^

Mattias


Thanks! looks so easy in hindsight ;) same the callbacks need to be assigned 
with the @ in front :)

-L.



--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to