Skip to content

Commit

Permalink
Work for #4484 - fixed leaks in Angular
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Sep 4, 2023
1 parent 4eaceed commit 85b9a84
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export class ItemValueDesignerComponent extends CreatorModelComponent<ItemValueW
protected getModel(): ItemValueWrapperViewModel {
return this.adorner;
}
override ngOnDestroy(): void {
super.ngOnDestroy();
this.adorner.dispose();
}
}

AngularComponentFactory.Instance.registerComponent("svc-item-value", ItemValueDesignerComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export class MatrixCellComponent extends CreatorModelComponent<MatrixCellWrapper
protected getModel(): MatrixCellWrapperViewModel {
return this.adorner;
}
override ngOnDestroy(): void {
super.ngOnDestroy();
this.adorner.dispose();
}
}

AngularComponentFactory.Instance.registerComponent("svc-matrix-cell", MatrixCellComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export class QuestionRatingAdornerDesignerComponent extends CreatorModelComponen
protected getModel(): QuestionRatingAdornerViewModel {
return this.adorner;
}
override ngOnDestroy(): void {
super.ngOnDestroy();
this.adorner.dispose();
}
}

AngularComponentFactory.Instance.registerComponent("svc-rating-question-content", QuestionRatingAdornerDesignerComponent);
Expand Down
1 change: 0 additions & 1 deletion packages/survey-creator-angular/src/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class PageDesignerComponent extends CreatorModelComponent<PageAdorner> {
public adorner!: PageAdorner;
protected createModel(): void {
if (this.model) {
this.previousModel?.dispose();
this.adorner = new PageAdorner(this.creator, this.model);
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/survey-creator-angular/src/question.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export class QuestionDesignerComponent extends CreatorModelComponent<QuestionAdo
event.stopPropagation();
this.adorner.addNewQuestion();
}
override ngOnDestroy(): void {
super.ngOnDestroy();
this.adorner.dispose();
}
adornerComponent = "";
}

Expand Down
5 changes: 5 additions & 0 deletions packages/survey-creator-angular/src/row.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export class CreatorRowComponent extends CreatorModelComponent<RowViewModel> {
getPropertiesToTrack(): string[] {
return ["creator", "row"];
}
override ngOnDestroy(): void {
super.ngOnDestroy();
this.model.dispose();
}

}

AngularComponentFactory.Instance.registerComponent("svc-row", CreatorRowComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export class StringEditorComponent extends CreatorModelComponent<StringEditorVie
}
}
override ngOnDestroy(): void {
this.baseModel.blurEditor = undefined as any;
this.baseModel.getEditorElement = undefined as any;
this.baseModel.dispose();
this.locString?.onStringChanged.remove(this.onChangeHandler);
super.ngOnDestroy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ export class ToolboxToolComponent extends CreatorModelComponent<Action> {
protected override getPropertiesToUpdateSync(): string[] {
return ["mode"];
}
override ngOnDestroy(): void {
super.ngOnDestroy();
this.model.dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class QuestionImageAdornerViewModel extends QuestionAdornerViewModel {
this.filePresentationModel.storeDataAsText = false;
surveyModel.onUploadFiles.add((s, o) => {
const fileToUpload = o.files[0];
if(!!fileToUpload) {
if (!!fileToUpload) {
this.creator.uploadFiles(o.files, this.question, (status, link) => {
this.question.imageLink = link;
});
Expand Down Expand Up @@ -78,4 +78,9 @@ export class QuestionImageAdornerViewModel extends QuestionAdornerViewModel {
public get chooseImageText(): string {
return getLocString("ed.imageChooseImage");
}

public dispose() {
super.dispose();
this.questionRoot = undefined;
}
}

0 comments on commit 85b9a84

Please sign in to comment.