LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-23-2007, 01:41 AM   #1
lkg
LQ Newbie
 
Registered: Aug 2006
Posts: 13

Rep: Reputation: 0
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;
}
 
Old 04-23-2007, 06:33 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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
 
Old 04-24-2007, 06:35 AM   #3
lkg
LQ Newbie
 
Registered: Aug 2006
Posts: 13

Original Poster
Rep: Reputation: 0
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

Last edited by lkg; 04-24-2007 at 06:38 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Music sheet program? enemorales Linux - Software 3 11-26-2005 10:49 PM
gtk+ 2.4.14 problem, how do I execute GTK? nautal Linux - Software 2 06-17-2005 07:09 PM
Scoring sheet music ? michaelsanford Linux - Software 5 05-10-2005 01:53 PM
Safari Style Sheet Problem atomicx Programming 2 05-03-2005 01:21 AM
Sheet Music software tyg Linux - Software 5 12-26-2003 11:38 AM


All times are GMT -5. The time now is 09:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration