Skip to content

Commit

Permalink
fix(ImageCroppingWidget): Missing unsubscribe call
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Oct 28, 2019
1 parent ab83119 commit 211179b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Sources/Widgets/Widgets3D/ImageCroppingWidget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { ViewTypes } from 'vtk.js/Sources/Widgets/Core/WidgetManager/Constants';
function vtkImageCroppingWidget(publicAPI, model) {
model.classHierarchy.push('vtkImageCroppingWidget');

let stateSub = null;

// --------------------------------------------------------------------------

function setHandlesEnabled(label, flag) {
Expand Down Expand Up @@ -87,6 +89,14 @@ function vtkImageCroppingWidget(publicAPI, model) {
}
};

// --------------------------------------------------------------------------

publicAPI.delete = macro.chain(publicAPI.delete, () => {
if (stateSub) {
stateSub.unsubscribe();
}
});

// --- Widget Requirement ---------------------------------------------------

model.behavior = behavior;
Expand Down Expand Up @@ -117,7 +127,9 @@ function vtkImageCroppingWidget(publicAPI, model) {
};

// Update handle positions when cropping planes update
model.widgetState.getCroppingPlanes().onModified(publicAPI.updateHandles);
stateSub = model.widgetState
.getCroppingPlanes()
.onModified(publicAPI.updateHandles);

// Add manipulators to our widgets.
const planeManipulator = vtkPlaneManipulator.newInstance();
Expand Down

0 comments on commit 211179b

Please sign in to comment.