[Vala] buggy code gen



Trying to write a 'real' gtk app I have found a eally anoying bug that makes
the final program cry. It's related to the C code generation when I add a
signal to an object (a button). This is the code:

        private HButtonBox bottom_buttons()
        {
                HButtonBox hbb = new HButtonBox();
                hbb.set_layout(ButtonBoxStyle.END);
                Button b = new Button.from_stock("gtk-ok");
/*
                b.clicked += btn => {
                        stdout.printf("Stopped!\n");
                };
*/
                hbb.pack_start(b, false, false, 3);
                return hbb;
        }

What this code generates is:

The awesome return terciary conditional oneliner of 'a.c' looks crappy, but it is ok.
It works. The next second lines are unreachable. just trash.

The 'b.c' contains the code generated after the signal addition. The 'g' code is
ok, but the return becomes far more complex and just returns trash.
If I add an event to this button the generated code becomes somewhat buggy:

Mr.Diff says:

$ diff -u a.c b.c
--- a.c 2007-09-11 03:30:22.000000000 +0200
+++ b.c 2007-09-11 03:26:08.000000000 +0200
@@ -7,9 +7,12 @@
         hbb = g_object_ref_sink (gtk_hbutton_box_new ());
         gtk_button_box_set_layout (GTK_BUTTON_BOX (hbb), GTK_BUTTONBOX_END);
         b = g_object_ref_sink (gtk_button_new_from_stock ("stop"));
+        g_signal_connect_object (b, "clicked", ((GCallback) __lambda0), self, 0);
         gtk_box_pack_start (GTK_BOX (hbb), GTK_WIDGET (b), FALSE, FALSE, 3);
         _tmp0 = NULL;
-        return (_tmp0 = hbb, (b == NULL ? NULL : (b = (g_object_unref (b), NULL))), _tmp0); 
+        return (_tmp0 = hbb, (hbb == NULL ? NULL : (hbb = (g_object_unref (hbb), NULL))), (b == NULL ? NULL 
: (b = (g_object_unref (b), NULL))), _tmp0);
         (hbb == NULL ? NULL : (hbb = (g_object_unref (hbb), NULL)));
         (b == NULL ? NULL : (b = (g_object_unref (b), NULL)));
}    

The problem is that when we add a signal to a button it is unreferenced before the end of
the function (g_object_unref(hbb)) and it shouldn't. The g_object_unref(b) it's ok, so the
button works. But hbb doesn't.

Why is it unreferenced?

  --pancake




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]