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;

// clutter_thread_test.cs created with MonoDevelop
// User: danhigham at 15:30 10/12/2008
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//

using System;
using System.Threading;
using Clutter;

namespace clutter_thread_test
{
        
        
        public class clutter_thread_test
        {

                static void HandleKeyPress (object o, KeyPressEventArgs args)
                {
                        KeyEvent _event = args.Event;
                        
                        switch ((int)_event.HardwareKeycode)
                        {
                        case 9 : //esc
                                Clutter.Main.Quit();
                                break;
                        }
                }
                
                public clutter_thread_test()
                {
                }
                
                public void start_threads()
                {
                        for (int x = 0; x < 10; x++){   
                                addRect(x * 100, x * 100);
                                Thread.Sleep(100);

                        }
                        
                        
                        for (int x = 0; x < 10; x++){   
                                addRect(x * 100, 100);
                                Thread.Sleep(100);

                        }
                        /*
                        int z=0;
                        while(z<10){
                                //addRect(z * 100, 100);
                                z++;
                        }
                        */
                        //addRect(300, 50);
                }
                
                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;
                }
                
                static void Main () {
                        if (!GLib.Thread.Supported)
                                GLib.Thread.Init ();                    
                        
                        Clutter.Threads.Init ();
                        
                        ClutterRun.Init ();

                        Stage stage = Stage.Default;
                        stage.SetSize(800,600);
                                        
                        clutter_thread_test test = new clutter_thread_test();   
                                                        

                        stage.ShowAll ();
                        stage.KeyPressEvent += HandleKeyPress;
                        
                        Thread oThread = new Thread(new 
ThreadStart(test.start_threads));
                        //oThread.IsBackground = true;
                        oThread.Start();
                        
                        ClutterRun.Main ();
                        
                }
        }
}

Whenever I run this, it seems ok but shortly after all the actors are
added I get the following errors;

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance of invalid non-instantiatable type
`<invalid>'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance of invalid non-instantiatable type
`<invalid>'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance of invalid non-instantiatable type
`<invalid>'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **:
/build/buildd/glib2.0-2.18.2/gobject/gsignal.c:2916: signal id `4' is
invalid for instance `0xa360328'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **:
/build/buildd/glib2.0-2.18.2/gobject/gsignal.c:2916: signal id `4' is
invalid for instance `0xa360260'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **:
/build/buildd/glib2.0-2.18.2/gobject/gsignal.c:2916: signal id `4' is
invalid for instance `0xa360198'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **:
/build/buildd/glib2.0-2.18.2/gobject/gsignal.c:2916: signal id `4' is
invalid for instance `0xa3604b8'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **:
/build/buildd/glib2.0-2.18.2/gobject/gsignal.c:2916: signal id `4' is
invalid for instance `0xa3603f0'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **:
/build/buildd/glib2.0-2.18.2/gobject/gsignal.c:2916: signal id `4' is
invalid for instance `0xa360710'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance of invalid non-instantiatable type
`<invalid>'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_emit_valist: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance of invalid non-instantiatable type
`<invalid>'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **: instance of invalid non-instantiatable type
`<invalid>'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion
`G_TYPE_CHECK_INSTANCE (instance)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **:
/build/buildd/glib2.0-2.18.2/gobject/gsignal.c:2916: signal id `4' is
invalid for instance `0xa3750c8'

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
Clutter-CRITICAL **: clutter_actor_unrealize: assertion
`CLUTTER_IS_ACTOR (self)' failed

(/home/danhigham/Projects/mono/clutter_thread_test/bin/Debug/clutter_thread_test.exe:9043):
GLib-GObject-WARNING **:
/build/buildd/glib2.0-2.18.2/gobject/gsignal.c:2916: signal id `4' is
invalid for instance `0xa375000'

Any help on this would be most appreciated as I have been struggling
with it for a couple of days now to no avail.

Thanks and kind regards

-- 
Dan Higham
-- 
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to