[PATCH] user32: Fix error handling in MapWindowPoints, ClientToScreen and ScreenToClient and add tests for them.

Dmitry Timoshkov dmitry at baikal.ru
Fri Oct 19 20:59:45 CDT 2012


Christian Costa <titan.costa at gmail.com> wrote:

> -BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt )
> +BOOL WINAPI ClientToScreen( HWND wnd, LPPOINT point )
>  {
> -    MapWindowPoints( hwnd, 0, lppnt, 1 );
> +    DWORD error = GetLastError();
> +
> +    if (!wnd)
> +    {
> +        SetLastError( ERROR_INVALID_WINDOW_HANDLE );
> +        return FALSE;
> +    }
> +
> +    SetLastError( 0xdeadbeef );
> +    MapWindowPoints( wnd, 0, point, 1 );
> +
> +    if (GetLastError() != 0xdeadbeef)
> +        return FALSE;
> +
> +    SetLastError(error);
>      return TRUE;
>  }

All this logic with saving/restoring last error code is wrong (here and
in another places), there is no need for that.

-- 
Dmitry.



More information about the wine-devel mailing list