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

Text View Complaining about Double Free or Corruption



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., I'm
doing something wrong with GTK) or a problem with GTK/DirectFB. Thanks
in advance for any suggestions / help.

[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;
}


[/code]

-- 
Mark


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