Call winit() here instead of in main initialization.

This commit is contained in:
Guido van Rossum 1991-02-19 12:26:49 +00:00
parent 7f133ed073
commit 2d14e21382
1 changed files with 16 additions and 10 deletions

View File

@ -751,8 +751,9 @@ static typeobject Texttype = {
/* Menu objects */ /* Menu objects */
#define MAXNMENU 50 #define IDOFFSET 10 /* Menu IDs we use start here */
static menuobject *menulist[MAXNMENU]; /* Slot 0 unused */ #define MAXNMENU 20 /* Max #menus we allow */
static menuobject *menulist[MAXNMENU];
static menuobject * static menuobject *
newmenuobject(title) newmenuobject(title)
@ -761,19 +762,19 @@ newmenuobject(title)
int id; int id;
MENU *menu; MENU *menu;
menuobject *mp; menuobject *mp;
for (id = 1; id < MAXNMENU; id++) { for (id = 0; id < MAXNMENU; id++) {
if (menulist[id] == NULL) if (menulist[id] == NULL)
break; break;
} }
if (id >= MAXNMENU) if (id >= MAXNMENU)
return (menuobject *) err_nomem(); return (menuobject *) err_nomem();
menu = wmenucreate(id, getstringvalue(title)); menu = wmenucreate(id + IDOFFSET, getstringvalue(title));
if (menu == NULL) if (menu == NULL)
return (menuobject *) err_nomem(); return (menuobject *) err_nomem();
mp = NEWOBJ(menuobject, &Menutype); mp = NEWOBJ(menuobject, &Menutype);
if (mp != NULL) { if (mp != NULL) {
mp->m_menu = menu; mp->m_menu = menu;
mp->m_id = id; mp->m_id = id + IDOFFSET;
mp->m_attr = NULL; mp->m_attr = NULL;
menulist[id] = mp; menulist[id] = mp;
} }
@ -789,8 +790,8 @@ menu_dealloc(mp)
menuobject *mp; menuobject *mp;
{ {
int id = mp->m_id; int id = mp->m_id - IDOFFSET;
if (id >= 0 && id < MAXNMENU) { if (id >= 0 && id < MAXNMENU && menulist[id] == mp) {
menulist[id] = NULL; menulist[id] = NULL;
} }
wmenudelete(mp->m_menu); wmenudelete(mp->m_menu);
@ -1373,9 +1374,9 @@ stdwin_get_poll_event(poll, args)
e.u.where.mask); e.u.where.mask);
break; break;
case WE_MENU: case WE_MENU:
if (e.u.m.id >= 0 && e.u.m.id < MAXNMENU && if (e.u.m.id >= IDOFFSET && e.u.m.id < IDOFFSET+MAXNMENU &&
menulist[e.u.m.id] != NULL) menulist[e.u.m.id - IDOFFSET] != NULL)
w = (object *)menulist[e.u.m.id]; w = (object *)menulist[e.u.m.id - IDOFFSET];
else else
w = None; w = None;
w = makemenu(w, e.u.m.item); w = makemenu(w, e.u.m.item);
@ -1663,5 +1664,10 @@ static struct methodlist stdwin_methods[] = {
void void
initstdwin() initstdwin()
{ {
static int inited;
if (!inited) {
winit();
inited = 1;
}
initmodule("stdwin", stdwin_methods); initmodule("stdwin", stdwin_methods);
} }