Skip to content

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

Merged
swederik merged 4 commits intocornerstonejs:masterfrom
mikehazell:pr/fix-setViewport-merge
Sep 13, 2021
Merged

fix: setViewport can cause a crash if voi or scale are not provided#493
swederik merged 4 commits intocornerstonejs:masterfrom
mikehazell:pr/fix-setViewport-merge

Conversation

@mikehazell
Copy link
Copy Markdown
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
// 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
Copy Markdown
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
Copy Markdown
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.

@swederik swederik merged commit 4468b1b into cornerstonejs:master Sep 13, 2021
@swederik
Copy link
Copy Markdown
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