Clip rounded profile start to end after clipping rounded end to width / height #1399
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This should fix #1395.
I believe that this bug is triggered by the spatially matched images being non-overlapping, which leads to a profile sometimes being requested from the large image with both endpoints being the largest y value (i.e. 999 to 999). When the image is zoomed out and a large mip is used, the endpoints are rounded for decimation (from 999 to 1000). The end is then restricted to the height of the image (999), but we did not consider the possibility that the start value could be equal to the end and thus also need to be adjusted in the same way here.
This PR adds a line to restrict the start so that it does not exceed the end.
In my local test (on Ubuntu), the crash was happening in
profile.reserve(end - start);
. I'm not 100% sure if @crocka's crash on the Mac (a value being too large to fit in asize_t
) was happening in exactly the same place, but it's likely to have had the same root cause (a negative number being incorrectly converted to an unsigned type).If you cannot reproduce the crash in
dev
, try reducing the area available for the image viewer component (e.g. by opening the browser console in the window). It's only triggered when the mip is high enough (and I believe when your cursor is in the appropriate area of the image).If there is no regression, I think this is a low-risk addition.
Checklist
no changelog update neededprotobuf updated to the latest dev commit/ no protobuf update neededprotobuf version bumped/ protobuf version not bumped