Re: lookup_widget problems



On Tue, 2003-06-10 at 19:13, Karl Lattimer wrote:
Hi, i've just started using glade. I'm finding it quite easy to use
apart from a problem i'm having in a callback function.

The problem is as follows.

I created a signal handler as follows

Signal: Clicked
Handler: on_b_calendarOk_clicked
Object: w_calendar

NOTE: Without object set to w_calendar the program segfaulted at
lookup_widget.

I then wrote the code for the function as follows

void
on_b_calendarOk_clicked                (GtkButton       *button,
                                        gpointer         user_data)
{
  GtkWidget *w_calendar;

  w_calendar = lookup_widget(GTK_WIDGET (w_calendar), "w_calendar");
  gtk_widget_hide(w_calendar);
}

This looks wrong - you are passing an uninitialised pointer to
lookup_widget. It should be:

w_calendar = lookup_widget(GTK_WIDGET (button), "w_calendar");

Of course you should be using libglade anyway rather than generated code
really....

This worked fine, hiding the calendar window (w_calendar) when the OK
button was clicked.

I'm not sure how, that code shouldn't work...... 

-- 
Mike Hearn <m hearn signal qinetiq com>
QinetiQ - Malvern Technology Center




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