Re: BUG in gtk_list_store_set



Ok, i found the solution at my problem :-) lol
Owen, there is an error in the tutorial's example of GtkListStore. :-)

NUM_COLUMNS :-) was my problem, now it works.
On Tue, 2003-01-28 at 09:35, Stephane Wirtel wrote:
> Hi all !
> 
> I have a problem running my application, i get a segmentation fault with
> a gtk_list_store_set
> 
> my app uses a GtkTreeView with a GtkListStore, and, it crashes when i
> read the data from a simple struct ( this for my example ).
> 
> i used gdb, but i don't find the error in my code, but, i know where is
> this error. 
> 
> here is the function's code of create_model :
> static GtkTreeModel *create_model (void)
> {
> 	gint i = 0;
> 	GtkListStore *store;
> 	GtkTreeIter iter;
> 	store = gtk_list_store_new (
> 		NUM_COLUMNS, 
> 		G_TYPE_STRING, 
> 		G_TYPE_STRING);
> 	for (i = 0; i < G_N_ELEMENTS (data); i++) {
> 		gtk_list_store_append (store, &iter);
> 		gtk_list_store_set( 
> 			store, 
> 			&iter, 
> 			CONTACT_COLUMN_FIRSTNAME, 
> 			data[i].firstname, 
> 			CONTACT_COLUMN_LASTNAME, 
> 			data[i].lastname, 
> 			-1);
> 		}
> 	return GTK_TREE_MODEL (store);
> }
> 
> and here is the contains of my struct
> typedef struct 
> {
> 	gchar *firstname;
> 	gchar *lastname;
> 	gchar *street;
> 	gint number;
> 	gchar *location;
> 	gint zipcode;
> 	
> 	gchar *phone_gsm;
> 	gchar *phone_fix;
> 	gchar *email;
> 	gpointer photo;
> } Contact;
> 
> enum
> {
> 	CONTACT_COLUMN_FIRSTNAME, 
> 	CONTACT_COLUMN_LASTNAME,
> 	CONTACT_COLUMN_STREET,
> 	CONTACT_COLUMN_NUMBER,
> 	CONTACT_COLUMN_LOCATION,
> 	CONTACT_COLUMN_ZIPCODE,
> 	CONTACT_COLUMN_PHONE_GSM,
> 	CONTACT_COLUMN_PHONE_FIX,
> 	CONTACT_COLUMN_EMAIL,
> 	NUM_COLUMNS
> };
> 
> static Contact data[] = {
> {	"Stephane", "Wirtel",	"Rue XXX", 53, "charleroi", 9999,
> "0474/xx.yy.zz.vv", "071/xx.yy.zz",
> "stephane wirtel belgacom net",	NULL	}
> };
> 
> sorry, but i did not find the reason of this "Segmentation Fault", if
> anyone wants my code, it's available on
> http://www.linux-mons.be/download/gContacts.tar.bz2
> 
> Thanks
> 
> ----------------
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 




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