On Thu, 2008-12-11 at 15:56 +0000, Dan Higham wrote:
> Hello All,
>
> I am having some trouble getting my head round clutter threads. I seem
> to keep running in to the same problems when adding actors from a new
> thread. Please see my code below;
you *must* *not* call Clutter API from a thread that did not start the
main loop without acquiring the main thread lock; hence, this code:
> private bool addRect (int x, int y){
> Rectangle rect = new Rectangle(new Clutter.Color (0xff,
> 0x00, 0x00, 0xff));
> rect.SetPosition(x,y);
> rect.SetSize(50,50);
> Clutter.Threads.Enter();
> Clutter.Stage.Default.AddActor(rect);
> Clutter.Threads.Leave();
> return true;
> }
>
is completely wrong. the Threads.Enter() call should be done at the
beginning of the function.
in practice, though, there is also to factor in the interactions between
threads, GObject, Clutter and Mono threads, which might render the whole
point moot and prevent you from instantiating GObject classes from
another thread than the main thread.
to be safe and portable on different platforms, you should install an
idle handler inside your thread once you've performed the blocking call
and add the rectangle from the callback of the idle handler; this way
you'll be guaranteed to operate in the main thread.
ciao,
Emmanuele.
--
Emmanuele Bassi, Intel Open Source Technology Center
--
To unsubscribe send a mail to [EMAIL PROTECTED]