Re: Emitting a signal leads to a failed assertion




On Nov 2, 2007, at 9:37 AM, Ari Jolma wrote:

GLib-GObject-CRITICAL **: g_object_notify: assertion `G_IS_OBJECT
(object)' failed

The system is a bit too large to create a test code quickly.

A good starting point is the following procedure. It will work better if you have a local debug build of gtk+ and gobject (e.g., jhbuild), but that isn't strictly required just to get a stack trace.

First, start gdb on perl. gdb should find perl in your path, just fine, but if you need a specific perl or specific environment, set it up before invoking gdb.

  $ gdb perl

Once inside gdb, you can run the program; you have to tell perl about your script on the command line. Just replace "perl" with "run". MOST IMPORTANT: add the argument --g-fatal-warnings to your script! This will cause g_log() to call abort() on warnings, which will dump you back into the debugger.

  (gdb) run myscript --g-fatal-warnings otherargs...
... do stuff, when the CRITICAL comes out, you'll be dropped back to gdb.

Now you can get a backtrace and find out where the CRITICAL came from.

  (gdb) backtrace

The "assertion `G_IS_OBJECT (object)'" undoubtedly came from a "g_return_if_fail (G_IS_OBJECT (object))" down in libgobject, but it's the frames above (below, depending on how you look at it) that are what we're interested in.



The  essentials are:

Well, i'm not sure, but i think i see it.


sub my_inits { # another question is why can't I do these in INIT_INSTANCE
   my($self) = @_;
   my $hs = $self->get_hscrollbar();
   $hs->signal_connect("value-changed" => \&value_changed, $self);
}

You can't do those calls in INIT_INSTANCE() because the properties likely haven't been given values yet at INIT_INSTANCE() time. Depending on the scroll policy, they might not be created at all. (Haven't inspected the code to say...)

However, you don't want to connect directly to the ScrolledWindow's scrollbar, anyway. The scrollbars are combination view-and- controllers. The horizontal and vertical adjustments are what you actually want. ScrolledWindow communicates with the scrollee through the adjustments; you can programatically control the scrolling with the adjustments; etc, etc, etc.


--
The one difference between Dali and a crazy man is very simple: Dali is not crazy at all.
  -- Salvador Dali





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