Skip to content

bug: FreehandRoiSculptorTool causing crash when disabled while no image loaded. #1303

@mikehazell

Description

@mikehazell

Prerequisites

  • Which version are you using? (Is it latest?)
    • Latest but this applies from v4.19.1
  • Are you reporting to the correct repository?
    • Yes, sort of ... it's complicated
  • Did you search existing issues? (Were any related?)
    • Nope

Description

FreehandRoiSculptorTool can cause a crash if "disabled" before an image is loaded on an element. This case is especially likely to come up when globalToolSync is enabled.

This issue has become a problem for me since v4.19.1

The following change triggers the crash:

fc4495c#diff-8eec6cde9dbfd62a7f0ba3022495f20dR74-R82

This causes FreehandRoiSculptorTool to call updateImage on the element where we see the error.

_deactivateSculpt(element) {
element.removeEventListener(EVENTS.MOUSE_UP, this.activeMouseUpCallback);
element.removeEventListener(EVENTS.MOUSE_CLICK, this.activeMouseUpCallback);
element.removeEventListener(
EVENTS.MOUSE_DRAG,
this.activeMouseDragCallback
);
element.removeEventListener(EVENTS.TOUCH_END, this.activeTouchEndCallback);
element.removeEventListener(EVENTS.TOUCH_TAP, this.activeTouchEndCallback);
element.removeEventListener(
EVENTS.TOUCH_DRAG,
this.activeMouseDragCallback
);
external.cornerstone.updateImage(element);
}

Steps to Reproduce the issue

The simplest test case is to add the FreehandRoiSculptorTool and then call setToolDisabledForElement for it.

CodeSandbox With Reproduction of Issue:

https://codesandbox.io/s/cornerstone-freehandsculptor-crash-u2wsk?file=/src/index.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions