What am I doing wrong?



Ok, I've got the following function I use to enable
or disable a menu item. However, it's causing my
program to segfault on startup and quit depending on
what I do. Here's my code.

void change_menu_item_state(GtkItemFactory *menu, gchar *path, gboolean
state) 
{
   GtkWidget *tmp;
   gchar *newpath;

   /* This is necessary because gtk_item_factory_get_widget() *
    * does not like underscores. So we rip 'em out.           */
   while((*newpath = *path++) != '\0')
   {
      if(*newpath != '_')
      {
         newpath++;
      }
   }
   
/*   printf("--%s--\n", newpath); */
   tmp = gtk_item_factory_get_widget(menu, newpath);
   gtk_widget_set_sensitive(tmp, state);
}

If I uncomment the printf(), my program segfaults
right when I start the program. If I keep it commented,
I can run the program, but then it segfaults right
when I quit. What am I doing wrong? It's probably
something trivial that has to do with memory allocation,
but I'm stil pretty new at that.

-- 
+-----------------------------------------------------+
| Jeff "Shippy" Shipman     E-Mail: shippy@cs.nmt.edu |
| Computer Science Major    ICQ: 1786493              |
| New Mexico Institute of Mining and Technology       |
| Homepage: http://www.nmt.edu/~shippy                |
+-----------------------------------------------------+



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