signal referencing

From: BRUGUIER Nicolas <gandalfn_at_club-internet.fr>
Date: 18 Dec 2002 16:56:45 +0100

hi,

First, thank you for this great tools which is gob

I use gob 2.0.4 and i have a some troubles with ref and unref object
when I use signal,

I have an object who generate signal

class MyObject from G:Object
{
        private gchar * my_string
                destroy {
                        g_print("destroy");
                        g_free(my_string);
                };

        signal NONE (NONE)
        mysignal(self);

        public SELF *
        new(void)
        {
                ...
                selfp->my_string = g_strdup("my_string");
                ...
        }

        public void
        action(self)
        {
                ...
                self_mysignal(self);
                ...
        }
}

and an other who use this:

on_my_signal(MyObject * obj, gpointer user_data)
{
        my_signal = TRUE;
}

f()
{
        MyObject * obj = my_object_new();

        my_object_connect__mysignal(obj, on_my_signal, NULL);
        while (!my_signal);
        g_object_unref(obj);
}

the problem is when the signal is send MyObject is referenced, I saw it
with my favorite debugger.

Well, when I am in on_my_signal obj->ref_count = 2, OK I add
g_object_unref in end of on_my_signal but in this case if the signal
isn't connected the ref count it is always increase. The only solution i
found is decrease ref_count with g_object_unref after call the signal
generator.

My question what is the better solution or does have another solutions ?

thank you, in advance, and sorry for my english

Regards

-- 
BRUGUIER Nicolas <gandalfn_at_club-internet.fr>
Received on Wed Dec 18 2002 - 10:57:13 CST

This archive was generated by hypermail 2.2.0 : Sun Apr 17 2011 - 21:05:02 CDT