GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Oct 24, 2014 9:34 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Text View Complaining about Double Free or Corruption
PostPosted: Tue Feb 26, 2008 7:20 pm 
Offline

Joined: Tue Feb 26, 2008 7:05 pm
Posts: 1
Was wondering if anybody has any idea(s) why the code below would seem to work fine on GTK/X11 (at least I don't see any error messages), but fail on GTK/DirectFB? When the application is exited by hitting the "Quit" button, I receive the following error message:

*** glibc detected *** TextDemo: double free or corruption (out): 0x4035b1b0 ***

I'm trying to figure out if this is a GTK related problem (i.e., am I'm doing something wrong in GTK) or a problem with GTK/DirectFB. I have to assume that my code IS the problem, but I just don't see where / how.

The reason for doing the sample code this way is that I noticed this problem in my application which destroys the parent view which contains a text view and then re-uses the space for other widgets. The interesting thing is that if I disable the text view creation and only leave the 'Quit' button, the application exits just fine without any messages. I see the same behavior with my "real" application in that I can switch between different forms without any problems unless it contains a text view widget.

What am I doing wrong here?

Code:
#include "common.h"

GtkWidget* main_window;

static gboolean destroy_event(GtkWidget* widget, void* data)
{
       gtk_main_quit();
       return FALSE;
}

static void button_click_event(void)
{
       gtk_widget_destroy(main_window);
}

int main(int argc, char* argv[])
{
       GtkWidget *text_view, *box, *button;

       // initialize multi-threading within GLib
       g_thread_init(NULL);

       // initialize multi-threading within GDK
       gdk_threads_init();

       // acquire thread lock
       gdk_threads_enter();
       gtk_init(&argc, &argv);

       // create main window
       main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
       if (main_window == NULL)
               abort();
       g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(destroy_event), NULL);
       gtk_widget_show(main_window);

       box = gtk_vbox_new(FALSE, 5);
       if (box == NULL)
               abort();
       gtk_widget_show(box);
       gtk_container_add(GTK_CONTAINER(main_window), box);

       text_view = gtk_text_view_new();
       if (text_view == NULL)
               abort();
       gtk_widget_show(text_view);
       gtk_box_pack_start(GTK_BOX(box), text_view, TRUE, TRUE, 5);

       button = gtk_button_new_with_label("Quit");
       if (button == NULL)
               abort();
       g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_click_event), NULL);
       gtk_widget_show(button);
       gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 5);

       // run the main loop
       gtk_main();

       // release thread lock
       gdk_threads_leave();

       return 0;
}




Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group