- [Graph Panel] Fix crash when deleting multiple noeds.

This commit is contained in:
Tanasart 2024-06-17 12:07:47 +07:00
parent e67d134d2a
commit 94330dd272
4 changed files with 43 additions and 4 deletions

View file

@ -576,7 +576,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
instanceBase = noone;
} #endregion
static onDoubleClick = function(panel) { #region
function onDoubleClick(panel) { #region
if(PREFERENCES.panel_graph_group_require_shift && !key_mod_press(SHIFT)) return false;
__temp_panel = panel;

View file

@ -2251,7 +2251,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
array_remove(group == noone? PROJECT.nodes : group.getNodeList(), self);
if(PANEL_GRAPH.node_hover == self) PANEL_GRAPH.node_hover = noone;
PANEL_GRAPH.nodes_selecting = [];
array_remove(PANEL_GRAPH.nodes_selecting, self);
if(PANEL_INSPECTOR.inspecting == self) PANEL_INSPECTOR.inspecting = noone;

View file

@ -162,39 +162,53 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
case "Range" :
if(!is_array(_val) || array_length(_val) != 2)
inParent.animator = new valueAnimator([0, 0], inParent);
inParent.def_val = [0, 0];
inParent.setDisplay(VALUE_DISPLAY.range);
break;
case "Slider" :
if(is_array(_val)) inParent.animator = new valueAnimator(0, inParent);
inParent.def_val = 0;
inParent.setDisplay(VALUE_DISPLAY.slider, { range: [_range[0], _range[1], _step] });
break;
case "Slider range" :
if(!is_array(_val) || array_length(_val) != 2)
inParent.animator = new valueAnimator([0, 0], inParent);
inParent.def_val = [0, 0];
inParent.setDisplay(VALUE_DISPLAY.slider_range, { range: [_range[0], _range[1], _step] });
break;
case "Rotation" :
if(is_array(_val)) inParent.animator = new valueAnimator(0, inParent);
inParent.def_val = 0;
inParent.setDisplay(VALUE_DISPLAY.rotation);
break;
case "Rotation range" :
if(!is_array(_val) || array_length(_val) != 2)
inParent.animator = new valueAnimator([0, 0], inParent);
inParent.def_val = [0, 0];
inParent.setDisplay(VALUE_DISPLAY.rotation_range);
break;
case "Padding" :
if(!is_array(_val) || array_length(_val) != 4)
inParent.animator = new valueAnimator([0, 0, 0, 0], inParent);
inParent.def_val = [0, 0, 0, 0];
inParent.setDisplay(VALUE_DISPLAY.padding);
break;
case "Area" :
if(!is_array(_val) || array_length(_val) != 5)
inParent.animator = new valueAnimator(DEF_AREA, inParent);
inParent.def_val = array_clone(DEF_AREA);
inParent.setDisplay(VALUE_DISPLAY.area);
break;
@ -204,14 +218,20 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
case 0 :
if(!is_array(_val) || array_length(_val) != 2)
inParent.animator = new valueAnimator([0, 0], inParent);
inParent.def_val = [0, 0];
break;
case 1 :
if(!is_array(_val) || array_length(_val) != 3)
inParent.animator = new valueAnimator([0, 0, 0], inParent);
inParent.def_val = [0, 0, 0];
break;
case 2 :
if(!is_array(_val) || array_length(_val) != 4)
inParent.animator = new valueAnimator([0, 0, 0, 0], inParent);
inParent.def_val = [0, 0, 0, 0];
break;
}
if(_dtype == "Vector") inParent.setDisplay(VALUE_DISPLAY.vector);
@ -220,17 +240,23 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
case "Enum button" :
if(is_array(_val)) inParent.animator = new valueAnimator(0, inParent);
inParent.def_val = 0;
inParent.setDisplay(VALUE_DISPLAY.enum_button, string_splice(_enum_label, ","));
break;
case "Menu scroll" :
if(is_array(_val)) inParent.animator = new valueAnimator(0, inParent);
inParent.def_val = 0;
inParent.setDisplay(VALUE_DISPLAY.enum_scroll, string_splice(_enum_label, ","));
break;
case "Palette" :
if(!is_array(_val))
inParent.animator = new valueAnimator([c_black], inParent);
inParent.def_val = [c_black];
inParent.setDisplay(VALUE_DISPLAY.palette);
break;
@ -239,16 +265,22 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
outputs[| 0].setType(inParent.type);
inParent.animator = new valueAnimator(new gradientObject(c_white), inParent);
inParent.def_val = new gradientObject(c_white);
inParent.setDisplay(VALUE_DISPLAY._default);
break;
case "Curve":
inParent.animator = new valueAnimator(CURVE_DEF_11, inParent);
inParent.def_val = array_clone(CURVE_DEF_11);
inParent.setDisplay(VALUE_DISPLAY.curve);
break;
default:
if(is_array(_val)) inParent.animator = new valueAnimator(0, inParent);
inParent.def_val = 0;
inParent.setDisplay(VALUE_DISPLAY._default);
break;
}

View file

@ -1055,8 +1055,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(node_hovering != noone)
_HOVERING_ELEMENT = node_hovering;
if(node_hovering != noone && _focus && DOUBLE_CLICK && node_hovering.onDoubleClick != -1) {
if(DOUBLE_CLICK) {
// print($"Double click {node_hovering} || {_focus} || {instanceof(node_hovering)}");
if(node_hovering != noone && _focus && node_hovering.onDoubleClick != -1)
if(node_hovering.onDoubleClick(self)) {
DOUBLE_CLICK = false;
node_hovering = noone;
@ -2405,7 +2407,12 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
function doDelete(_merge = false) { #region
__temp_merge = _merge;
array_foreach(nodes_selecting, function(node) { if(node.manual_deletable) node.destroy(__temp_merge); });
for(i = array_length(nodes_selecting) - 1; i >= 0; i--) {
var _node = array_safe_get_fast(nodes_selecting, i, 0);
if(_node && _node.manual_deletable)
_node.destroy(__temp_merge);
}
nodes_selecting = [];
} #endregion