Skip to content

Commit 7488529

Browse files
committed
Use same cleanup procedure for TGeo drawing
1 parent 7b99ed4 commit 7488529

File tree

2 files changed

+6
-30
lines changed

2 files changed

+6
-30
lines changed

scripts/JSRoot3DPainter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@
323323
if (obj.children) {
324324
for (var i = 0; i < obj.children.length; i++)
325325
JSROOT.Painter.DisposeThreejsObject(obj.children[i]);
326+
obj.children = undefined;
326327
}
327328
if (obj.geometry) {
328329
obj.geometry.dispose();
@@ -349,6 +350,7 @@
349350
this.clear_3d_canvas();
350351

351352
JSROOT.Painter.DisposeThreejsObject(this.scene);
353+
if (this.control) this.control.dispose();
352354

353355
delete this.size3d;
354356
delete this.scene;

scripts/JSRootGeoPainter.js

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,8 +1839,10 @@
18391839

18401840
if (!first_time) {
18411841
this.helpText();
1842-
if (this._scene)
1843-
this.deleteChildren(this._scene);
1842+
1843+
1844+
JSROOT.Painter.DisposeThreejsObject(this._scene);
1845+
18441846
if (this._tcontrols)
18451847
this._tcontrols.dispose();
18461848

@@ -1942,34 +1944,6 @@
19421944
this.Render3D();
19431945
}
19441946

1945-
JSROOT.TGeoPainter.prototype.deleteChildren = function(obj) {
1946-
if ((typeof obj['children'] != 'undefined') && (obj['children'] instanceof Array)) {
1947-
for ( var i=obj.children.length-1; i>=0; i-- ) {
1948-
var ob = obj.children[i];
1949-
this.deleteChildren(ob);
1950-
try {
1951-
obj.remove(obj.children[i]);
1952-
} catch(e) {}
1953-
try {
1954-
ob.geometry.dispose();
1955-
ob.geometry = null;
1956-
} catch(e) {}
1957-
try {
1958-
ob.material.dispose();
1959-
ob.material = null;
1960-
} catch(e) {}
1961-
try {
1962-
ob.texture.dispose();
1963-
ob.texture = null;
1964-
} catch(e) {}
1965-
ob = null;
1966-
obj.children[i] = null;
1967-
}
1968-
obj.children = null;
1969-
}
1970-
obj = null;
1971-
}
1972-
19731947
JSROOT.Painter.drawGeoObject = function(divid, obj, opt) {
19741948
if (obj === null) return null;
19751949

0 commit comments

Comments
 (0)