Skip to content

Commit 72d8cfc

Browse files
bsekachevBoris Sekachev
authored and
Boris Sekachev
committed
Some memory leaks have been fixed (#61)
* svg.selectize.js memory leaks have been fixed
1 parent fdd4006 commit 72d8cfc

File tree

3 files changed

+55
-24
lines changed

3 files changed

+55
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
From b89380c65ea8bc9231cc98a6ae0e812227c85b3d Mon Sep 17 00:00:00 2001
1+
From 5eeb1092c64865c555671ed585da18f974c9c10c Mon Sep 17 00:00:00 2001
22
From: Boris Sekachev <[email protected]>
3-
Date: Tue, 10 Jul 2018 14:31:13 +0300
3+
Date: Tue, 18 Sep 2018 15:58:20 +0300
44
Subject: [PATCH] tmp
55

66
---
77
.../engine/static/engine/js/3rdparty/svg.draggable.js | 1 +
88
cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js | 17 +++++++++++++++--
99
.../apps/engine/static/engine/js/3rdparty/svg.resize.js | 5 +++--
10-
.../apps/engine/static/engine/js/3rdparty/svg.select.js | 1 +
11-
4 files changed, 20 insertions(+), 4 deletions(-)
10+
.../apps/engine/static/engine/js/3rdparty/svg.select.js | 5 ++++-
11+
4 files changed, 23 insertions(+), 5 deletions(-)
1212

1313
diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js
14-
index d88abf5..06158f1 100644
14+
index d88abf5..aba474c 100644
1515
--- a/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js
1616
+++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.draggable.js
1717
@@ -109,6 +109,7 @@
18-
18+
1919
// while dragging
2020
DragHandler.prototype.drag = function(e){
2121
+ this.m = this.el.node.getScreenCTM().inverse();
22-
22+
2323
var box = this.getBBox()
2424
, p = this.transformPoint(e)
2525
diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js
26-
index 68dbf2a..9884b75 100644
26+
index 68dbf2a..20a6917 100644
2727
--- a/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js
2828
+++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.draw.js
2929
@@ -18,6 +18,7 @@
3030
this.startPoint = null;
3131
this.lastUpdateCall = null;
3232
this.options = {};
3333
+ this.set = new SVG.Set();
34-
34+
3535
// Merge options and defaults
3636
for (var i in this.el.draw.defaults) {
3737
@@ -139,6 +140,8 @@
3838
// Call the calc-function which calculates the new position and size
3939
this.calc(event);
40-
40+
4141
+ this.m = this.el.node.getScreenCTM().inverse();
4242
+ this.offset = { x: window.pageXOffset, y: window.pageYOffset };
4343
// Fire the `drawupdate`-event
@@ -46,7 +46,7 @@ index 68dbf2a..9884b75 100644
4646
@@ -160,6 +163,16 @@
4747
this.el.fire('drawcancel');
4848
};
49-
49+
5050
+ // Undo last drawed point
5151
+ PaintHandler.prototype.undo = function () {
5252
+ if (this.set.length()) {
@@ -59,24 +59,24 @@ index 68dbf2a..9884b75 100644
5959
+
6060
// Calculate the corrected position when using `snapToGrid`
6161
PaintHandler.prototype.snapToGrid = function (draw) {
62-
62+
6363
@@ -371,14 +384,14 @@
64-
64+
6565
this.set.clear();
66-
66+
6767
- for (var i = 0; i < array.length; ++i) {
6868
+ for (var i = 0; i < array.length - 1; ++i) {
69-
69+
7070
this.p.x = array[i][0]
7171
this.p.y = array[i][1]
72-
72+
7373
var p = this.p.matrixTransform(this.parent.node.getScreenCTM().inverse().multiply(this.el.node.getScreenCTM()));
74-
74+
7575
- this.set.add(this.parent.circle(5).stroke({width: 1}).fill('#ccc').center(p.x, p.y));
7676
+ this.set.add(this.parent.circle(5).stroke({width: 1}).fill('#ccc').center(p.x, p.y)).addClass("svg_draw_point");
7777
}
7878
}
79-
79+
8080
diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js
8181
index 0c3b63d..fb5dc26 100644
8282
--- a/cvat/apps/engine/static/engine/js/3rdparty/svg.resize.js
@@ -91,27 +91,53 @@ index 0c3b63d..fb5dc26 100644
9191
+ y: event.clientY != null ? event.clientY : event.touches[0].clientY
9292
};
9393
};
94-
94+
9595
@@ -343,6 +343,7 @@
9696
}
9797
return;
9898
}
9999
+ this.m = this.el.node.getScreenCTM().inverse();
100-
100+
101101
// Calculate the difference between the mouseposition at start and now
102102
var txPt = this._extractPosition(event);
103103
diff --git a/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js b/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js
104-
index 47e07bd..f1d0c02 100644
104+
index 47e07bd..cee6d34 100644
105105
--- a/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js
106106
+++ b/cvat/apps/engine/static/engine/js/3rdparty/svg.select.js
107107
@@ -160,6 +160,7 @@ SelectHandler.prototype.drawPoints = function () {
108108
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
109109
ev.stopPropagation();
110-
110+
111111
+ if (ev.which != 1) return false;
112112
var x = ev.pageX || ev.touches[0].pageX;
113113
var y = ev.pageY || ev.touches[0].pageY;
114114
_this.el.fire('point', {x: x, y: y, i: k, event: ev});
115-
--
115+
@@ -361,6 +362,7 @@ SelectHandler.prototype.cleanup = function () {
116+
// stop watching the element, remove the selection
117+
this.rectSelection.set.each(function () {
118+
this.remove();
119+
+ SVG.off(this.node);
120+
});
121+
122+
this.rectSelection.set.clear();
123+
@@ -371,6 +373,7 @@ SelectHandler.prototype.cleanup = function () {
124+
// Remove all points, clear the set, stop watching the element
125+
this.pointSelection.set.each(function () {
126+
this.remove();
127+
+ SVG.off(this.node);
128+
});
129+
130+
this.pointSelection.set.clear();
131+
@@ -379,8 +382,8 @@ SelectHandler.prototype.cleanup = function () {
132+
133+
if (!this.pointSelection.isSelected && !this.rectSelection.isSelected) {
134+
this.nested.remove();
135+
+ SVG.off(this.node);
136+
delete this.nested;
137+
-
138+
}
139+
};
140+
141+
--
116142
2.7.4
117143

cvat/apps/engine/static/engine/js/player.js

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class FrameProvider extends Listener {
4444
this._loaded = frame;
4545
this._frameCollection[frame] = image;
4646
this._loadAllowed = true;
47+
image.onload = null;
48+
image.onerror = null;
4749
this.notify();
4850
}
4951

@@ -109,6 +111,8 @@ class FrameProvider extends Listener {
109111
image.onload = this._onImageLoad.bind(this, image, frame);
110112
image.onerror = () => {
111113
this._loadAllowed = true;
114+
image.onload = null;
115+
image.onerror = null;
112116
};
113117
image.src = `get/task/${this._tid}/frame/${frame}`;
114118
}.bind(this), 25);

cvat/apps/engine/static/engine/js/shapes.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1646,8 +1646,8 @@ class ShapeView extends Listener {
16461646

16471647
_removeShapeUI() {
16481648
if (this._uis.shape) {
1649-
this._uis.shape.off('click');
16501649
this._uis.shape.remove();
1650+
SVG.off(this._uis.shape.node);
16511651
this._uis.shape = null;
16521652
}
16531653
}
@@ -1656,6 +1656,7 @@ class ShapeView extends Listener {
16561656
_removeShapeText() {
16571657
if (this._uis.text) {
16581658
this._uis.text.remove();
1659+
SVG.off(this._uis.text.node);
16591660
this._uis.text = null;
16601661
}
16611662
}

0 commit comments

Comments
 (0)