Problem on gtk-sheet....
I am using gtk_sheet. I am getting some segmentation fault when I create a sheet repeatedly.... I am giving the code here....
When I run the below C-code it pops up the one main window and the sheet dialog the main window contains the button labelled Destroy & Create, which destroys the sheet dialog and creates a new sheet dialog for hundred times, when i keep on clicking the button it crashes at some point... My system specifications : OS: Linux Federo core 3 Kernel: 2.6.12-prep athlon i386 GNU/Linux gtk version : gtk2-2.4.13-9 gtk sheet package : gtk+extra-2.1.1 gcc version 3.4.2 please let me know what the mistake I am doing....., Thanks in advance #include<gtk/gtk.h> #include<stdlib.h> #include<stdio.h> #include<unistd.h> #include<gtkextra-2.0/gtkextra/gtksheet.h> GtkWidget *sheet_dialog_window; GtkWidget *sheet; /*Craets a sheet and packs to the dialog vbox*/ void create_sheet() { sheet_dialog_window=gtk_dialog_new(); gtk_widget_set_size_request(sheet_dialog_window,85 0,700); sheet=gtk_sheet_new(2,1,"PIVOT_SHEET"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(sheet_dialog _window)->vbox),sheet,TRUE,TRUE,0); gtk_widget_show_all(sheet_dialog_window); } /*Destroy's and create's the sheet for 100 times*/ void Destroy_and_create_callback(GtkWidget *w,gpointer d) { int i=0; for(i=1;i<=100;i++) { gtk_widget_destroy(sheet); gtk_widget_destroy(sheet_dialog_window); create_sheet(); printf("%d\n",i); } } int main(int argc,char *argv[]) { GtkWidget *w,*b; gtk_init(&argc,&argv); w=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (GTK_WIDGET (w), 400, 400); b=gtk_button_new_with_label("Destroy & Create"); g_signal_connect(b,"clicked",G_CALLBACK(Destroy_an d_create_callback),NULL); gtk_container_add(GTK_CONTAINER(w),b); create_sheet(); gtk_widget_show_all(w); g_signal_connect(w,"destroy",G_CALLBACK(gtk_main_q uit),NULL); gtk_main(); return 0; } |
It's possible that it isn't done with one of the destroy/create loops when you click on the button again. That's the only thing I can think of because I don't see anything else in your code that would cause that. You should disable the button at the beginning of 'Destroy_and_create_callback' and enable it again when it's complete.
ta0kira |
Is there any chance of memory problem in the gtk_sheet itself??? and in my code there is no need of 100 times loop if u destroy and create once then also it gives the segfault
|
All times are GMT -5. The time now is 12:56 PM. |