GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 23, 2014 5:58 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: const char* as widget name?
PostPosted: Sun Aug 10, 2014 3:50 pm 
Offline
Familiar Face

Joined: Sun Aug 10, 2014 1:44 pm
Posts: 6
Hello.

I have 32 buttons. So I decided to use it in one function, it's better than 32 functions. ;) So I named them like

GtkWidget * button32;
gtk_widget_set_name(button32, "button32");

etc.

And then

Code:
void foo( GtkWidget * widget )
{
    const char * sfoo;
    sfoo = gtk_widget_get_name( widget );
    gtk_container_remove( GTK_CONTAINER( grid ), GTK_WIDGET( sfoo ) );
}


It compiles so it should work but app crashes. Any solutions?


Top
 Profile  
 
 Post subject: Re: const char* as widget name?
PostPosted: Wed Aug 13, 2014 5:34 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 764
Location: UK
Hello,

The function proto-type for gtk_container_remove () is -
Code:
void                gtk_container_remove                (GtkContainer *container,
                                                         GtkWidget *widget);

You are calling it with the second argument that is a char pointer. This is the most likely cause of your error.

_________________
E.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 3 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group