Re: emitting the delete_event...



Hi all,

I want my dialogs to close when the user presses the escape key. So I
attached to the key_press_event, and if the key is escape I emit the
delete event. Immediately the delete event destroys the window, and then
the programs continues with the key-press-event (on a widget that doesn't
exist anymore!!) and crashes (tha backtrace says it segfaults somewhere
inside gtk).

I suspect you need to add gtk_widget_destroy (dialog);
inside the delete_event callback. For example:

void function_destroy (GtkWidget *widget, gpointer data)
{
GtkWidget *dialog = (GtkWidget *) data;

gtk_widget_destroy (dialog);
}

void function_delete (GtkWidget *widget,
GdkEventButton *event, gpointer data)
{
function_destroy (widget, data);
}

connect function_delete (3 arg) to WM decoration
and function_destroy (2 arg) to buttons, etc...

Carlos



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