Ensure _activeProfileIDs initialized before use

This commit is contained in:
John Lewin 2018-11-21 08:34:14 -08:00
parent 4141c10e86
commit 0137413966

View file

@ -213,31 +213,35 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
}
}
private List<string> _activeProfileIDs = null;
private List<string> profileIDsBackingField = null;
[JsonIgnore]
public IEnumerable<string> OpenPrinterIDs
private List<string> _activeProfileIDs
{
get
{
// Lazy load from db if null
if (_activeProfileIDs == null)
if (profileIDsBackingField == null)
{
string profileIDs = UserSettings.Instance.get($"ActiveProfileIDs-{UserName}");
try
{
_activeProfileIDs = JsonConvert.DeserializeObject<List<string>>(profileIDs);
profileIDsBackingField = JsonConvert.DeserializeObject<List<string>>(profileIDs);
}
catch
{
_activeProfileIDs = new List<string>();
profileIDsBackingField = new List<string>();
}
}
return _activeProfileIDs;
return profileIDsBackingField;
}
}
[JsonIgnore]
public IEnumerable<string> OpenPrinterIDs => _activeProfileIDs;
public void AddOpenPrinter(string printerID)
{
try