Re: Text View Complaining about Double Free or Corruption




On Tue, 2008-02-26 at 20:51 -0500, Mark Rodriguez wrote:

James,

 I'm not sure what in your #include "common.h", but I placed the following
in mine

 #include <stdlib.h>  /* for abort() */
 #include <gtk/gtk.h> /* for gtk, gdk, and glib */

I have a few other things, but these are included and the app also
build fine for me. I can even run it under Ubuntu and it behaves
exactly as I'd expect. It was pointed ou
 With that single change the program compiled and executed without error
message; as I would have expected.

Thanks for taking to time to respond.

I too can compile and run the application without any problems under
Ubuntu; however, when I run the same application cross compiled under
DirectFB/GTK, it complains about double free / corruption. It was
pointed out the my destroy handler should actually be defined to
return void, but this didn't seem to affect anything.


The "destroy" handler is an GObject handler that is signaled almost as
the last logical breath before the object is removed from active memory.
I can see no problem using this shutdown method and I have used the same
method in 10s of multi-threaded programs.

This might be worth a try.
     g_signal_connect (G_OBJECT (main_window), "destroy", G_CALLBACK
(gtk_main_quit), NULL); 
i.e. take the fastest way out, reducing stack overhead.


The crazy thing is that I only get this error when adding a text view.
All other widgets (buttons, pop-ups, labels, sliders, etc.) seem to
work just fine. Is there anything different about a text view and
calling gtk_widget_destroy on it's parent? Should I destroy the text
view explicitly instead of relying on the parent to clean things up?
Perhaps I should handle things myself and follow some "special" or
"preferred" order when destroying the text view within the window?

No special or preferred method that I am aware of, and I use text_view all the time.  Contextually, your 
problem must should be related to your Direct/FB setup, rather than GTK internals.  However, I am not an 
expert just an experienced long time user.

When doe s the error occur? 
0. When program starts
1. When shutting down
2. When creating the text_view the first time
3. When creating the text_view the Nth time

I will assume it happens durin shutdown (#1).


I assume the text view can be handled just like any other widget, but
there appears to be something special or different about it.

Yes, it should be handled like any other widget.  The only special thing is its text_buffer!  Consider 
gtk_text_view_new_with_buffer(), one is created automatically for when using the gtk_text_view_new() api.  I 
don't think creating the GtkTextBuffer first would make any difference -- however, that where you are now.  
So try creating the GtkTextBuffer first, then use the ...with_buffer() api to create the view.  This may 
produce a different result.

If all else fails, try using gdb to get a backtrace to see which
modules/api generated that error message.

Again, thanks.



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