Re: Segmentation Fault [Newbie]
- From: Larry Reaves <larry yrral net>
- To: Sulabh Bista <sul4bh gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Segmentation Fault [Newbie]
- Date: Thu, 30 Oct 2008 04:35:18 -0400
Running through gdb, we can see it crashes on this line:
gtk_container_add(GTK_CONTAINER(window),menu_bar);
glancing through the code, this makes perfect sense because window is
never initialized. The pointer window points to some random address.
Adding:
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
somewhere before gtk_container_add will fix your segfault.
Good luck,
Larry Reaves
On Thu, 2008-10-30 at 09:46 +0545, Sulabh Bista wrote:
#include <gtk/gtk.h>
int main(int argc, char **argv)
{
GtkWidget *window;
GtkWidget *file_menu_box;
GtkWidget *Server;
GtkWidget *Client;
GtkWidget *Quit;
GtkWidget *File;
GtkWidget *menu_bar;
gtk_init (&argc,&argv);
menu_bar=gtk_menu_bar_new();
file_menu_box=gtk_menu_new();
File=gtk_menu_item_new_with_label("File");
Server=gtk_menu_item_new_with_label("Server");
Client=gtk_menu_item_new_with_label("Client");
Quit=gtk_menu_item_new_with_label("Quit");
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu_box),Server);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu_box),Client);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu_box),Quit);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(File),file_menu_box);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar),File);
gtk_container_add(GTK_CONTAINER(window),menu_bar);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]