On 26/06/10 11:37, pHilipp Zabel wrote: > On Sat, Jun 26, 2010 at 9:36 AM, Andrew <[email protected]> wrote: >> HI guys, >> >> Perhaps the simplest way to ask this is, could anyone tell me why when >> the attached file (Genie) is compiled and then run, do I get these error >> messages? >> >> (wasiliana:2710): Gtk-CRITICAL **: gtk_container_add: assertion >> `GTK_IS_CONTAINER (container)' failed >> (wasiliana:2710): GLib-GObject-WARNING **: invalid (NULL) pointer instance >> (wasiliana:2710): GLib-GObject-CRITICAL **: g_signal_connect_object: >> assertion `G_TYPE_CHECK_INSTANCE (instance)' failed > > I accidentally replied off-list, saying this is because the widgets > are created as local variables which are never assigned to the object > properties. > My first idea to fix this was just to assign to the properties directly: > > --- main.gs.orig 2010-06-26 12:04:28.061569285 +0200 > +++ main.gs 2010-06-26 12:18:32.577892738 +0200 > @@ -47,13 +47,13 @@ > this.delete_event.connect(on_mainwindow_delete_event) > > // Toolbar creation > - var scrolled_window = new ScrolledWindow(null, null) > + scrolled_window = new ScrolledWindow(null, null) > var vbox = new VBox(false, 0) > var toolbar_hbox = new HBox(true, 0) > - var toolbar = new Toolbar() > + toolbar = new Toolbar() > var back_button = new ToolButton.from_stock("gtk-go-back") > - var forward_button = new ToolButton.from_stock("gtk-go-forward") > - var location_entry = new Entry() > + forward_button = new ToolButton.from_stock("gtk-go-forward") > + location_entry = new Entry() > > //Toolbar Packing > toolbar.insert(back_button, -1) > > But that failed (after compilation with valac 0.8.0), because the > property assignment didn't increase the refcount on the widgets. > Is this a bug in the Genie code generator? Is it fixed in current versions? > For comparison, this is the C output for the scrolled_window setter method: > > void main_window_set_scrolled_window (MainWindow* self, > GtkScrolledWindow* value) { > g_return_if_fail (self != NULL); > self->priv->_scrolled_window = value; > g_object_notify ((GObject *) self, "scrolled-window"); > } > > And this is what I would have expected instead (and what I get from > vala 0.8.0 when compiling from a .vala source instead of from .gs > source): > > void main_window_set_scrolled_window (MainWindow* self, > GtkScrolledWindow* value) { > GtkScrolledWindow* _tmp0_; > g_return_if_fail (self != NULL); > self->priv->_scrolled_window = (_tmp0_ = _g_object_ref0 (value), > _g_object_unref0 (self->priv->_scrolled_window), _tmp0_); > g_object_notify ((GObject *) self, "scrolled-window"); > } > > regards > Philipp > _______________________________________________ > vala-list mailing list > [email protected] > http://mail.gnome.org/mailman/listinfo/vala-list
Yes, the first example gives the error: (wasiliana:1880): Gtk-CRITICAL **: gtk_box_pack: assertion `GTK_IS_WIDGET (child)' failed (wasiliana:1880): Gtk-CRITICAL **: gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed Could anyone help out here? -- Andrew _______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
