From f51a44235795ed25caf94a705d8da3aa84d053c0 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 3 Jun 2024 10:54:22 +0200 Subject: [PATCH] Fix crash when using content search in Visject surface --- Source/Editor/Surface/Archetypes/Function.cs | 26 +++++++++++--------- Source/Editor/Surface/Elements/FloatValue.cs | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Source/Editor/Surface/Archetypes/Function.cs b/Source/Editor/Surface/Archetypes/Function.cs index 4a66d2675..11dd12765 100644 --- a/Source/Editor/Surface/Archetypes/Function.cs +++ b/Source/Editor/Surface/Archetypes/Function.cs @@ -2198,21 +2198,23 @@ namespace FlaxEditor.Surface.Archetypes _combobox.ClearItems(); _tooltips.Clear(); _functionNodesIds.Clear(); - var nodes = Surface.Nodes; - var count = _signature != null ? nodes.Count : 0; - for (int i = 0; i < count; i++) + if (Surface != null && _signature != null) { - if (nodes[i] is VisualScriptFunctionNode functionNode) + var nodes = Surface.Nodes; + for (int i = 0; i < nodes.Count; i++) { - // Get if function signature matches the event signature - functionNode.GetSignature(out var functionSig); - if (IsValidFunctionSignature(ref functionSig)) + if (nodes[i] is VisualScriptFunctionNode functionNode) { - if (functionNode.ID == handlerFunctionNodeId) - toSelect = _functionNodesIds.Count; - _functionNodesIds.Add(functionNode.ID); - _tooltips.Add(functionNode.TooltipText); - _combobox.AddItem(functionSig.ToString()); + // Get if function signature matches the event signature + functionNode.GetSignature(out var functionSig); + if (IsValidFunctionSignature(ref functionSig)) + { + if (functionNode.ID == handlerFunctionNodeId) + toSelect = _functionNodesIds.Count; + _functionNodesIds.Add(functionNode.ID); + _tooltips.Add(functionNode.TooltipText); + _combobox.AddItem(functionSig.ToString()); + } } } } diff --git a/Source/Editor/Surface/Elements/FloatValue.cs b/Source/Editor/Surface/Elements/FloatValue.cs index c5b73d297..71ee26df9 100644 --- a/Source/Editor/Surface/Elements/FloatValue.cs +++ b/Source/Editor/Surface/Elements/FloatValue.cs @@ -35,7 +35,7 @@ namespace FlaxEditor.Surface.Elements ParentNode.ValuesChanged += OnNodeValuesChanged; // Disable slider if surface doesn't allow it - if (!ParentNode.Surface.CanLivePreviewValueChanges) + if (ParentNode.Surface != null && !ParentNode.Surface.CanLivePreviewValueChanges) _slideSpeed = 0.0f; }