Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: setViewport can cause a crash if voi or scale are not provided #493

Merged
merged 4 commits into from
Sep 13, 2021

Conversation

mikehazell
Copy link
Contributor

@mikehazell mikehazell commented Oct 30, 2020

This PR fixes an issue where setViewport can cause a crash if not provided voi or scale.

@mikehazell mikehazell changed the title fix issue where merge setViewport fix issue where setViewport can cause a crash if voi or scale are not provided Oct 30, 2020
@mikehazell mikehazell marked this pull request as ready for review October 30, 2020 05:49
@mikehazell mikehazell changed the title fix issue where setViewport can cause a crash if voi or scale are not provided fix: setViewport can cause a crash if voi or scale are not provided Oct 30, 2020
@@ -35,12 +35,12 @@ export default function (element, viewport) {
// Prevent window width from being too small (note that values close to zero are valid and can occur with
// PET images in particular)
if (enabledElement.viewport.voi.windowWidth) {
enabledElement.viewport.voi.windowWidth = Math.max(viewport.voi.windowWidth, MIN_WINDOW_WIDTH);
enabledElement.viewport.voi.windowWidth = Math.max(enabledElement.viewport.voi.windowWidth, MIN_WINDOW_WIDTH);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

viewport.voi.windowWidth and enabledElement.viewport.voi.windowWidth should be equal given the merge on lines 26-32.

}

// Prevent scale from getting too small
if (enabledElement.viewport.scale) {
enabledElement.viewport.scale = Math.max(viewport.scale, MIN_VIEWPORT_SCALE);
enabledElement.viewport.scale = Math.max(enabledElement.viewport.scale, MIN_VIEWPORT_SCALE);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same goes for viewport.scale and enabledElement.viewport.scale.

test/setViewport_test.js Outdated Show resolved Hide resolved
@swederik swederik merged commit 4468b1b into cornerstonejs:master Sep 13, 2021
@swederik
Copy link
Member

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants