Menu: Fix segfault if there is no menu {} section in config.

This commit is contained in:
Martin Duquesnoy 2009-07-29 17:42:50 +02:00
parent 702d6065fa
commit 7097296cc8
4 changed files with 10 additions and 11 deletions

View File

@ -298,8 +298,6 @@ conf_layout_section(cfg_t *cfg_l)
conf.colors.bar,
conf.colors.text);
menulayout.special = True;
if(!conf.layout[0].symbol
&& !conf.layout[0].func)
{
@ -425,9 +423,8 @@ conf_menu_section(cfg_t *cfg_m)
conf.nmenu = cfg_size(cfg_m, "set_menu");
CHECK(conf.nmenu);
conf.menu = emalloc(conf.nmenu + 1, sizeof(Menu));
conf.menu = emalloc(conf.nmenu, sizeof(Menu));
conf.menu[conf.nmenu] = menulayout;
for(i = 0; i < conf.nmenu; ++i)
{

View File

@ -113,11 +113,11 @@ buttonpress(XButtonEvent *ev)
{
if(conf.layout_system && (ev->button == Button1 || ev->button == Button3)) /* True -> menu */
{
conf.menu[conf.nmenu].y = spgeo[selscreen].y + infobar[selscreen].layout_button->geo.y + INFOBARH;
conf.menu[conf.nmenu].x = infobar[selscreen].layout_button->geo.x + (sgeo[selscreen].x - BORDH);
menulayout.y = spgeo[selscreen].y + infobar[selscreen].layout_button->geo.y + INFOBARH;
menulayout.x = infobar[selscreen].layout_button->geo.x + (sgeo[selscreen].x - BORDH);
if(infobar[selscreen].geo.y != spgeo[selscreen].y)
conf.menu[conf.nmenu].y = infobar[selscreen].geo.y - (INFOBARH * menulayout.nitem) - SHADH;
menulayout.y = infobar[selscreen].geo.y - (INFOBARH * menulayout.nitem) - SHADH;
uicb_menu("menulayout");
}

View File

@ -247,7 +247,10 @@ uicb_menu(uicb_t cmd)
int i, d, u, x, y;
Window w;
for(i = 0; i < conf.nmenu + conf.layout_system; ++i)
if(!strcmp(cmd, "menulayout"))
menu_draw(menulayout, menulayout.x, menulayout.y);
for(i = 0; i < conf.nmenu; ++i)
if(!strcmp(cmd, conf.menu[i].name))
{
if(conf.menu[i].place_at_mouse)
@ -255,8 +258,8 @@ uicb_menu(uicb_t cmd)
else
{
screen_get_sel();
x = conf.menu[i].x + ((conf.menu[i].special) ? 0 : spgeo[selscreen].x);
y = conf.menu[i].y + ((conf.menu[i].special) ? 0 : spgeo[selscreen].y);;
x = conf.menu[i].x + spgeo[selscreen].x;
y = conf.menu[i].y + spgeo[selscreen].y;
}
menu_draw(conf.menu[i], x, y);
}

View File

@ -237,7 +237,6 @@ typedef struct
char *name;
/* Placement */
Bool place_at_mouse;
Bool special;
int x, y;
/* Color */
struct