popup menu causes crash

Dick Middleton (dick@sqf.hp.com)
Thu, 15 May 1997 11:21:46 +0100

To subscribers of the xforms list from Dick Middleton <dick@sqf.hp.com> :

Hello,

I'm having some difficulty with popup menus. I don't know whether
it's my programming error or a bug. It would be nice if an expert could look
at it.

I copied bits from the demo program pup to make this. What I find is if the
form with the menu:

is shown
menu selected
form hidden
form shown again
menu selected again

then the program terminates with BadDrawable in X_GetGeometry:

X Error of failed request: BadDrawable (invalid Pixmap or Window parameter)
Major opcode of failed request: 14 (X_GetGeometry)
Resource id in failed request: 0x780003d
Serial number of failed request: 1141
Current serial number in output stream: 1141

The dependencies seem to be that the menu be selected and hidden. When it is
selected the second time it fails.

The code, which provokes the problem, is for setting up the popup menu:

mm = fl_newpup(fl_default_win());
smm = fl_newpup(0);
fl_setpup_bw(mm, -2); /* soft edge */
fl_setpup_shadow(mm, 0); /* no shaddow */
fl_setpup_bw(smm, -2); /* soft edge */
fl_setpup_shadow(smm, 0); /* no shaddow */

fl_addtopup(mm, "Restore|Save%m|Clear|Close", smm);

fl_addtopup(smm,"Assoc|Task");
fl_set_menu_popup(fd_menu->popup, mm);

I attach the full code for a demo in case it needs investigating. I'm using
hpux 9.07 on s700.

Dick

--

dick@sqf.hp.com

#---------------------------------- cut here ---------------------------------- # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by Dick Middleton <dick@hpqt0008> on Thu May 15 11:19:54 1997 # # This archive contains: # debug.c crash.c crash.h # # Modification/access file times will be preserved. # Error checking via wc(1) will be performed.

LANG=""; export LANG PATH=/bin:/usr/bin:$PATH; export PATH

echo x - debug.c cat >debug.c <<'@EOF' #include "forms.h" #include "crash.h"

FD_main *fd_main; FD_menu *fd_menu;

/* callbacks for form main */ void mainCB(FL_OBJECT *ob, long data) { switch (data) { case 0: /* quit */ exit(0); break; case 1: /* show */ fl_show_form(fd_menu->menu, FL_PLACE_GEOMETRY, FL_TRANSIENT, "Menu Form"); break; } }

/* callbacks for form menu */ void menuCB(FL_OBJECT *ob, long data) { switch (data) { case 1: /* hide */ fl_hide_form(fd_menu->menu); break; case 2: /* menu */ break; }

}

int main(int argc, char *argv[]) { int mm; int smm;

fl_initialize(&argc, argv, 0, 0, 0); fd_main = create_form_main(); fd_menu = create_form_menu();

mm = fl_newpup(fl_default_win()); smm = fl_newpup(0); fl_setpup_bw(mm, -2); /* soft edge */ fl_setpup_shadow(mm, 0); /* no shaddow */ fl_setpup_bw(smm, -2); /* soft edge */ fl_setpup_shadow(smm, 0); /* no shaddow */ fl_addtopup(mm, "Restore|Save%m|Clear|Close", smm); fl_addtopup(smm,"Assoc|Task"); fl_set_menu_popup(fd_menu->popup, mm);

/* show the first form */ fl_show_form(fd_main->main,FL_PLACE_CENTER,FL_FULLBORDER,"main form"); fl_do_forms(); return 0; }

@EOF set `wc -lwc <debug.c` if test $1$2$3 != 611421210 then echo ERROR: wc results of debug.c are $* should be 61 142 1210 fi

touch -m 0515102597 debug.c touch -a 0515111797 debug.c chmod 644 debug.c

echo x - crash.c cat >crash.c <<'@EOF' /* Form definition file generated with fdesign. */

#include "forms.h" #include <stdlib.h> #include "crash.h"

FD_main *create_form_main(void) { FL_OBJECT *obj; FD_main *fdui = (FD_main *) fl_calloc(1, sizeof(*fdui));

fdui->main = fl_bgn_form(FL_NO_BOX, 120, 90); obj = fl_add_box(FL_UP_BOX,0,0,120,90,""); obj = fl_add_button(FL_NORMAL_BUTTON,20,10,80,30,"Show"); fl_set_object_callback(obj,mainCB,1); obj = fl_add_button(FL_NORMAL_BUTTON,20,50,80,30,"Quit"); fl_set_object_callback(obj,mainCB,0); fl_end_form();

fdui->main->fdui = fdui;

return fdui; } /*---------------------------------------*/

FD_menu *create_form_menu(void) { FL_OBJECT *obj; FD_menu *fdui = (FD_menu *) fl_calloc(1, sizeof(*fdui));

fdui->menu = fl_bgn_form(FL_NO_BOX, 100, 90); obj = fl_add_box(FL_UP_BOX,0,0,100,90,""); fdui->popup = obj = fl_add_menu(FL_PULLDOWN_MENU,20,10,60,30,"Menu"); fl_set_object_boxtype(obj,FL_FLAT_BOX); fl_set_object_callback(obj,menuCB,2); obj = fl_add_button(FL_NORMAL_BUTTON,20,50,60,30,"Hide"); fl_set_object_callback(obj,menuCB,1); fl_end_form();

fdui->menu->fdui = fdui;

return fdui; } /*---------------------------------------*/

@EOF set `wc -lwc <crash.c` if test $1$2$3 != 45891201 then echo ERROR: wc results of crash.c are $* should be 45 89 1201 fi

touch -m 0515104597 crash.c touch -a 0515111797 crash.c chmod 644 crash.c

echo x - crash.h cat >crash.h <<'@EOF' #ifndef FD_main_h_ #define FD_main_h_ /* Header file generated with fdesign. */

/**** Callback routines ****/

extern void mainCB(FL_OBJECT *, long);

extern void menuCB(FL_OBJECT *, long);

/**** Forms and Objects ****/

typedef struct { FL_FORM *main; void *vdata; long ldata; } FD_main;

extern FD_main * create_form_main(void); typedef struct { FL_FORM *menu; void *vdata; long ldata; FL_OBJECT *popup; } FD_menu;

extern FD_menu * create_form_menu(void);

#endif /* FD_main_h_ */ @EOF set `wc -lwc <crash.h` if test $1$2$3 != 3066494 then echo ERROR: wc results of crash.h are $* should be 30 66 494 fi

touch -m 0515104597 crash.h touch -a 0515104697 crash.h chmod 644 crash.h

exit 0 _________________________________________________ To unsubscribe, send the message "unsubscribe" to xforms-request@bob.usuf2.usuhs.mil or see http://bob.usuf2.usuhs.mil/mailserv/xforms.html Xforms Home Page: http://bragg.phys.uwm.edu/xforms List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/xforms-archive/