signal emit is wrong

From: Dennis Bjorklund <>
Date: Sat, 13 Apr 2002 11:20:37 +0200 (CEST)

In gtk2 signal emit and default value handling changed so the code
generated by gob2 is wrong. To set a default value yourself you can not
use g_signal_emit() but must use g_signal_emitv()

So instead of generating code like:

gint bla_bla_test_sig (Obj * self, gint a, gint b)
        gint return_val = (gint )(0);

        g_return_val_if_fail (self != NULL, (gint )0);
        g_return_val_if_fail (BLA_IS_BLA (self), (gint )0);

        g_signal_emit (G_OBJECT (self),
                object_signals[TEST_SIG_SIGNAL], 0,
                (gint )a,
                (gint )b,
        return return_val;

one must create a vector of GValue and generate something like:

gint bla_bla_test_sig (Obj * self, gint a, gint b)
        gint return_val = (gint )(42);

        GValue instance_and_params[3];
        GValue return_value;
        g_return_val_if_fail (self != NULL, (gint )0);
        g_return_val_if_fail (BLA_IS_BLA (self), (gint )0);

        instance_and_params[0].g_type = 0;
        g_value_init (&instance_and_params[0],
                      G_TYPE_FROM_INSTANCE (G_OBJECT(obj)));
        g_value_set_instance (&instance_and_params[0], obj);
        instance_and_params[1].g_type = 0;
        g_value_init (&instance_and_params[1], G_TYPE_INT);
        g_value_set_int (&instance_and_params[1], a);

        instance_and_params[2].g_type = 0;
        g_value_init (&instance_and_params[2], G_TYPE_INT);
        g_value_set_int (&instance_and_params[2], b);

        return_value.g_type = 0;
        g_value_init (&return_value, G_TYPE_INT);
        g_value_set_int (&return_value, return_val);

        g_signal_emitv (instance_and_params,
                        object_signals[TEST_SIG_SIGNAL], 0,

        return_val = g_value_get_int (&ret);

        return return_val;
Of course one could make it more beautiful by using macros or small help
functions to set the GValues in instance_and_params and return_value.

See also

I don't know gob2 enough to write this in 10 minutes and I don't have too
much time to spend on it right now, if no one else fixes it i'll probably
give it a shoot later on though. This should be easy to fix.

It would be nice if one could pass along the detail parameter to
g_signal_emitv() also.

ps. I'm I the only one on this list :-)

Received on Sat Apr 13 2002 - 05:20:37 CDT

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