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)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 17 Oct 2013 18:20:34 +0000 (14:20 -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>
Open-ILS/xul/staff_client/chrome/content/util/print.js

index f4369f1..6e52010 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;