Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: BUGFIX: cOsd::CanHandleAreas()



Reinhard Nissl wrote:
> 
> Hi,
> 
> CanHandleAreas() didn't check the alignment of the last area. Basically, the
> inner for loop was closed to late.

Right, thanks.

> To have overlap detection work properly and to return reasonable error codes
> to the user, CanHandleAreas() now first checks the alignment of all areas and
> performs overlap detection afterwards.

I don't quite see what the advantage is in having an extra 'for' loop.
The error messages are still the same, aren't they?

Shouldn't

  for (int i = 0; i < NumAreas; i++) {
      if (Areas[i].x1 > Areas[i].x2 || Areas[i].y1 > Areas[i].y2 || Areas[i].x1 < 0 || Areas[i].y1 < 0)
         return oeWrongAlignment;
      for (int j = i + 1; j < NumAreas; j++) {
          if (Areas[i].Intersects(Areas[j]))
             return oeAreasOverlap;
          }
      }

do just the same?

Klaus

> Bye.
> --
> Dipl.-Inform. (FH) Reinhard Nissl
> mailto:rnissl@gmx.de
> 
>   ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> --- vdr-1.3.11-orig/osd.c       2004-06-15 22:29:42.000000000 +0200
> +++ vdr-1.3.11/osd.c    2004-06-20 21:05:51.791081842 +0200
> @@ -603,13 +603,17 @@
>  eOsdError cOsd::CanHandleAreas(const tArea *Areas, int NumAreas)
>  {
>    for (int i = 0; i < NumAreas; i++) {
> +      if (Areas[i].x1 > Areas[i].x2 || Areas[i].y1 > Areas[i].y2 || Areas[i].x1 < 0 || Areas[i].y1 < 0)
> +          return oeWrongAlignment;
> +  }
> +
> +  for (int i = 0; i < NumAreas - 1; i++) {
>        for (int j = i + 1; j < NumAreas; j++) {
>            if (Areas[i].Intersects(Areas[j]))
> -             return oeAreasOverlap;
> -          if (Areas[i].x1 > Areas[i].x2 || Areas[i].y1 > Areas[i].y2 || Areas[i].x1 < 0 || Areas[i].y1 < 0)
> -             return oeWrongAlignment;
> -          }
> -      }
> +              return oeAreasOverlap;
> +    }
> +  }
> +
>    return oeOk;
>  }




Home | Main Index | Thread Index