Skip to content

Commit 85a5117

Browse files
committed
collect garbage
1 parent c8d0d33 commit 85a5117

File tree

2 files changed

+53
-30
lines changed

2 files changed

+53
-30
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
2121
construct: function(resourceData) {
2222
this.base(arguments);
2323

24+
this.__widgets = [];
2425
this.__resourceData = resourceData;
2526

2627
let latestPromise = null;
@@ -115,6 +116,10 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
115116
...osparc.ui.window.TabbedWindow.DEFAULT_PROPS,
116117
});
117118
resourceDetails.addListener("closeWindow", () => window.close());
119+
window.addListener("close", () => {
120+
// trigger children's destroy functions
121+
resourceDetails.destroy();
122+
});
118123
return {
119124
resourceDetails,
120125
window,
@@ -144,6 +149,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
144149
members: {
145150
__resourceData: null,
146151
__resourceModel: null,
152+
__widgets: null,
147153
__infoPage: null,
148154
__servicesUpdatePage: null,
149155
__conversationsPage: null,
@@ -430,6 +436,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
430436
}
431437
},
432438

439+
__addPage: function(page) {
440+
const tabsView = this.getChildControl("tabs-view");
441+
tabsView.add(page);
442+
},
443+
433444
__addInfoPage: function() {
434445
const id = "Information";
435446
const title = this.tr("Overview");
@@ -459,11 +470,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
459470
infoCard.addListener("openClassifiers", () => this.openClassifiers());
460471
infoCard.addListener("openQuality", () => this.openQuality());
461472
page.addToContent(infoCard);
473+
this.__widgets.push(infoCard);
462474
}
463475
page.addListenerOnce("appear", lazyLoadContent, this);
464476

465-
const tabsView = this.getChildControl("tabs-view");
466-
tabsView.add(page);
477+
this.__addPage(page);
467478
},
468479

469480
__addBillingPage: function() {
@@ -498,11 +509,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
498509
}, this);
499510
const billingScroll = new qx.ui.container.Scroll(billingSettings);
500511
page.addToContent(billingScroll);
512+
this.__widgets.push(billingSettings);
501513
}
502514
page.addListenerOnce("appear", lazyLoadContent, this);
503515

504-
const tabsView = this.getChildControl("tabs-view");
505-
tabsView.add(page);
516+
this.__addPage(page);
506517
} else if (osparc.utils.Resources.isService(resourceData)) {
507518
const id = "Tiers";
508519
const title = this.tr("Tiers");
@@ -514,11 +525,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
514525
const pricingUnitsList = new osparc.service.PricingUnitsList(resourceData);
515526
const pricingUnitsListScroll = new qx.ui.container.Scroll(pricingUnitsList);
516527
page.addToContent(pricingUnitsListScroll);
528+
this.__widgets.push(pricingUnitsList);
517529
}
518530
page.addListenerOnce("appear", lazyLoadContent, this);
519531

520-
const tabsView = this.getChildControl("tabs-view");
521-
tabsView.add(page);
532+
this.__addPage(page);
522533
}
523534
},
524535

@@ -547,11 +558,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
547558
const resourceModel = this.__resourceModel;
548559
const preview = new osparc.study.StudyPreview(resourceModel);
549560
page.addToContent(preview);
561+
this.__widgets.push(preview);
550562
}
551563
page.addListenerOnce("appear", lazyLoadContent, this);
552564

553-
const tabsView = this.getChildControl("tabs-view");
554-
tabsView.add(page);
565+
this.__addPage(page);
555566
},
556567

557568
__addConversationsPage: function() {
@@ -569,11 +580,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
569580
const lazyLoadContent = () => {
570581
const conversations = new osparc.study.Conversations(resourceData);
571582
page.addToContent(conversations);
583+
this.__widgets.push(conversations);
572584
}
573585
page.addListenerOnce("appear", lazyLoadContent, this);
574586

575-
const tabsView = this.getChildControl("tabs-view");
576-
tabsView.add(page);
587+
this.__addPage(page);
577588
},
578589

579590
__addPermissionsPage: function() {
@@ -607,11 +618,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
607618
}, this);
608619
}
609620
page.addToContent(collaboratorsView);
621+
this.__widgets.push(collaboratorsView);
610622
}
611623
page.addListenerOnce("appear", lazyLoadContent, this);
612624

613-
const tabsView = this.getChildControl("tabs-view");
614-
tabsView.add(page);
625+
this.__addPage(page);
615626
},
616627

617628
__addClassifiersPage: function() {
@@ -643,11 +654,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
643654
classifiers = new osparc.metadata.ClassifiersViewer(resourceData);
644655
}
645656
page.addToContent(classifiers);
657+
this.__widgets.push(classifiers);
646658
}
647659
page.addListenerOnce("appear", lazyLoadContent, this);
648660

