Re: emitting the "delete_event" in a "key_press_event" --> crash
- From: Olivier Sessink <olivier lx student wau nl>
- To: Owen Taylor <otaylor redhat com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: emitting the "delete_event" in a "key_press_event" --> crash
- Date: Thu, 07 Nov 2002 13:10:39 +0100
On Wed, 06 Nov 2002 16:15:33 -0500 (EST) "Owen Taylor"
<otaylor redhat com> wrote:
Small test case? Escape is automatically hooked up for GTK+ dialogs and
doesn't usually crash GTK+, so there must be something else going on
here.
(Bug report filed in bugzilla would be appreciated)
I don't know if the code is valid, so here is my testcase, if the code is
valid please let me know and I'll enter it as a bug.
/*
escape_testcase.c
compile with
gcc escape_testcase.c -o escape_testcase `pkg-config --cflags gtk+-2.0`
`pkg-config --libs gtk+-2.0` */
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
static void create_testwin();
static gboolean create_window_key_press_event_lcb(GtkWidget
*widget,GdkEventKey *event,GtkWidget *win) { if (event->keyval ==
GDK_Escape) { g_signal_emit_by_name(G_OBJECT(win), "delete_event");
/* gtk_widget_destroy(win);*/
return TRUE;
}
return FALSE;
}
GtkWidget *create_window(GCallback close_func,gpointer close_data) {
GtkWidget *returnwidget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(returnwidget), "delete_event", close_func,
close_data); g_signal_connect(G_OBJECT(returnwidget), "destroy",
close_func, close_data); g_signal_connect(G_OBJECT(returnwidget),
"key_press_event", G_CALLBACK(create_window_key_press_event_lcb),
returnwidget); return returnwidget;
}
typedef struct {
GtkWidget *win;
int various_other_data;
} TestWinStruct;
void testwin_destroy_cb(GtkWidget * widget, GdkEvent *event,
TestWinStruct *testwin) {
g_signal_handlers_destroy(G_OBJECT(testwin->win));
gtk_widget_destroy(testwin->win); g_free(testwin);
}
static void testwin_button_clicked_cb(GtkWidget *widget, gpointer data) {
create_testwin();
}
static void create_testwin() {
GtkWidget *button;
TestWinStruct *testwin;
testwin = g_new(TestWinStruct,1);
testwin->win = create_window(G_CALLBACK(testwin_destroy_cb), testwin);
button = gtk_button_new_with_label("create another testwin\n");
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(testwin_button_clicked_cb), NULL);
gtk_container_add(GTK_CONTAINER(testwin->win), button);
gtk_widget_show_all(testwin->win);}
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
create_testwin();
gtk_main();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]