Skip to content

Commit 7f5476e

Browse files
committed
fix(ViewProxy): handle object cleanup
1 parent bf000b6 commit 7f5476e

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Sources/Proxy/Core/ViewProxy/index.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ function vtkViewProxy(publicAPI, model) {
166166
// --------------------------------------------------------------------------
167167

168168
publicAPI.setContainer = (container) => {
169+
const orientationWidgetEnabled = model.orientationWidget.getEnabled();
170+
169171
if (model.container) {
172+
model.orientationWidget.setEnabled(false);
170173
model.interactor.unbindEvents(model.container);
171174
model.openglRenderWindow.setContainer(null);
172175
model.cornerAnnotation.setContainer(null);
@@ -179,6 +182,7 @@ function vtkViewProxy(publicAPI, model) {
179182
model.cornerAnnotation.setContainer(container);
180183
model.interactor.initialize();
181184
model.interactor.bindEvents(container);
185+
model.orientationWidget.setEnabled(orientationWidgetEnabled);
182186
}
183187
};
184188

@@ -577,11 +581,21 @@ function vtkViewProxy(publicAPI, model) {
577581

578582
// --------------------------------------------------------------------------
579583

580-
publicAPI.delete = macro.chain(
581-
publicAPI.setContainer,
582-
model.openglRenderWindow.delete,
583-
publicAPI.delete
584-
);
584+
publicAPI.delete = macro.chain(() => {
585+
publicAPI.setContainer(null);
586+
model.orientationWidget.setEnabled(false);
587+
model.orientationWidget.delete();
588+
model.orientationAxesArrow.delete();
589+
model.orientationAxesCube.delete();
590+
model.interactorStyle2D.delete();
591+
model.interactorStyle3D.delete();
592+
model.cornerAnnotation.delete();
593+
// in reverse order
594+
model.interactor.delete();
595+
model.renderer.delete();
596+
model.openglRenderWindow.delete();
597+
model.renderWindow.delete();
598+
}, publicAPI.delete);
585599

586600
// --------------------------------------------------------------------------
587601
// Initialization from state or input

0 commit comments

Comments
 (0)