GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Oct 21, 2014 7:06 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Ok, this is weird :\
PostPosted: Fri Jun 13, 2008 11:08 pm 
Offline
GTK+ Guru

Joined: Sun Apr 06, 2008 6:43 pm
Posts: 286
Location: Fortress of solitude
I got a warning:
Code:
void OnButton1Clicked(GtkWidget *widget, gpointer entry) {
   GtkWidget *Entry = GTK_WIDGET(entry);
   gchar *texto = (gchar*)gtk_entry_get_text(Entry); // line error
    g_print("%s\n", texto);
    g_free(texto);
}

The error is something about incompatible pointer, The function is called from:
Code:
entry1 = gtk_entry_new();
//...
g_signal_connect(G_OBJECT(button1), "clicked", G_CALLBACK(OnButton1Clicked), entry1);

The first time prints into the terminal correctly the inputed text, but 2nd time prints a tons of lines like
Quote:
double free or corruption (fasttop): 0x08097d78 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb78dba85]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb78df4f0]
/usr/lib/libglib-2.0.so.0(g_free+0x31)[0xb79fe8b1]
/usr/lib/libglib-2.0.so.0[0xb79f694e]

and so on... :cry:
Any ideas? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 11:53 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
it's because you're freeing texto.
see the "Returns:" section of this page to see what you can and can't do:
http://library.gnome.org/devel/gtk/stab ... y-get-text

as far as the warning about incompatible pointers, try passing '(gpointer)entry1' to g_signal_connect instead of 'entry1'


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 1:58 am 
Offline
GTK+ Guru

Joined: Sun Apr 06, 2008 6:43 pm
Posts: 286
Location: Fortress of solitude
dreblen wrote:
it's because you're freeing texto.
see the "Returns:" section of this page to see what you can and can't do:
http://library.gnome.org/devel/gtk/stab ... y-get-text

as far as the warning about incompatible pointers, try passing '(gpointer)entry1' to g_signal_connect instead of 'entry1'

Your the man!! Thanks :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group