Bug 1606375 - Prevent calendar components from being loaded multiple times; r=Fallen
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 31 Dec 2019 11:30:40 +1300
changeset 37922 6ff2528049d8aa2e92a30266f4a61472e0e3cf9d
parent 37921 8144aa335452df7ed2e86a68114d6dee632609d8
child 37923 fd13b1c3b79c733bd65113b3b1dfd8bac51dfd44
push id398
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:10:28 +0000
reviewersFallen
bugs1606375
Bug 1606375 - Prevent calendar components from being loaded multiple times; r=Fallen
calendar/base/src/calItemModule.js
--- a/calendar/base/src/calItemModule.js
+++ b/calendar/base/src/calItemModule.js
@@ -25,17 +25,17 @@
 /* import-globals-from calStartupService.js */
 /* import-globals-from calTransactionManager.js */
 /* import-globals-from calTodo.js */
 /* import-globals-from calWeekInfoService.js */
 
 var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-this.NSGetFactory = cid => {
+this._NSGetFactory = cid => {
   let scriptLoadOrder = [
     "resource://calendar/calendar-js/calItemBase.js",
     "resource://calendar/calendar-js/calCachedCalendar.js",
 
     "resource://calendar/calendar-js/calAlarm.js",
     "resource://calendar/calendar-js/calAlarmMonitor.js",
     "resource://calendar/calendar-js/calAlarmService.js",
     "resource://calendar/calendar-js/calAttendee.js",
@@ -85,11 +85,17 @@ this.NSGetFactory = cid => {
     calRelation,
     calStartupService,
     calTransaction,
     calTransactionManager,
     calTodo,
     calWeekInfoService,
   ];
 
-  this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
-  return this.NSGetFactory(cid);
+  this._NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
+  return this._NSGetFactory(cid);
 };
+
+// This version of NSGetFactory is used every time, even if it is replaced. Instead, we use a shim
+// calling an internal function. The internal function is replaced after the first run.
+this.NSGetFactory = cid => {
+  return this._NSGetFactory(cid);
+};