Re: Gtk-CRITICAL - getting meaningful information

2010-06-11 Thread Damien Caliste
Hello,

Le 11/06/2010, Mick bare...@tpg.com.au a écrit :
   object class=GtkTextView id=chat_view
 property name=visibleTrue/property
 property name=can_focusTrue/property
 property name=bufferchat_buffer/property
   /object
 GtkTextView *chat_view;
 GtkTextBuffer *chat_buffer;
 GtkTextIter start, end;
 GtkTextIter iter;
 
 main()
 {
 ...
 chat_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(chat_view));
 }
It seems to me that you never initialise the chat_view variable ? From
your code snippets, you give a value to the pointer chimp_window with
the call to gtk_builder_get_object(); but there's no chat_view = ...
I've never used gtkbuilder, but from what I've understand, you need to
get_object() on the ids (names) you gave in your XML to be able to
access them.

By the way, compile with -Wall, the compiler would have stop this
saying that your going to use chat_view without initialise it first
(I guess).

Damien.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Gtk-CRITICAL - getting meaningful information

2010-06-11 Thread Claudio Saavedra
On Fri, 2010-06-11 at 12:50 +1000, Mick wrote:
 Is there any way to get something meaningful that will point to a real
 world location. I assume the :2621 points to a location in the code
 but
 two successive compilations with the source unchanged (eg: make clean;
 make; make install; run; make clean; make; make install; run) results
 in a different number. 

The number after the process name is the PID, not the code line where
the crash happened.

If you want to find out where your critical warnings are coming from,
you can run your program under gdb and set the environment variable
G_DEBUG to fatal-criticals

 $ gdb myprogram
 gdb set env G_DEBUG=fatal-criticals
 gdb run

once it crashes,

 gdb backtrace


And you'll see where the crash happened by inspecting the stacktrace.

Then I would suggest reading a bit on the critical messages, usually
they are self-explanatories. For instance, 

  assertion `GTK_IS_TEXT_BUFFER (buffer)' failed

Means that buffer variable is not pointing to a GtkTextBuffer, which
either means that you already disposed it or that you never initialized
it to be one.

Claudio

-- 
Claudio Saavedra csaave...@gnome.org

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Gtk-CRITICAL - getting meaningful information

2010-06-10 Thread Mick
I've been using gtk for a while and frequently get messages like this:
(nuchimp2:2621): Gtk-CRITICAL **: gtk_text_view_get_buffer: assertion
`GTK_IS_TEXT_VIEW (text_view)' failed
some times I can stumble over the cause and solution but the rest of
the time I'm left to blindly grope around in the dark.

Is there any way to get something meaningful that will point to a real
world location. I assume the :2621 points to a location in the code but
two successive compilations with the source unchanged (eg: make clean;
make; make install; run; make clean; make; make install; run) results
in a different number.

I used glade to define the interface:
...
  object class=GtkWindow id=chimp_window
property name=title translatable=yesChimp for
chatmunkees/property property name=default_width640/property
property name=default_height400/property
property name=iconpixmaps/chimp2.xpm/property
signal name=destroy handler=gtk_main_quit/
child
  object class=GtkVBox id=vbox1
property name=visibleTrue/property
property name=orientationvertical/property
...
child
  object class=GtkNotebook id=notebook1
property name=visibleTrue/property
property name=can_focusTrue/property
child
  object class=GtkVBox id=vbox2
property name=visibleTrue/property
property name=orientationvertical/property
child
  object class=GtkHPaned id=hpaned1
property name=visibleTrue/property
property name=can_focusTrue/property
child
  object class=GtkTextView id=chat_view
property name=visibleTrue/property
property name=can_focusTrue/property
property name=bufferchat_buffer/property
  /object
  packing
property name=resizeTrue/property
property name=shrinkFalse/property
  /packing
/child
...
  /object
  packing
property name=position0/property
  /packing
/child
...
  object class=GtkTextTagTable id=chattexttagtable/
...
  object class=GtkTextBuffer id=chat_buffer
property name=tag_tablechattexttagtable/property
  /object
/interface
the code snippet this particular instance comes from is:

GtkTextView *chat_view;
GtkTextBuffer *chat_buffer;
GtkTextIter start, end;
GtkTextIter iter;

main()
{
...
chimp_window = GTK_WIDGET(gtk_builder_get_object(builder,
chimp_window)); gtk_builder_connect_signals(builder, NULL);  
gtk_widget_show(chimp_window);

chat_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(chat_view));
gtk_text_buffer_create_tag(chat_buffer, blue_fg, foreground,
blue, NULL); gtk_text_buffer_insert_with_tags_by_name(chat_buffer,
iter, Colored Text\n, -1, blue_fg, lmarg,  NULL); ...
}

which gives these:
(nuchimp2:2621): Gtk-CRITICAL **: gtk_text_view_get_buffer: assertion
`GTK_IS_TEXT_VIEW (text_view)' failed

(nuchimp2:2621): Gtk-CRITICAL **: gtk_text_buffer_create_tag: assertion
`GTK_IS_TEXT_BUFFER (buffer)' failed

(nuchimp2:2621): Gtk-CRITICAL **:
gtk_text_buffer_insert_with_tags_by_name: assertion `GTK_IS_TEXT_BUFFER
(buffer)' failed

the tarball of the package (the small part I've done so far) can be d/l
from http:/www.junkyardalchemy.org/nuchimp2-0.1.tar.gz in case I've
snipped something critical.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list