check for int value in uicb_tag_toggleview()

This commit is contained in:
Julien Danjou 2007-11-16 22:03:26 +01:00
parent 037d6aea59
commit d46f740a39
1 changed files with 8 additions and 2 deletions

10
tag.c
View File

@ -142,14 +142,20 @@ void
uicb_tag_toggleview(awesome_config *awesomeconf,
const char *arg)
{
unsigned int i;
int j;
int i, j;
i = arg ? atoi(arg) - 1: 0;
if(i >= awesomeconf->ntags)
return;
awesomeconf->tags[i].selected = !awesomeconf->tags[i].selected;
/* check that there's at least one tag selected */
for(j = 0; j < awesomeconf->ntags && !awesomeconf->tags[j].selected; j++);
if(j == awesomeconf->ntags)
awesomeconf->tags[i].selected = True;
saveawesomeprops(awesomeconf);
arrange(awesomeconf);
}