GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
FAQ
Search
Memberlist
Usergroups
Register
Profile
Log in to check your private messages
Log in
Ok, this is weird :\
GTK+ Forums Forum Index
->
GTK+ Programming
Author
Message
Joel
GTK+ Geek
Joined: 06 Apr 2008
Posts: 51
Location: Fortress of solitude
Posted: Fri Jun 13, 2008 11:08 pm
Post subject: Ok, this is weird :\
I got a warning:
Code:
(C)
1
2
3
4
5
6
7
8
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:
(C)
1
2
3
4
5
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.
Back to top
dreblen
Never Seen the Sunlight
Joined: 14 Jun 2007
Posts: 534
Location: Falun, WI USA
Posted: Fri Jun 13, 2008 11:53 pm
Post subject:
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/stable/GtkEntry.html#gtk-entry-get-text
as far as the warning about incompatible pointers, try passing '(gpointer)entry1' to g_signal_connect instead of 'entry1'
Back to top
Joel
GTK+ Geek
Joined: 06 Apr 2008
Posts: 51
Location: Fortress of solitude
Posted: Sat Jun 14, 2008 1:58 am
Post subject:
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/stable/GtkEntry.html#gtk-entry-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 :)
Back to top
Display posts from previous:
All Posts
1 Day
7 Days
2 Weeks
1 Month
3 Months
6 Months
1 Year
Oldest First
Newest First
GTK+ Forums Forum Index
->
GTK+ Programming
All times are GMT
Page
1
of
1
Powered by
phpBB
© 2001, 2005 phpBB Group
CodeBB
1.0 Beta 2
Protected by
Anti-Spam ACP