Some memory leaks have been fixed (#61)

* svg.selectize.js memory leaks have been fixed
main
Boris Sekachev 8 years ago committed by Nikita Manovich
parent 05e6e331d2
commit badddeb07f

@ -1,29 +1,29 @@
From b89380c65ea8bc9231cc98a6ae0e812227c85b3d Mon Sep 17 00:00:00 2001 From 5eeb1092c64865c555671ed585da18f974c9c10c Mon Sep 17 00:00:00 2001
From: Boris Sekachev <boris.sekachev@intel.com> From: Boris Sekachev <boris.sekachev@intel.com>
Date: Tue, 10 Jul 2018 14:31:13 +0300 Date: Tue, 18 Sep 2018 15:58:20 +0300
Subject: [PATCH] tmp Subject: [PATCH] tmp
--- ---
.../engine/static/engine/js/3rdparty/svg.draggable.js | 1 + .../engine/static/engine/js/3rdparty/svg.draggable.js | 1 +
cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js | 17 +++++++++++++++-- cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js | 17 +++++++++++++++--
.../apps/engine/static/engine/js/3rdparty/svg.resize.js | 5 +++-- .../apps/engine/static/engine/js/3rdparty/svg.resize.js | 5 +++--
.../apps/engine/static/engine/js/3rdparty/svg.select.js | 1 + .../apps/engine/static/engine/js/3rdparty/svg.select.js | 5 ++++-
4 files changed, 20 insertions(+), 4 deletions(-) 4 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js
index d88abf5..06158f1 100644 index d88abf5..aba474c 100644
--- a/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js --- a/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js
+++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js +++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js
@@ -109,6 +109,7 @@ @@ -109,6 +109,7 @@
// while dragging // while dragging
DragHandler.prototype.drag = function(e){ DragHandler.prototype.drag = function(e){
+ this.m = this.el.node.getScreenCTM().inverse(); + this.m = this.el.node.getScreenCTM().inverse();
var box = this.getBBox() var box = this.getBBox()
, p = this.transformPoint(e) , p = this.transformPoint(e)
diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js
index 68dbf2a..9884b75 100644 index 68dbf2a..20a6917 100644
--- a/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js --- a/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js
+++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js +++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
@ -31,13 +31,13 @@ index 68dbf2a..9884b75 100644
this.lastUpdateCall = null; this.lastUpdateCall = null;
this.options = {}; this.options = {};
+ this.set = new SVG.Set(); + this.set = new SVG.Set();
// Merge options and defaults // Merge options and defaults
for (var i in this.el.draw.defaults) { for (var i in this.el.draw.defaults) {
@@ -139,6 +140,8 @@ @@ -139,6 +140,8 @@
// Call the calc-function which calculates the new position and size // Call the calc-function which calculates the new position and size
this.calc(event); this.calc(event);
+ this.m = this.el.node.getScreenCTM().inverse(); + this.m = this.el.node.getScreenCTM().inverse();
+ this.offset = { x: window.pageXOffset, y: window.pageYOffset }; + this.offset = { x: window.pageXOffset, y: window.pageYOffset };
// Fire the `drawupdate`-event // Fire the `drawupdate`-event
@ -46,7 +46,7 @@ index 68dbf2a..9884b75 100644
@@ -160,6 +163,16 @@ @@ -160,6 +163,16 @@
this.el.fire('drawcancel'); this.el.fire('drawcancel');
}; };
+ // Undo last drawed point + // Undo last drawed point
+ PaintHandler.prototype.undo = function () { + PaintHandler.prototype.undo = function () {
+ if (this.set.length()) { + if (this.set.length()) {
@ -59,24 +59,24 @@ index 68dbf2a..9884b75 100644
+ +
// Calculate the corrected position when using `snapToGrid` // Calculate the corrected position when using `snapToGrid`
PaintHandler.prototype.snapToGrid = function (draw) { PaintHandler.prototype.snapToGrid = function (draw) {
@@ -371,14 +384,14 @@ @@ -371,14 +384,14 @@
this.set.clear(); this.set.clear();
- for (var i = 0; i < array.length; ++i) { - for (var i = 0; i < array.length; ++i) {
+ for (var i = 0; i < array.length - 1; ++i) { + for (var i = 0; i < array.length - 1; ++i) {
this.p.x = array[i][0] this.p.x = array[i][0]
this.p.y = array[i][1] this.p.y = array[i][1]
var p = this.p.matrixTransform(this.parent.node.getScreenCTM().inverse().multiply(this.el.node.getScreenCTM())); var p = this.p.matrixTransform(this.parent.node.getScreenCTM().inverse().multiply(this.el.node.getScreenCTM()));
- this.set.add(this.parent.circle(5).stroke({width: 1}).fill('#ccc').center(p.x, p.y)); - this.set.add(this.parent.circle(5).stroke({width: 1}).fill('#ccc').center(p.x, p.y));
+ this.set.add(this.parent.circle(5).stroke({width: 1}).fill('#ccc').center(p.x, p.y)).addClass("svg_draw_point"); + this.set.add(this.parent.circle(5).stroke({width: 1}).fill('#ccc').center(p.x, p.y)).addClass("svg_draw_point");
} }
} }
diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js
index 0c3b63d..fb5dc26 100644 index 0c3b63d..fb5dc26 100644
--- a/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js --- a/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js
@ -91,27 +91,53 @@ index 0c3b63d..fb5dc26 100644
+ y: event.clientY != null ? event.clientY : event.touches[0].clientY + y: event.clientY != null ? event.clientY : event.touches[0].clientY
}; };
}; };
@@ -343,6 +343,7 @@ @@ -343,6 +343,7 @@
} }
return; return;
} }
+ this.m = this.el.node.getScreenCTM().inverse(); + this.m = this.el.node.getScreenCTM().inverse();
// Calculate the difference between the mouseposition at start and now // Calculate the difference between the mouseposition at start and now
var txPt = this._extractPosition(event); var txPt = this._extractPosition(event);
diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js
index 47e07bd..f1d0c02 100644 index 47e07bd..cee6d34 100644
--- a/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js --- a/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js
+++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js +++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js
@@ -160,6 +160,7 @@ SelectHandler.prototype.drawPoints = function () { @@ -160,6 +160,7 @@ SelectHandler.prototype.drawPoints = function () {
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false; ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
ev.stopPropagation(); ev.stopPropagation();
+ if (ev.which != 1) return false; + if (ev.which != 1) return false;
var x = ev.pageX || ev.touches[0].pageX; var x = ev.pageX || ev.touches[0].pageX;
var y = ev.pageY || ev.touches[0].pageY; var y = ev.pageY || ev.touches[0].pageY;
_this.el.fire('point', {x: x, y: y, i: k, event: ev}); _this.el.fire('point', {x: x, y: y, i: k, event: ev});
-- @@ -361,6 +362,7 @@ SelectHandler.prototype.cleanup = function () {
// stop watching the element, remove the selection
this.rectSelection.set.each(function () {
this.remove();
+ SVG.off(this.node);
});
this.rectSelection.set.clear();
@@ -371,6 +373,7 @@ SelectHandler.prototype.cleanup = function () {
// Remove all points, clear the set, stop watching the element
this.pointSelection.set.each(function () {
this.remove();
+ SVG.off(this.node);
});
this.pointSelection.set.clear();
@@ -379,8 +382,8 @@ SelectHandler.prototype.cleanup = function () {
if (!this.pointSelection.isSelected && !this.rectSelection.isSelected) {
this.nested.remove();
+ SVG.off(this.node);
delete this.nested;
-
}
};
--
2.7.4 2.7.4

@ -44,6 +44,8 @@ class FrameProvider extends Listener {
this._loaded = frame; this._loaded = frame;
this._frameCollection[frame] = image; this._frameCollection[frame] = image;
this._loadAllowed = true; this._loadAllowed = true;
image.onload = null;
image.onerror = null;
this.notify(); this.notify();
} }
@ -109,6 +111,8 @@ class FrameProvider extends Listener {
image.onload = this._onImageLoad.bind(this, image, frame); image.onload = this._onImageLoad.bind(this, image, frame);
image.onerror = () => { image.onerror = () => {
this._loadAllowed = true; this._loadAllowed = true;
image.onload = null;
image.onerror = null;
}; };
image.src = `get/task/${this._tid}/frame/${frame}`; image.src = `get/task/${this._tid}/frame/${frame}`;
}.bind(this), 25); }.bind(this), 25);

@ -1608,8 +1608,8 @@ class ShapeView extends Listener {
_removeShapeUI() { _removeShapeUI() {
if (this._uis.shape) { if (this._uis.shape) {
this._uis.shape.off('click');
this._uis.shape.remove(); this._uis.shape.remove();
SVG.off(this._uis.shape.node);
this._uis.shape = null; this._uis.shape = null;
} }
} }
@ -1618,6 +1618,7 @@ class ShapeView extends Listener {
_removeShapeText() { _removeShapeText() {
if (this._uis.text) { if (this._uis.text) {
this._uis.text.remove(); this._uis.text.remove();
SVG.off(this._uis.text.node);
this._uis.text = null; this._uis.text = null;
} }
} }

Loading…
Cancel
Save