1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

prevent exception generating tooltip for deleted nodes

This commit is contained in:
Steve-Mcl 2022-07-06 15:17:58 +01:00
parent 8cb212d897
commit 962672564e

View File

@ -3293,11 +3293,17 @@ RED.view = (function() {
if (active && ((portType === PORT_TYPE_INPUT && ((d._def && d._def.inputLabels)||d.inputLabels)) || (portType === PORT_TYPE_OUTPUT && ((d._def && d._def.outputLabels)||d.outputLabels)))) { if (active && ((portType === PORT_TYPE_INPUT && ((d._def && d._def.inputLabels)||d.inputLabels)) || (portType === PORT_TYPE_OUTPUT && ((d._def && d._def.outputLabels)||d.outputLabels)))) {
portLabelHoverTimeout = setTimeout(function() { portLabelHoverTimeout = setTimeout(function() {
const n = port && port.node()
const nId = n && n.__data__ && n.__data__.id
//check see if node has been deleted since timeout started
if(!n || !n.parentNode || !RED.nodes.node(n.__data__.id)) {
return; //node is gone!
}
var tooltip = getPortLabel(d,portType,portIndex); var tooltip = getPortLabel(d,portType,portIndex);
if (!tooltip) { if (!tooltip) {
return; return;
} }
var pos = getElementPosition(port.node()); var pos = getElementPosition(n);
portLabelHoverTimeout = null; portLabelHoverTimeout = null;
portLabelHover = showTooltip( portLabelHover = showTooltip(
(pos[0]+(portType===PORT_TYPE_INPUT?-2:12)), (pos[0]+(portType===PORT_TYPE_INPUT?-2:12)),
@ -3734,6 +3740,10 @@ RED.view = (function() {
if (d.hasOwnProperty('l')?!d.l : (d.type === "link in" || d.type === "link out")) { if (d.hasOwnProperty('l')?!d.l : (d.type === "link in" || d.type === "link out")) {
var parentNode = this.parentNode; var parentNode = this.parentNode;
portLabelHoverTimeout = setTimeout(function() { portLabelHoverTimeout = setTimeout(function() {
//check see if node has been deleted since timeout started
if(!parentNode || !parentNode.parentNode || !RED.nodes.node(parentNode.id)) {
return; //node is gone!
}
var tooltip; var tooltip;
if (d._def.label) { if (d._def.label) {
tooltip = d._def.label; tooltip = d._def.label;