Fix crash when snapshot or match places window on invalid desk (noted by Ted Baltz).

SVN revision: 42381
This commit is contained in:
Kim Woelders 2009-09-10 14:34:06 +00:00
parent b04daa8b86
commit cf87c2452d
4 changed files with 13 additions and 3 deletions

View File

@ -717,6 +717,15 @@ DeskGet(unsigned int desk)
return _DeskGet(desk);
}
Desk *
DeskGetValid(unsigned int desk)
{
if (desk >= Conf.desks.num)
desk = 0;
return _DeskGet(desk);
}
Desk *
DeskGetRelative(Desk * dsk, int inc)
{
@ -846,7 +855,7 @@ ChangeNumberOfDesktops(unsigned int quantity)
for (j = 0; j < num; j++)
{
if (EoGetDeskNum(lst[j]) >= quantity)
EwinMoveToDesktop(lst[j], _DeskGet(quantity - 1));
EwinMoveToDesktop(lst[j], _DeskGet(0));
}
while (Conf.desks.num > quantity)

View File

@ -62,6 +62,7 @@ struct _desk {
/* desktops.c */
Desk *DeskGet(unsigned int desk);
Desk *DeskGetValid(unsigned int desk);
Desk *DeskGetRelative(Desk * dsk, int inc);
void DeskGetArea(const Desk * dsk, int *ax, int *ay);
void DeskSetArea(Desk * dsk, int ax, int ay);

View File

@ -1429,7 +1429,7 @@ SnapshotEwinApply(EWin * ewin)
EoSetSticky(ewin, sn->sticky);
if (use_flags & SNAP_USE_DESK)
EoSetDesk(ewin, DeskGet(sn->desktop));
EoSetDesk(ewin, DeskGetValid(sn->desktop));
if (use_flags & SNAP_USE_SIZE)
{

View File

@ -671,7 +671,7 @@ WindowMatchEwinOpsAction(EWin * ewin, int op, const char *args)
break;
case EWIN_OP_DESK:
EoSetDesk(ewin, DeskGet(atoi(args)));
EoSetDesk(ewin, DeskGetValid(atoi(args)));
break;
#if 0 /* Causes crash */