Skip to content

Conversation

@HeikoKlare
Copy link
Contributor

The MultiZoomCoordinateSystemMapper currently produces a devide-by-zero error when transforming a rectangle of zero size. This can, for example, happen when a (dummy) shell with width=height=0 is created and its bounds are passed to the mapper.

This change ensures that the problematic calculation is avoided in case width or height are zero. In that case, no reasonable monitor can be identified anyway.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2025

Test Results

   539 files   -  6     539 suites   - 6   32m 41s ⏱️ + 3m 25s
 4 330 tests  - 35   4 316 ✅  - 33   13 💤  - 3  1 ❌ +1 
16 579 runs   - 21  16 467 ✅  - 19  111 💤  - 3  1 ❌ +1 

For more details on these failures, see this check.

Results for commit 5003293. ± Comparison against base commit 7c818d6.

This pull request removes 37 and adds 2 tests. Note that renamed tests count towards both.
AllWin32Tests org.eclipse.swt.graphics.ImageWin32Tests ‑ testImageDataForDifferentFractionalZoomsShouldBeDifferent
AllWin32Tests org.eclipse.swt.graphics.ImageWin32Tests ‑ testImageShouldHaveDimesionAsPerZoomLevel
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testByteArrayTransfer
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testFileTransfer
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testHtmlTransfer
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromCopiedImage
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromImage
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromImageData
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testImageTransfer_fromImageDataFromImage
AllWin32Tests org.eclipse.swt.tests.win32.Test_org_eclipse_swt_dnd_DND ‑ testRtfTransfer
…
org.eclipse.swt.widgets.CoordinateSystemMapperTests ‑ translateRectangleInPixelsForZeroSize(CoordinateSystemMapper)[1]
org.eclipse.swt.widgets.CoordinateSystemMapperTests ‑ translateRectangleInPixelsForZeroSize(CoordinateSystemMapper)[2]

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare marked this pull request as ready for review March 21, 2025 13:03
@HeikoKlare HeikoKlare force-pushed the multizoomcoordinatesystem-byzero branch from ef5d23a to 379393a Compare March 24, 2025 16:43
@HeikoKlare
Copy link
Contributor Author

@amartya4256 can you please review this?

private Monitor getContainingMonitorForPoints(int x, int y, int width, int height) {
if (width <= 0 || height <= 0) {
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to return the monitor of the containing point (x,y)in this case using getContainingMonitorForPoints(int x, int y)
Since this function's caller is getValidMonitorIfApplicable(int x, int y, int width, int height, Monitor monitor) and it assigns the rectangle the defaultMonitor in case null is returned. For correctness, we can keep the monitor consistent by calling getContainingMonitorForPoints(int x, int y). What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea, thank you! I have adapted the PR accordingly. Can you check whether it now fits to your proposal, @amartya4256?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is good.

The MultiZoomCoordinateSystemMapper currently produces a devide-by-zero
error when transforming a rectangle of zero size. This can, for example,
happen when a (dummy) shell with width=height=0 is created and its
bounds are passed to the mapper.

This change ensures that the problematic calculation is avoided in case
width or height are zeroi by just taking the x/y coordinate into
account.
@HeikoKlare HeikoKlare force-pushed the multizoomcoordinatesystem-byzero branch from 379393a to 5003293 Compare March 26, 2025 12:11
Copy link
Contributor

@amartya4256 amartya4256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR overall looks good to me.

@HeikoKlare
Copy link
Contributor Author

Failing test is unrelated and documented: #1843

@HeikoKlare HeikoKlare merged commit 5a22b50 into eclipse-platform:master Mar 26, 2025
13 of 15 checks passed
@HeikoKlare HeikoKlare deleted the multizoomcoordinatesystem-byzero branch March 26, 2025 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants