Question about GtkWidget pointer?
- From: "David Wang (Wang Xin-lu)" <davidwang lucent com>
- To: gtk-list gnome org
- Subject: Question about GtkWidget pointer?
- Date: Wed, 31 Jul 2002 09:42:46 +0800
Hi,
I wrote a function to create menu:
void setupMenu(GtkWidget *window, GtkWidget *menu_bar, GtkWidget *menu_vbox,
GtkWidget *root_menu, GtkWidget *menu, char *labelname, gboolean boo)
{
if (menu_vbox == 0) {
menu_vbox = gtk_vbox_new(FALSE, 1);
gtk_container_border_width (GTK_CONTAINER(menu_vbox), 1);
gtk_container_add(GTK_CONTAINER (window), menu_vbox);
gtk_widget_show(menu_vbox);
printf("menu_vbox is 0\n");
printf("menu_vbox is %x\n", menu_vbox);
}
....
}
In the main function, I call it like this:
int main( int argc, char *argv[] )
{
...
GtkWidget *menu_vbox;
menu_vbox = 0;
...
setupMenu(window, menu_bar, menu_vbox,
root_menu, menu, "File", FALSE);
printf("after one menu_vbox is %x\n", menu_vbox);
..
}
I found that "menu_vbox" has value in setupMenu function, but it is "0" after
it.
If I call setupMenu more than 1 time, there has error:
: before menu_vbox is 0
menu_vbox is 0
menu_vbox is 3b090
menu_bar is 0
new root_menu with label
after one menu_vbox is 0
Gtk-CRITICAL **: file gtkbin.c: line 217 (gtk_bin_add): assertion `bin->child ==
NULL' failed.
menu_vbox is 0
menu_vbox is 3b320
menu_bar is 0
new root_menu with label
justify root_menu
after two menu_vbox is 0
why GtkWidget pointer can not take back value in a function?
How can I do if I want to use the value initialized in a function?
Thanks!
David
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]