649-
const tabsView = this.getChildControl("tabs-view");
650-
tabsView.add(page);
661+
this.__addPage(page);
651662
},
652663

653664
__addQualityPage: function() {
@@ -673,11 +684,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
673684
this.__fireUpdateEvent(updatedData);
674685
});
675686
page.addToContent(qualityEditor);
687+
this.__widgets.push(qualityEditor);
676688
}
677689
page.addListenerOnce("appear", lazyLoadContent, this);
678690

679-
const tabsView = this.getChildControl("tabs-view");
680-
tabsView.add(page);
691+
this.__addPage(page);
681692
}
682693
},
683694

@@ -704,11 +715,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
704715
this.__fireUpdateEvent(resourceData, updatedData);
705716
}, this);
706717
page.addToContent(tagManager);
718+
this.__widgets.push(tagManager);
707719
}
708720
page.addListenerOnce("appear", lazyLoadContent, this);
709721

710-
const tabsView = this.getChildControl("tabs-view");
711-
tabsView.add(page);
722+
this.__addPage(page);
712723
},
713724

714725
__addServicesUpdatePage: function() {
@@ -734,11 +745,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
734745
this.__fireUpdateEvent(resourceData, updatedData);
735746
});
736747
page.addToContent(servicesUpdate);
748+
this.__widgets.push(servicesUpdate);
737749
}
738750
page.addListenerOnce("appear", lazyLoadContent, this);
739751

740-
const tabsView = this.getChildControl("tabs-view");
741-
tabsView.add(page);
752+
this.__addPage(page);
742753
},
743754

744755
__addServicesBootOptionsPage: function() {
@@ -767,6 +778,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
767778
this.__fireUpdateEvent(resourceData, updatedData);
768779
});
769780
page.addToContent(servicesBootOpts);
781+
this.__widgets.push(servicesBootOpts);
770782

771783
if (
772784
osparc.utils.Resources.isStudy(resourceData) ||
@@ -788,8 +800,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
788800
}
789801
page.addListenerOnce("appear", lazyLoadContent, this);
790802

791-
const tabsView = this.getChildControl("tabs-view");
792-
tabsView.add(page);
803+
this.__addPage(page);
793804
},
794805

795806
__addPublishPage: function() {
@@ -823,11 +834,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
823834
toolbar.add(publishTemplateButton);
824835
page.addToHeader(toolbar);
825836
page.addToContent(saveAsTemplate);
837+
this.__widgets.push(saveAsTemplate);
826838
}
827839
page.addListenerOnce("appear", lazyLoadContent, this);
828840

829-
const tabsView = this.getChildControl("tabs-view");
830-
tabsView.add(page);
841+
this.__addPage(page);
831842
}
832843
},
833844

@@ -862,11 +873,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
862873
toolbar.add(createTemplateButton);
863874
page.addToHeader(toolbar);
864875
page.addToContent(saveAsTemplate);
876+
this.__widgets.push(saveAsTemplate);
865877
}
866878
page.addListenerOnce("appear", lazyLoadContent, this);
867879

868-
const tabsView = this.getChildControl("tabs-view");
869-
tabsView.add(page);
880+
this.__addPage(page);
870881
}
871882
},
872883

@@ -894,9 +905,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
894905
toolbar.add(createFunctionButton);
895906
page.addToHeader(toolbar);
896907
page.addToContent(createFunction);
908+
this.__widgets.push(createFunction);
897909

898-
const tabsView = this.getChildControl("tabs-view");
899-
tabsView.add(page);
910+
this.__addPage(page);
900911
},
901912

902913
__addProjectFilesPopUp: function() {
@@ -941,5 +952,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
941952
this.addWidgetToTabs(dataAccess);
942953
}
943954
},
955+
956+
// overridden
957+
destroy: function() {
958+
this.__widgets.forEach(w => w.destroy());
959+
this.base(arguments);
960+
},
944961
}
945962
});

services/static-webserver/client/source/class/osparc/study/Conversations.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ qx.Class.define("osparc.study.Conversations", {
5252
const viewWidth = 600;
5353
const viewHeight = 700;
5454
const win = osparc.ui.window.Window.popUpInWindow(conversations, title, viewWidth, viewHeight);
55+
win.addListener("close", () => {
56+
conversations.destroy();
57+
}, this);
5558
return win;
5659
},
5760

@@ -361,14 +364,17 @@ qx.Class.define("osparc.study.Conversations", {
361364
}
362365
},
363366

364-
destruct: function() {
367+
// overridden
368+
destroy: function() {
365369
const socket = osparc.wrapper.WebSocket.getInstance();
366370
if (this.__wsHandlers) {
367371
this.__wsHandlers.forEach(({ eventName }) => {
368372
socket.removeSlot(eventName);
369373
});
370374
this.__wsHandlers = null;
371375
}
376+
377+
this.base(arguments);
372378
},
373-
}
379+
},
374380
});

0 commit comments

Comments
 (0)