From 259658eb28bb683fdf5965182088de455d42c206 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 24 Apr 2019 08:17:01 -0700 Subject: [PATCH] Fix leaked interval in dialog --- src/vs/base/browser/ui/dialog/dialog.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/vs/base/browser/ui/dialog/dialog.ts b/src/vs/base/browser/ui/dialog/dialog.ts index 6f56c306563..63c444bd886 100644 --- a/src/vs/base/browser/ui/dialog/dialog.ts +++ b/src/vs/base/browser/ui/dialog/dialog.ts @@ -40,7 +40,7 @@ export class Dialog extends Disposable { private buttonGroup: ButtonGroup | undefined; private styles: IDialogStyles | undefined; private focusToReturn: HTMLElement | undefined; - private iconRotatingInternal: any | undefined; + private iconRotatingInternal: NodeJS.Timer | undefined; constructor(private container: HTMLElement, private message: string, private buttons: string[], private options: IDialogOptions) { super(); @@ -169,7 +169,7 @@ export class Dialog extends Disposable { this.iconElement.style.transform = `rotate(${deg}deg)`; deg += 45; // 360 / 8 } else { - this.iconRotatingInternal = undefined; + this.stopAnimation(); } }, 125 /** 1000 / 8 */); break; @@ -199,6 +199,13 @@ export class Dialog extends Disposable { }); } + private stopAnimation() { + if (this.iconRotatingInternal) { + clearInterval(this.iconRotatingInternal); + this.iconRotatingInternal = undefined; + } + } + private applyStyles() { if (this.styles) { const style = this.styles; @@ -233,9 +240,7 @@ export class Dialog extends Disposable { this.modal = undefined; } - if (this.iconRotatingInternal) { - this.iconRotatingInternal = undefined; - } + this.stopAnimation(); if (this.focusToReturn && isAncestor(this.focusToReturn, document.body)) { this.focusToReturn.focus();