Skip to content

Commit

Permalink
Exception when loading config from an Uno
Browse files Browse the repository at this point in the history
Fixes #1275
  • Loading branch information
neilenns committed Aug 19, 2023
1 parent 1f6d055 commit 7813c7b
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions MobiFlight/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public List<String> ToInternal(int MaxMessageLength)
// Its data is embedded (redundantly) in mux client devices

String current = item.ToInternal();

if ((message.Length + current.Length) > MaxMessageLength && message.Length > 0) {

if ((message.Length + current.Length) > MaxMessageLength && message.Length > 0)
{
result.Add(message);
message = "";
}
Expand Down Expand Up @@ -150,13 +151,14 @@ public Config FromInternal(String value, bool throwException = false)
case DeviceType.InputMultiplexer:
// If the multiplexerDriver is to be implicitly defined by clients:
// Build multiplexerDriver if none found yet
if (multiplexerDriver == null) {
if (multiplexerDriver == null)
{
// Store it, so another clients will not create a new one
multiplexerDriver = new MobiFlight.Config.MultiplexerDriver();
// The MultiplexerDriver is registered as a "ghost" device in Config's items list; it won't be shown in the GUI tree.
Items.Add(multiplexerDriver);
//} else {
// multiplexerDriver.registerClient();
//} else {
// multiplexerDriver.registerClient();
}
multiplexerDriver.FromInternal(InputMultiplexer.GetMultiplexerDriverConfig(item + BaseDevice.End));

Expand All @@ -174,16 +176,16 @@ public Config FromInternal(String value, bool throwException = false)
currentItem.FromInternal(item + BaseDevice.End);
break;

// If the multiplexerDriver is to be explicitly defined by its own config line,
// following 'case' is required:
// If the multiplexerDriver is to be explicitly defined by its own config line,
// following 'case' is required:

//case DeviceType.MultiplexerDriver:
//case DeviceType.MultiplexerDriver:
//if (multiplexerDriver == null) {
// multiplexerDriver = new MobiFlight.Config.MultiplexerDriver();
// currentItem = multiplexerDriver;
// currentItem.FromInternal(item + BaseDevice.End);
//} else {
// multiplexerDriver.registerClient();
//} else {
// multiplexerDriver.registerClient();
//}
//break;
}
Expand All @@ -207,6 +209,13 @@ public Config FromInternal(String value, bool throwException = false)
else
return this;
}
catch (Exception ex)
{
if (throwException)
throw new Exception("Config not valid.", ex);
else
return this;
}

}
return this;
Expand Down

0 comments on commit 7813c7b

Please sign in to comment.