提交 1eb0b5bc 编写于 作者: A Andre Weinand

dispose of RunOnceScheduler properly

上级 e06e6262
...@@ -28,7 +28,6 @@ import { isWindows } from 'vs/base/common/platform'; ...@@ -28,7 +28,6 @@ import { isWindows } from 'vs/base/common/platform';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { ltrim } from 'vs/base/common/strings'; import { ltrim } from 'vs/base/common/strings';
import { RunOnceScheduler } from 'vs/base/common/async'; import { RunOnceScheduler } from 'vs/base/common/async';
import { memoize } from 'vs/base/common/decorators';
const SMART = true; const SMART = true;
...@@ -308,7 +307,6 @@ export class LoadedScriptsView extends TreeViewsViewletPanel { ...@@ -308,7 +307,6 @@ export class LoadedScriptsView extends TreeViewsViewletPanel {
private treeContainer: HTMLElement; private treeContainer: HTMLElement;
private loadedScriptsItemType: IContextKey<string>; private loadedScriptsItemType: IContextKey<string>;
private settings: any; private settings: any;
private shouldRefreshRecursive;
constructor( constructor(
options: IViewletViewOptions, options: IViewletViewOptions,
...@@ -327,16 +325,6 @@ export class LoadedScriptsView extends TreeViewsViewletPanel { ...@@ -327,16 +325,6 @@ export class LoadedScriptsView extends TreeViewsViewletPanel {
this.loadedScriptsItemType = CONTEXT_LOADED_SCRIPTS_ITEM_TYPE.bindTo(contextKeyService); this.loadedScriptsItemType = CONTEXT_LOADED_SCRIPTS_ITEM_TYPE.bindTo(contextKeyService);
} }
@memoize
private get treeRefreshScheduler(): RunOnceScheduler {
return new RunOnceScheduler(() => {
if (this.tree) {
this.tree.refresh(undefined, this.shouldRefreshRecursive);
this.shouldRefreshRecursive = false;
}
}, 300);
}
protected renderBody(container: HTMLElement): void { protected renderBody(container: HTMLElement): void {
dom.addClass(container, 'debug-loaded-scripts'); dom.addClass(container, 'debug-loaded-scripts');
...@@ -378,6 +366,15 @@ export class LoadedScriptsView extends TreeViewsViewletPanel { ...@@ -378,6 +366,15 @@ export class LoadedScriptsView extends TreeViewsViewletPanel {
} }
})); }));
let nextRefreshIsRecursive = false;
const refreshScheduler = new RunOnceScheduler(() => {
if (this.tree) {
this.tree.refresh(undefined, nextRefreshIsRecursive);
nextRefreshIsRecursive = false;
}
}, 300);
this.disposables.push(refreshScheduler);
const root = new RootTreeItem(this.debugService.getModel(), this.environmentService, this.contextService); const root = new RootTreeItem(this.debugService.getModel(), this.environmentService, this.contextService);
this.tree.setInput(root); this.tree.setInput(root);
...@@ -385,8 +382,8 @@ export class LoadedScriptsView extends TreeViewsViewletPanel { ...@@ -385,8 +382,8 @@ export class LoadedScriptsView extends TreeViewsViewletPanel {
this.disposables.push(session.onDidLoadedSource(event => { this.disposables.push(session.onDidLoadedSource(event => {
const sessionRoot = root.add(session); const sessionRoot = root.add(session);
sessionRoot.addPath(event.source); sessionRoot.addPath(event.source);
this.shouldRefreshRecursive = true; nextRefreshIsRecursive = true;
this.treeRefreshScheduler.schedule(); refreshScheduler.schedule();
})); }));
}; };
...@@ -395,7 +392,7 @@ export class LoadedScriptsView extends TreeViewsViewletPanel { ...@@ -395,7 +392,7 @@ export class LoadedScriptsView extends TreeViewsViewletPanel {
this.disposables.push(this.debugService.onDidEndSession(session => { this.disposables.push(this.debugService.onDidEndSession(session => {
root.remove(session.getId()); root.remove(session.getId());
this.treeRefreshScheduler.schedule(); refreshScheduler.schedule();
})); }));
} }
...@@ -412,8 +409,8 @@ export class LoadedScriptsView extends TreeViewsViewletPanel { ...@@ -412,8 +409,8 @@ export class LoadedScriptsView extends TreeViewsViewletPanel {
} }
dispose(): void { dispose(): void {
super.dispose();
this.tree = undefined; this.tree = undefined;
super.dispose();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册