Skip to content

Commit

Permalink
Merge pull request #25 from alja/prox41
Browse files Browse the repository at this point in the history
Fix crash on root exit (related to previous PR)
  • Loading branch information
alja authored Feb 6, 2019
2 parents 09bd8f9 + c6c1b5d commit 6061565
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 61 deletions.
74 changes: 54 additions & 20 deletions etc/eve7/EveManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,41 +258,75 @@
this.ProcessUpdate(300);
}

//______________________________________________________________________________


EveManager.prototype.RecursiveRemove = function(elem, delSet) {
var elId = elem.fElementId;
var motherId = elem.fMotherId;

// iterate children
if (elem.childs !== undefined) {
while (elem.childs.length > 0) {
var n = 0;
var sub = elem.childs[n];
this.RecursiveRemove(sub, delSet);
}
}

// delete myself from mater
var mother = this.GetElement(motherId);
var mc = mother.childs;
for (var i = 0; i < mc.length; ++i) {

if (mc[i].fElementId === elId) {
mc.splice(i, 1);
}
}

delete this.map[elId];
delSet.delete(elId);

console.log(" ecursiveRemove END", elId, delSet);
// delete elem;
}
//______________________________________________________________________________



EveManager.prototype.ImportSceneChangeJson = function(msg) {
var arr = msg.arr;
this.last_json = null;
this.scene_changes = msg;

var scene = this.GetElement(msg.header.fSceneId);
console.log("ImportSceneChange", scene.fName, msg);

// notify scenes for beginning of changes and
// notify for element removal
var removedIds = msg.header["removedElements"];

// do we need this?
// do we need this? -- AMT this is intended to freeze redraws
this.callSceneReceivers(scene, "beginChanges");

for (var r = 0; r < removedIds.length; ++r) {
var id = removedIds[r];
this.callSceneReceivers(scene, "elementRemoved", id);
var element = this.GetElement(id);
this.DeleteChildsOf(element);

// remove from mother
var mother = this.map[element.fMotherId];
var mc = mother.childs;
// notify controllers
this.callSceneReceivers(scene, "elementsRemoved", removedIds);

for (var i = 0; i < mc.length; ++i) {
console.log("comapre ", mc[i], id);
if (mc[i].fElementId === id) {
console.log("remove from mother ");
mc.splice(i, 1);
}
}
delete this.map[id];
element = null;

var delSet = new Set();
for (var r = 0; r < removedIds.length; ++r) {
var id = removedIds[r];
delSet.add(id);
}

console.log("start with delSet ", delSet);
while (delSet.size != 0) {
var it = delSet.values();
var id = it.next().value;
console.log("going to call RecursiveRemove .... ", this.map[id]);
this.RecursiveRemove(this.GetElement(id), delSet);
console.log("complete RecursiveREmove ", delSet);
}

// wait for binary if needed
if (msg.header.fTotalBinarySize)
{
Expand Down
29 changes: 18 additions & 11 deletions etc/eve7/EveScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@
var container = this.viewer.getThreejsContainer("scene" + this.id);

container.add(obj3d);
console.log("element added ", el);

this.id2obj_map[el.fElementId] = obj3d;
if (el.fMasterId) this.mid2obj_map[el.fMasterId] = obj3d;
}

EveScene.prototype.visibilityChanged = function(el)
Expand Down Expand Up @@ -395,16 +397,21 @@
this[msg.tag](el);
}

EveScene.prototype.elementRemoved = function(elId) {
var el = this.mgr.GetElement(elId);
console.log("EveScene elementRemoved ", el);
var obj3d = this.getObj3D(el.fElementId);

var container = this.viewer.getThreejsContainer("scene" + this.id);
container.remove(obj3d);

delete this.id2obj_map[el.fElementId];

EveScene.prototype.elementsRemoved = function(ids) {
for (var i = 0; i < ids.length; i++)
{
var elId = ids[i];
var obj3d = this.getObj3D(elId);
if (!obj3d) {
console.log("ERROOR cant find obj3d");
}

var container = this.viewer.getThreejsContainer("scene" + this.id);
container.remove(obj3d);

// console.log("EveScene elementRemoved AFTER ", container);
delete this.id2obj_map[elId];
}
}

JSROOT.EVE.EveScene = EveScene;
Expand Down
43 changes: 41 additions & 2 deletions etc/eve7/Summary.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ sap.ui.define([
member: "fMainColor",
srv : "SetMainColorRGB",
_type : "Color"
}, {
name : "Destroy ",
member: "fElementId",
srv : "Destroy",
_type : "Action"
}],
"REveElementList" : [ {sub: ["REveElement"]}],
"REveGeoShape" : [ {sub: ["REveElement"]}, ],
Expand Down Expand Up @@ -163,6 +168,11 @@ sap.ui.define([
}, {
name : "LineWidth",
_type : "Number"
}, {
name : "Destroy ",
member: "fElementId",
srv : "Destroy",
_type : "Action"
}],
"REveDataGeoShape" : [{
}]
Expand Down Expand Up @@ -190,6 +200,17 @@ sap.ui.define([

var oTree = this.getView().byId("tree");
oTree.expandToLevel(2);

// hide editor
if (this.ged) {
/*
var pp = this.byId("sumSplitter");
this.ged.visible = false;
pp.removeContentArea(this.ged);
*/ var gedFrame = this.gedVert;//this.getView().byId("GED");
gedFrame.unbindElement();
gedFrame.destroyContent();
}
},

addNodesToTreeItemModel: function(el, model) {
Expand Down Expand Up @@ -371,7 +392,8 @@ sap.ui.define([
var model = oEvent.getParameter("listItem").getBindingContext("treeModel"),
path = model.getPath(),
ttt = model.getProperty(path);


console.log("Summary::onItemPressed ", this.mgr.GetElement(ttt.id));
if (!ttt || (ttt.childs !== undefined) || !ttt.masterid) return;

var sel_color = ttt.fHighlight == "None" ? "blue" : "";
Expand Down Expand Up @@ -556,7 +578,14 @@ sap.ui.define([
oCPPop.data("myData", customData);
}
});
break;

case "Action":
widget = new Button(sId, {
//text: "Action",
icon: "sap-icon://accept",
press: this.sendMethodInvocationRequest.bind(this, "Action")
});
break;
}

Expand Down Expand Up @@ -609,8 +638,18 @@ sap.ui.define([
},

sendMethodInvocationRequest: function(kind, event) {
var value = "";
switch (kind) {
case "Bool":
value = event.getSource().getSelected();
break;

var value = (kind == "Bool") ? event.getSource().getSelected() : event.getParameter("value");
case "Action":
value = "";
break;
default:
value = event.getParameter("value");
}

console.log("on change !!!!!!", event.getSource().data("myData"));

Expand Down
4 changes: 4 additions & 0 deletions graf3d/eve7/src/REveElement.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ REveElement::REveElement(const REveElement& e) :

REveElement::~REveElement()
{
if (fScene && fScene->IsAcceptingChanges()) {
printf("PreDeleteElement add to remove list (SCENE =%s) %d \n", fScene->GetCName(), fElementId);
fScene->SceneElementRemoved( fElementId);
}
if (fDestructing != kAnnihilate)
{
fDestructing = kStandard;
Expand Down
Loading

0 comments on commit 6061565

Please sign in to comment.