Hi, I created simple custom widget derived from dialog. But the program segfaults when I run gtk_dialog_run on it. I'm still learning gtk and I'm not sure how to trace the error. I'm attaching the source code and backtrace. Thanks, Jiri -- Jiri Pavlovsky jpavlovsky@mbox.dkm.cz tel: (+420) 737196433
/* login.h * widget to get username and password for db login */ #include <gtk/gtk.h> #include <gtk/gtkdialog.h> #include "login.h" enum { TICTACTOE_SIGNAL, LAST_SIGNAL }; /*static void login_class_init (LoginClass *klass);*/ static void login_init (Login *l); /*static void login_toggle (GtkWidget *widget, Login *l);*/ GType login_get_type (void) { static GType l_type = 0; if (!l_type) { static const GTypeInfo l_info = { sizeof (LoginClass), NULL, /* base_init */ NULL, /* base_finalize */ /*(GClassInitFunc) login_class_init,*/ NULL, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (Login), 0, (GInstanceInitFunc) login_init, }; l_type = g_type_register_static (GTK_TYPE_DIALOG, "Login", &l_info, 0); } return l_type; } /*static void login_class_init (LoginClass *klass) { }*/ static void login_init (Login *l) { GtkWidget *hbox1; GtkWidget *vbox1; GtkWidget *vbox2; GtkWidget *name_label; GtkWidget *passwd_label; vbox1 = gtk_vbox_new(FALSE, 2); vbox2 = gtk_vbox_new(FALSE, 2); hbox1 = gtk_hbox_new(FALSE, 2); gtk_window_set_destroy_with_parent(GTK_WINDOW(l), TRUE); gtk_window_set_position(GTK_WINDOW(l), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_modal(GTK_WINDOW(l), TRUE); gtk_window_set_title(GTK_WINDOW(l), "Login"); gtk_window_set_resizable(GTK_WINDOW(l), FALSE); l->name_entry = gtk_entry_new(); l->passwd_entry = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(l->passwd_entry), FALSE); gtk_dialog_add_buttons(GTK_DIALOG(l), GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); name_label = gtk_label_new("Username:"); passwd_label = gtk_label_new("Password:"); gtk_box_pack_start(GTK_BOX(vbox1), name_label, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox1), passwd_label, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox2), l->name_entry, TRUE, TRUE, 2); gtk_box_pack_start(GTK_BOX(vbox2), l->passwd_entry, TRUE, TRUE, 2); gtk_box_pack_start(GTK_BOX(hbox1), vbox1, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(hbox1), vbox2, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX (GTK_DIALOG (l)->vbox), hbox1, TRUE, TRUE, 0); gtk_widget_show(GTK_WIDGET(name_label)); gtk_widget_show(GTK_WIDGET(l->name_entry)); gtk_widget_show(GTK_WIDGET(passwd_label)); gtk_widget_show(GTK_WIDGET(l->passwd_entry)); gtk_widget_show(GTK_WIDGET(vbox1)); gtk_widget_show(GTK_WIDGET(vbox2)); gtk_widget_show(GTK_WIDGET(hbox1)); } GtkWidget* login_new () { return GTK_WIDGET (g_object_new (login_get_type(), NULL)); }
/* login.h * widget to get username and password for db login */ #ifndef __LOGIN_H__ #define __LOGIN_H__ #include <glib.h> #include <glib-object.h> #include <gtk/gtkdialog.h> G_BEGIN_DECLS #define LOGIN_TYPE (login_get_type ()) #define LOGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOGIN_TYPE, Login)) #define LOGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LOGIN_TYPE, LoginClass)) #define IS_LOGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOGIN_TYPE)) #define IS_LOGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LOGIN_TYPE)) typedef struct _Login Login; typedef struct _LoginClass LoginClass; struct _Login { GtkDialog dialog; GtkWidget *name_entry; GtkWidget *passwd_entry; }; struct _LoginClass { GtkDialogClass parent_class; void (* login) (Login *l); }; GType login_get_type (void); GtkWidget* login_new (void); void login_clear (Login *l); G_END_DECLS #endif /* __LOGIN_H__ */
#0 0x4207c45c in memcpy () from /lib/tls/libc.so.6 #1 0x41f7e857 in png_set_iCCP () from /usr/lib/libpng12.so.0 #2 0x41f81867 in png_handle_iCCP () from /usr/lib/libpng12.so.0 #3 0x41f890a6 in png_read_info () from /usr/lib/libpng12.so.0 #4 0x41f49b7f in _init () from /usr/lib/gtk-2.0/2.2.0/loaders/libpixbufloader-png.so #5 0x4030bb48 in _gdk_pixbuf_generic_image_load () from /usr/lib/libgdk_pixbuf-2.0.so.0 #6 0x4030bd7a in gdk_pixbuf_new_from_file () from /usr/lib/libgdk_pixbuf-2.0.so.0 #7 0x400dace9 in gtk_icon_set_copy () from /usr/lib/libgtk-x11-2.0.so.0 #8 0x400daf9b in gtk_icon_set_render_icon () from /usr/lib/libgtk-x11-2.0.so.0 #9 0x401e8678 in gtk_widget_render_icon () from /usr/lib/libgtk-x11-2.0.so.0 #10 0x400df12e in gtk_image_get () from /usr/lib/libgtk-x11-2.0.so.0 #11 0x400df152 in gtk_image_get () from /usr/lib/libgtk-x11-2.0.so.0 #12 0x403b8814 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #13 0x403a5247 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0 #14 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #15 0x403b720f in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #16 0x403b69a8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #17 0x403b6cc3 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #18 0x40144df3 in gtk_size_group_remove_widget () from /usr/lib/libgtk-x11-2.0.so.0 #19 0x4014518f in _gtk_size_group_compute_requisition () from /usr/lib/libgtk-x11-2.0.so.0 #20 0x401e3e0c in gtk_widget_size_request () from /usr/lib/libgtk-x11-2.0.so.0 #21 0x400d2d14 in gtk_hbox_new () from /usr/lib/libgtk-x11-2.0.so.0 #22 0x403b8814 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #23 0x403a5247 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0 #24 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #25 0x403b720f in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #26 0x403b69a8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #27 0x403b6cc3 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #28 0x40144df3 in gtk_size_group_remove_widget () from /usr/lib/libgtk-x11-2.0.so.0 #29 0x4014518f in _gtk_size_group_compute_requisition () from /usr/lib/libgtk-x11-2.0.so.0 #30 0x401e3e0c in gtk_widget_size_request () from /usr/lib/libgtk-x11-2.0.so.0 #31 0x4006d284 in gtk_alignment_set () from /usr/lib/libgtk-x11-2.0.so.0 #32 0x403b8814 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #33 0x403a5247 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0 #34 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #35 0x403b720f in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #36 0x403b69a8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #37 0x403b6cc3 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #38 0x40144df3 in gtk_size_group_remove_widget () from /usr/lib/libgtk-x11-2.0.so.0 #39 0x4014518f in _gtk_size_group_compute_requisition () from /usr/lib/libgtk-x11-2.0.so.0 #40 0x401e3e0c in gtk_widget_size_request () from /usr/lib/libgtk-x11-2.0.so.0 #41 0x40075342 in gtk_button_get_relief () from /usr/lib/libgtk-x11-2.0.so.0 #42 0x403b8814 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #43 0x403a5247 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0 #44 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #45 0x403b720f in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #46 0x403b69a8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #47 0x403b6cc3 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #48 0x40144df3 in gtk_size_group_remove_widget () from /usr/lib/libgtk-x11-2.0.so.0 #49 0x4014518f in _gtk_size_group_compute_requisition () from /usr/lib/libgtk-x11-2.0.so.0 #50 0x401e3e0c in gtk_widget_size_request () from /usr/lib/libgtk-x11-2.0.so.0 #51 0x400721f9 in _gtk_button_box_child_requisition () from /usr/lib/libgtk-x11-2.0.so.0 #52 0x400d27d9 in gtk_hbutton_box_get_layout_default () from /usr/lib/libgtk-x11-2.0.so.0 #53 0x403b8814 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #54 0x403a5247 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0 #55 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #56 0x403b720f in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #57 0x403b69a8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #58 0x403b6cc3 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #59 0x40144df3 in gtk_size_group_remove_widget () from /usr/lib/libgtk-x11-2.0.so.0 #60 0x4014518f in _gtk_size_group_compute_requisition () from /usr/lib/libgtk-x11-2.0.so.0 #61 0x401e3e0c in gtk_widget_size_request () from /usr/lib/libgtk-x11-2.0.so.0 #62 0x401dbbb4 in gtk_vbox_new () from /usr/lib/libgtk-x11-2.0.so.0 #63 0x403b8814 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #64 0x403a5247 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0 #65 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #66 0x403b720f in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #67 0x403b69a8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #68 0x403b6cc3 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #69 0x40144df3 in gtk_size_group_remove_widget () from /usr/lib/libgtk-x11-2.0.so.0 #70 0x4014518f in _gtk_size_group_compute_requisition () from /usr/lib/libgtk-x11-2.0.so.0 #71 0x401e3e0c in gtk_widget_size_request () from /usr/lib/libgtk-x11-2.0.so.0 #72 0x401f2e44 in gtk_window_reshow_with_initial_size () from /usr/lib/libgtk-x11-2.0.so.0 #73 0x403b8814 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #74 0x403a5247 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0 #75 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #76 0x403b720f in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #77 0x403b69a8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #78 0x403b6cc3 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #79 0x40144df3 in gtk_size_group_remove_widget () from /usr/lib/libgtk-x11-2.0.so.0 #80 0x4014518f in _gtk_size_group_compute_requisition () from /usr/lib/libgtk-x11-2.0.so.0 #81 0x401e3e0c in gtk_widget_size_request () from /usr/lib/libgtk-x11-2.0.so.0 #82 0x401f3dd1 in _gtk_window_unset_focus_and_default () from /usr/lib/libgtk-x11-2.0.so.0 #83 0x401f26ab in gtk_window_reshow_with_initial_size () from /usr/lib/libgtk-x11-2.0.so.0 #84 0x403b7d77 in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0 #85 0x403a5247 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0 #86 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #87 0x403b720f in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #88 0x403b69a8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #89 0x403b6be4 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 #90 0x401e2d48 in gtk_widget_show () from /usr/lib/libgtk-x11-2.0.so.0 #91 0x400b4948 in gtk_dialog_run () from /usr/lib/libgtk-x11-2.0.so.0 #92 0x0804a711 in menu_connect_callback (object=0x42706878, data=0x0) at callbacks.c:35 #93 0x403b7d77 in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0 #94 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #95 0x403b7983 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #96 0x403b69a8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #97 0x403b6be4 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 #98 0x401e58ed in gtk_widget_activate () from /usr/lib/libgtk-x11-2.0.so.0 #99 0x4010f682 in gtk_menu_shell_activate_item () from /usr/lib/libgtk-x11-2.0.so.0 #100 0x4010e8ff in _gtk_menu_shell_activate () from /usr/lib/libgtk-x11-2.0.so.0 #101 0x40107d6b in gtk_menu_reorder_child () from /usr/lib/libgtk-x11-2.0.so.0 #102 0x400ffc2f in _gtk_marshal_BOOLEAN__BOXED () from /usr/lib/libgtk-x11-2.0.so.0 #103 0x403a5247 in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0 #104 0x403a4ed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #105 0x403b7439 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0 #106 0x403b67af in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #107 0x403b6be4 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 #108 0x401e56fb in gtk_widget_send_expose () from /usr/lib/libgtk-x11-2.0.so.0 #109 0x400ffa27 in gtk_propagate_event () from /usr/lib/libgtk-x11-2.0.so.0 #110 0x400fe725 in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0 #111 0x402bd1a5 in _gdk_events_queue () from /usr/lib/libgdk-x11-2.0.so.0 #112 0x403fcb35 in g_get_current_time () from /usr/lib/libglib-2.0.so.0 #113 0x403fdb78 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0 #114 0x403fde8d in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0 #115 0x403fe58f in g_main_loop_run () from /usr/lib/libglib-2.0.so.0 #116 0x400fdf5f in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0 #117 0x0804d63a in main (argc=1, argv=0xbfffe2f4) at subscriptions.c:31 #118 0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6