[Glade-users] Problems with lookup_widget()

Magnus Wirström asdlinux@yahoo.se
Tue, 10 May 2005 17:14:01 +0200


söndagen den 8 maj 2005 21.32 skrev Magnus Wirström:
> Hi
>
> I have a problem with my app. I'm doing kinda lots of lookup_widget()
> commands and they work just fine. To save time i hav dublicated much of t=
he
> code. The thing is that I have a lookup_widget() that crashes my app but
> the duplicate dont, and i can't figure out why. The code looks like this:
>
> *crash here*	entry_widget = lookup_widget(GTK_WIDGET(button),
> "text_paket"); buffer = gtk_entry_get_text(GTK_ENTRY(entry_widget));
> 			strncat(post,buffer,cut_string(buffer));
> 			strncat(post,"\t",1);
>
> here is a sample of the code that does work just fine:
>
> 			entry_widget = lookup_widget(GTK_WIDGET(button), "text_personnummer"=
);
> 			buffer = gtk_entry_get_text(GTK_ENTRY(entry_widget));
> 			strncat(post,buffer,cut_string(buffer));
> 			strncat(post,"\t",1);
>
> Is there anyone that can help me figure out why i have this behaivour in =
my
> app. I would say also it was working before but suddenly stopped without
> any reason that i can give.
>
> Thanks for the help.
> Magnus
 Hi :)
 I have now found out that my problem occurs after i call a function i wrote, 
I am a novice in this so i might have done something stupid then i wrote it. 
It works as it intended but after calling it crashes the app at the next 
lookup_widget i use. Segment fault (11) is the result of the crash. here is 
the function:


-- Widget setup ---------------------------------------------------------
   comboboxentry1 = gtk_combo_box_entry_new_text ();
  gtk_widget_show (comboboxentry1);
  gtk_table_attach (GTK_TABLE (table3), comboboxentry1, 1, 3, 12, 13,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (GTK_FILL), 0, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), _("PN1000#BAS"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), 
_("PN1800#BAS/UTLAND"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), _("PK1000#UPP 
TILL 26"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), _("PK1800#UPP 
TILL 26/UTLAND"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), 
_("PN1330#KVÃ\204LL&HELG"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), 
_("PN1810#KVÃ\204LL&HELG/UTLAND"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), _("PN1450#DYGNET 
RUNT"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), _("PN1820#DYGNET 
RUNT/UTLAND"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), _("PN1770#KOMPIS 
0KR TILL FASTA NÃ\204T OCH TILL ALLA TELE2-MOBILER"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (comboboxentry1), 
_("PN1830#KOMPIS/UTLAND"));

--------------------------------------------------------------------------------------------------------------

char*
getcat	(GtkWidget *button)
{
	char *buffer;
	GtkWidget *entry_widget;
	gchar *string;
	
	entry_widget = lookup_widget(GTK_WIDGET(button), "comboboxentry1");
	string = gtk_combo_box_get_active_text((GtkComboBox*)entry_widget);
	
	strncpy(buffer,string,6);
	
	return(buffer);
}

Anyone see an error ??
Magnus