Skip to content

Commit

Permalink
add object clone()
Browse files Browse the repository at this point in the history
  • Loading branch information
elral committed Dec 2, 2024
1 parent 45704f4 commit ca33049
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion MobiFlight/MobiFlightModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,12 @@ public MobiFlightModule(MobiFlightModuleInfo moduleInfo)
Board = moduleInfo.Board;
HardwareId = moduleInfo.HardwareId;
}

public object Clone()
{
var clone = new MobiFlightModule(this.ToMobiFlightModuleInfo());
clone.CoreVersion = this.CoreVersion;
return clone;
}
public void Connect()
{
if (this.Connected)
Expand Down
5 changes: 3 additions & 2 deletions UI/Panels/Settings/MobiFlightPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,7 @@ private MobiFlightModule getVirtualModuleFromTree()
TreeNode moduleNode = getModuleNode();
if (moduleNode == null) return null;

var module = new MobiFlightModule((moduleNode.Tag as MobiFlightModule).ToMobiFlightModuleInfo());
module.CoreVersion = (moduleNode.Tag as MobiFlightModule).CoreVersion;
var module = (moduleNode.Tag as MobiFlightModule).Clone() as MobiFlightModule;

// Generate config
MobiFlight.Config.Config newConfig = new MobiFlight.Config.Config();
Expand All @@ -1295,6 +1294,8 @@ private MobiFlightModule getVirtualModuleFromTree()
return module;
}



/// <summary>
/// Tell whether a device requires the presence of a MultiplexerDriver
/// </summary>
Expand Down

0 comments on commit ca33049

Please sign in to comment.