Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix window point conversion functions not exposing failure #9269
Link to issue number:
Summary of the issue:
There are 4 functions wrappers related to screen, client, logical and physical coordinate conversions.
These functions take a window handle and a point structure and return 1 on success and 0 on failure. The user32 functions also set the last error when the functions fail. The point in the structure is used to calculate a new point, and on success, the coordinates in the structure are replaced. On failure, the coordinates stay the same.
However, the wrappers of these functions silently return whatever is in the structure, thereby silently ignoring whether the underlying function succeeded or failed.
Description of how this pull request fixes the issue:
This is pretty hard to test. I stumbled upon this bug when testing the highlighter in the vision framework (#9064) as that converts physical to logical rectangle coordinates. It silently seemed to fail the conversion of the top left coordinates where it succeeded in converting the bottom right coordinates, resulting in a malformed rectangle.
Known issues with pull request:
Change log entry:
michaelDCurran left a comment
In some places you are catching exceptions and logging a debugWarning, but then it seems you're still going on and using the values you could not get. You'd either need to return some kind of safe value from the function or raise the original exception again.
@feerrenrut: This pull requests changes the behavior of some winUser and windowUtils helper functions. Therefore looking at this to be merged into 2019.3 might be a good idea, since it introduces backwards incompatible changes (i.e. these functions now raise exceptions where they didn't before).
Note that this pr now causes errors like this:
This is no mistake in this pr, rather, it is exactly proving the point that this pr was necessary. Effort should be put into finding out why these errors occur in order to fix them properly.