Guard against null reference
This commit is contained in:
parent
0544ba38b8
commit
3cfd40b6a0
1 changed files with 14 additions and 2 deletions
|
|
@ -181,7 +181,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
internal static void SettingsChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Instance.ActiveProfile == null)
|
||||
if (Instance?.ActiveProfile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -207,7 +207,19 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public IEnumerable<PrinterInfo> ActiveProfiles => Profiles.Where(profile => !profile.MarkedForDelete).ToList();
|
||||
|
||||
[JsonIgnore]
|
||||
public PrinterInfo ActiveProfile => this[ActiveSliceSettings.Instance.ID];
|
||||
public PrinterInfo ActiveProfile
|
||||
{
|
||||
get
|
||||
{
|
||||
var activeID = ActiveSliceSettings.Instance?.ID;
|
||||
if (activeID == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this[activeID];
|
||||
}
|
||||
}
|
||||
|
||||
public PrinterInfo this[string profileID]
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue