Browse Source

Additional null checks around Flowchart.selectedBlocks and Flowchart.selectedCommands

-Nulls are getting into these collections in error. Seems to be due to SelectedBlocks serialising and not being refreshed correctly when something is deleted or removed outside of FlowchartWindow's control or a lingering null from a previous version.

Updated Changelog
master
desktop-maesty/steve 6 years ago
parent
commit
0d4b5bae00
  1. 7
      Assets/Fungus/Docs/CHANGELOG.txt
  2. 15
      Assets/Fungus/Scripts/Components/Flowchart.cs

7
Assets/Fungus/Docs/CHANGELOG.txt

@ -2,6 +2,13 @@ Changelog {#changelog}
========= =========
[TOC] [TOC]
v3.11.3 {#v3.11.3}
======
## Fixed
- Additional null checks around Flowchart.selectedBlocks and Flowchart.selectedCommands.
v3.11.2 {#v3.11.2} v3.11.2 {#v3.11.2}
====== ======

15
Assets/Fungus/Scripts/Components/Flowchart.cs

@ -230,6 +230,9 @@ namespace Fungus
// It shouldn't happen but it seemed to occur for a user on the forum // It shouldn't happen but it seemed to occur for a user on the forum
variables.RemoveAll(item => item == null); variables.RemoveAll(item => item == null);
selectedBlocks.RemoveAll(item => item == null);
selectedCommands.RemoveAll(item => item == null);
var allVariables = GetComponents<Variable>(); var allVariables = GetComponents<Variable>();
for (int i = 0; i < allVariables.Length; i++) for (int i = 0; i < allVariables.Length; i++)
{ {
@ -1129,10 +1132,20 @@ namespace Fungus
/// </summary> /// </summary>
public virtual void ClearSelectedBlocks() public virtual void ClearSelectedBlocks()
{ {
foreach (var item in selectedBlocks) if(selectedBlocks == null)
{
selectedBlocks = new List<Block>();
}
for (int i = 0; i < selectedBlocks.Count; i++)
{
var item = selectedBlocks[i];
if(item != null)
{ {
item.IsSelected = false; item.IsSelected = false;
} }
}
selectedBlocks.Clear(); selectedBlocks.Clear();
} }

Loading…
Cancel
Save