Skip to content

Commit f6b83c2

Browse files
committed
Clean up disposal for the widget manager and subclasses
1 parent b572f5f commit f6b83c2

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

packages/jupyterlab-manager/src/manager.ts

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ export abstract class LabWidgetManager extends ManagerBase<Widget>
276276
* #### Notes
277277
* This is a read-only property.
278278
*/
279-
abstract get isDisposed(): boolean;
279+
get isDisposed(): boolean {
280+
return this._isDisposed;
281+
}
280282

281283
/**
282284
* Dispose the resources held by the manager.
@@ -285,6 +287,7 @@ export abstract class LabWidgetManager extends ManagerBase<Widget>
285287
if (this.isDisposed) {
286288
return;
287289
}
290+
this._isDisposed = true;
288291

289292
if (this._commRegistration) {
290293
this._commRegistration.dispose();
@@ -442,6 +445,7 @@ export abstract class LabWidgetManager extends ManagerBase<Widget>
442445
protected _restoredStatus = false;
443446
protected _initialRestoredStatus = false;
444447

448+
private _isDisposed = false;
445449
private _registry: SemVerCache<ExportData> = new SemVerCache<ExportData>();
446450
private _rendermime: IRenderMimeRegistry;
447451

@@ -506,16 +510,6 @@ export class KernelWidgetManager extends LabWidgetManager {
506510
this._restored.emit();
507511
}
508512

509-
/**
510-
* Get whether the manager is disposed.
511-
*
512-
* #### Notes
513-
* This is a read-only property.
514-
*/
515-
get isDisposed(): boolean {
516-
return this._kernel === null;
517-
}
518-
519513
/**
520514
* Dispose the resources held by the manager.
521515
*/
@@ -524,9 +518,8 @@ export class KernelWidgetManager extends LabWidgetManager {
524518
return;
525519
}
526520

527-
super.dispose();
528-
529521
this._kernel = null!;
522+
super.dispose();
530523
}
531524

532525
get kernel(): Kernel.IKernelConnection {
@@ -628,16 +621,6 @@ export class WidgetManager extends LabWidgetManager {
628621
}
629622
}
630623

631-
/**
632-
* Get whether the manager is disposed.
633-
*
634-
* #### Notes
635-
* This is a read-only property.
636-
*/
637-
get isDisposed(): boolean {
638-
return this._context === null;
639-
}
640-
641624
/**
642625
* Dispose the resources held by the manager.
643626
*/
@@ -646,8 +629,8 @@ export class WidgetManager extends LabWidgetManager {
646629
return;
647630
}
648631

649-
super.dispose();
650632
this._context = null!;
633+
super.dispose();
651634
}
652635

653636
/**

0 commit comments

Comments
 (0)