Commit c41b09b8 authored by David Schnur's avatar David Schnur

Only save references to old Canvas methods once.

Plugins are re-initialized with each re-plot (which may not be the right
thing to do, but that's how it works for now).  The previous approach of
saving references to the original Canvas functions therefore broke,
since the second time around we'd get a reference to our new function.
Instead we hold those references as globals within the plugin, and only
set them once.

This whole idea of replacing prototype functions is, now that I step
back and look at it, really awful.  This needs to be changed ASAP to
something less ridiculous.
parent 53ce9ad1
......@@ -33,16 +33,25 @@ browser, but needs to redraw with canvas text when exporting as an image.
canvas: true
};
var render, getTextInfo, addText;
// Cache the prototype hasOwnProperty for faster access
var hasOwnProperty = Object.prototype.hasOwnProperty;
function init(plot, classes) {
var Canvas = classes.Canvas,
var Canvas = classes.Canvas;
// We only want to replace the functions once; the second time around
// we would just get our new function back. This whole replacing of
// prototype functions is a disaster, and needs to be changed ASAP.
if (render == null) {
getTextInfo = Canvas.prototype.getTextInfo,
addText = Canvas.prototype.addText,
render = Canvas.prototype.render;
}
// Finishes rendering the canvas, including overlaid text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment