Browse Source

Prevent possible memory leak

j8
tsareg 9 years ago
parent
commit
375b145030
2 changed files with 12 additions and 2 deletions
  1. 6
    0
      modules/UI/UI.js
  2. 6
    2
      modules/UI/util/MessageHandler.js

+ 6
- 0
modules/UI/UI.js View File

@@ -1289,6 +1289,12 @@ UI.showDeviceErrorDialog = function (micError, cameraError) {
1289 1289
                         input.prop("checked");
1290 1290
                 }
1291 1291
             }
1292
+        },
1293
+        null,
1294
+        function () {
1295
+            // Reset dialog reference to null to avoid memory leaks when
1296
+            // user closed the dialog manually.
1297
+            deviceErrorDialog = null;
1292 1298
         }
1293 1299
     );
1294 1300
 

+ 6
- 2
modules/UI/util/MessageHandler.js View File

@@ -113,9 +113,10 @@ var messageHandler = {
113 113
      * @param submitFunction function to be called on submit
114 114
      * @param loadedFunction function to be called after the prompt is fully
115 115
      *        loaded
116
+     * @param closeFunction function to be called on dialog close
116 117
      */
117 118
     openDialog: function (titleString, msgString, persistent, buttons,
118
-                              submitFunction, loadedFunction) {
119
+                              submitFunction, loadedFunction, closeFunction) {
119 120
         if (!popupEnabled)
120 121
             return;
121 122
 
@@ -125,11 +126,14 @@ var messageHandler = {
125 126
             buttons: buttons,
126 127
             defaultButton: 1,
127 128
             loaded: loadedFunction,
128
-            submit: submitFunction
129
+            submit: submitFunction,
130
+            close: closeFunction
129 131
         };
132
+
130 133
         if (persistent) {
131 134
             args.closeText = '';
132 135
         }
136
+        
133 137
         return new Impromptu(msgString, args);
134 138
     },
135 139
 

Loading…
Cancel
Save