LP#1086458: convert last-print information hash to JSON string before caching
authorGalen Charlton <gmc@esilibrary.com>
Mon, 14 Oct 2013 15:23:23 +0000 (08:23 -0700)
committerMike Rylander <mrylander@gmail.com>
Thu, 31 Oct 2013 15:34:03 +0000 (11:34 -0400)
By serializing the printing message and context information to a
JSON string before caching it, we avoid inadvertantly dragging in
things like Javascript execution contexts and possibly references
to objects created by the checkout interface.  This was contributing
to the staff client memory leaks observed during receipt printing.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/xul/staff_client/chrome/content/util/print.js

index f67f708..1e6f5fc 100644 (file)
@@ -51,9 +51,10 @@ util.print.prototype = {
                 );
                 return;
             }
-            if(obj.data.last_print.context) this.set_context(obj.data.last_print.context);
-            var msg = obj.data.last_print.msg;
-            var params = obj.data.last_print.params; params.no_prompt = false;
+            var last_print = JSON2js(obj.data.last_print);
+            if(last_print.context) this.set_context(last_print.context);
+            var msg = last_print.msg;
+            var params = last_print.params; params.no_prompt = false;
             obj.simple( msg, params );
         } catch(E) {
             this.error.standard_unexpected_error_alert('util.print.reprint_last',E);
@@ -115,7 +116,7 @@ util.print.prototype = {
 
             var obj = this;
 
-            obj.data.last_print = { 'msg' : msg, 'params' : params, 'context' : this.context};
+            obj.data.last_print = js2JSON({ 'msg' : msg, 'params' : params, 'context' : this.context});
             obj.data.stash('last_print');
 
             var silent = false;