Skip to content

Commit 04dc982

Browse files
committed
fix(WidgetManager): Unsubscribe to events when widgetManager is deleted
If the widgetManager is deleted, it does not unsubscribe to events. If an event is triggered (svgSetSize for example), the vizualization will crash since widgetManager does no longer exist.
1 parent ea3b09e commit 04dc982

File tree

1 file changed

+8
-0
lines changed
  • Sources/Widgets/Core/WidgetManager

1 file changed

+8
-0
lines changed

Sources/Widgets/Core/WidgetManager/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,14 @@ function vtkWidgetManager(publicAPI, model) {
461461
}
462462
return false;
463463
};
464+
465+
const superDelete = publicAPI.delete;
466+
publicAPI.delete = () => {
467+
while (subscriptions.length) {
468+
subscriptions.pop().unsubscribe();
469+
}
470+
superDelete();
471+
};
464472
}
465473

466474
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)