Skip to content

Commit

Permalink
fix null reference exception in entries list for multi point manipula…
Browse files Browse the repository at this point in the history
…tion when input is invalid
  • Loading branch information
FalcoGer committed Sep 22, 2023
1 parent c13cb19 commit 4f64197
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions CoordinateConverter/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace CoordinateConverter
/// <seealso cref="Form" />
public partial class MainForm : Form
{
private readonly GitHub.Version VERSION = new GitHub.Version(0, 5, 6);
private readonly GitHub.Version VERSION = new GitHub.Version(0, 5, 7);

private readonly Color ERROR_COLOR = Color.Pink;
private readonly Color DCS_ERROR_COLOR = Color.Yellow;
Expand Down Expand Up @@ -881,7 +881,11 @@ private void Tb_Altitude_TextChanged(object sender, EventArgs e)
altitude = 0;
}

List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() { input };
List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() {};
if (input != null)
{
entries.Add(input);
}
entries.AddRange(currentlyEditingIndices.Select(x => dataEntries[x]).Where(x => x != null));
ResetIDs();

Expand Down Expand Up @@ -985,9 +989,12 @@ private void Cb_AltitudeUnit_SelectedIndexChanged(object sender, EventArgs e)

private void Tb_Label_TextChanged(object sender, EventArgs e)
{
List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() { input };
entries.AddRange(currentlyEditingIndices.Select(x => dataEntries[x]));
entries = entries.Where(x => x != null).ToList();
List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() { };
if (input != null)
{
entries.Add(input);
}
entries.AddRange(currentlyEditingIndices.Select(x => dataEntries[x]).Where(x => x != null));

foreach (CoordinateDataEntry entry in entries)
{
Expand Down Expand Up @@ -1764,7 +1771,11 @@ private void Cb_AltitudeIsAGL_CheckedChanged(object objSender, EventArgs e)
{
CheckBox sender = objSender as CheckBox;

List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() { input };
List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() { };
if (input != null)
{
entries.Add(input);
}
entries.AddRange(currentlyEditingIndices.Select(x => dataEntries[x]).Where(x => x != null));

foreach (CoordinateDataEntry entry in entries)
Expand Down Expand Up @@ -2140,7 +2151,11 @@ private void Cb_pointType_SelectedIndexChanged(object objSender, EventArgs e)
return;
}

List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() { input };
List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() {};
if (input != null)
{
entries.Add(input);
}
entries.AddRange(currentlyEditingIndices.Select(x => dataEntries[x]).Where(x => x != null));

if (selectedAircraft.GetType() == typeof(AH64))
Expand Down Expand Up @@ -2239,7 +2254,11 @@ private void Cb_PointOption_SelectedIndexChanged(object objSender, EventArgs e)
return;
}

List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() { input };
List<CoordinateDataEntry> entries = new List<CoordinateDataEntry>() {};
if (input != null)
{
entries.Add(input);
}
entries.AddRange(currentlyEditingIndices.Select(x => dataEntries[x]).Where(x => x != null));

foreach (CoordinateDataEntry entry in entries)
Expand Down

0 comments on commit 4f64197

Please sign in to comment.