From cc031e0a869d36ea30a7b95f98f382117add2dc4 Mon Sep 17 00:00:00 2001 From: "olau@iola.dk" Date: Tue, 14 Dec 2010 20:24:13 +0000 Subject: [PATCH] Fix possible excanvas leak (report and suggested fix by tom9729) git-svn-id: https://flot.googlecode.com/svn/trunk@284 1e0a6537-2640-0410-bfb7-f154510ff394 --- NEWS.txt | 4 +++- jquery.flot.js | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index 99fce1a..5c732fe 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -111,7 +111,9 @@ Bug fixes: - Listen for mouseleave events and fire a plothover event with empty item when it occurs to drop highlights when the mouse leaves the plot (reported by by outspirit). -- Fix bug with using aboveData with a background (reported by amitayd). +- Fix bug with using aboveData with a background (reported by + amitayd). +- Fix possible excanvas leak (report and suggested fix by tom9729). Flot 0.6 diff --git a/jquery.flot.js b/jquery.flot.js index 5251c10..755efcf 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -699,15 +699,28 @@ function constructCanvas() { canvasWidth = placeholder.width(); canvasHeight = placeholder.height(); + + // excanvas hack, if there are any canvases here, whack + // the state on them manually + if (window.G_vmlCanvasManager) + placeholder.find("canvas").each(function () { + delete this.context_; + }); + placeholder.html(""); // clear placeholder + if (placeholder.css("position") == 'static') placeholder.css("position", "relative"); // for positioning labels and overlay if (canvasWidth <= 0 || canvasHeight <= 0) throw "Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight; - if (window.G_vmlCanvasManager) // excanvas hack, make sure everything is setup + // excanvas hack, make sure everything is setup + if (window.G_vmlCanvasManager + && !window.G_vmlCanvasManager.inited) { + window.G_vmlCanvasManager.inited = true; window.G_vmlCanvasManager.init_(document); + } function makeCanvas(skipPositioning) { var c = document.createElement('canvas');