Skip to content

Commit

Permalink
Merge pull request #494 from okmiim/viewer-exception
Browse files Browse the repository at this point in the history
BUG: Fix uninitialized variable in viewer
  • Loading branch information
thewtex authored Aug 9, 2022
2 parents 57701a7 + cf50853 commit 9c810f6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions js/lib/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const createRenderingPipeline = (
backgroundColor[2] = rgb[2] / 255.0
}
const backgroundTrait = domWidgetView.model.get('background')
if (backgroundTrait.length !== 0) {
if (backgroundTrait && !!backgroundTrait.length) {
backgroundColor = backgroundTrait
}
const viewerStyle = {
Expand Down Expand Up @@ -721,7 +721,7 @@ const ViewerView = widgets.DOMWidgetView.extend({
}
this.model.itkVtkViewer.on('backgroundColorChanged', onBackgroundChanged)
const background = this.model.get('background')
if (background.length === 0) {
if (background === null|| background.length === 0) {
this.model.set('background', this.model.itkVtkViewer.getBackgroundColor())
}

Expand Down Expand Up @@ -930,7 +930,7 @@ const ViewerView = widgets.DOMWidgetView.extend({
onChannelsChanged
)
const channels = this.model.get('channels')
if (channels.length === 0) {
if (channels === null || channels.length === 0) {
this.model.set('channels', this.model.itkVtkViewer.getComponentVisibilities())
}

Expand Down

0 comments on commit 9c810f6

Please sign in to comment.