From ca33049736eb76ff549ea166c62c2b0974c3467f Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Mon, 2 Dec 2024 13:11:51 +0100 Subject: [PATCH] add object clone() --- MobiFlight/MobiFlightModule.cs | 7 ++++++- UI/Panels/Settings/MobiFlightPanel.cs | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/MobiFlight/MobiFlightModule.cs b/MobiFlight/MobiFlightModule.cs index 76330df0..bd082f97 100644 --- a/MobiFlight/MobiFlightModule.cs +++ b/MobiFlight/MobiFlightModule.cs @@ -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) diff --git a/UI/Panels/Settings/MobiFlightPanel.cs b/UI/Panels/Settings/MobiFlightPanel.cs index 2226e8c3..671e03df 100644 --- a/UI/Panels/Settings/MobiFlightPanel.cs +++ b/UI/Panels/Settings/MobiFlightPanel.cs @@ -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(); @@ -1295,6 +1294,8 @@ private MobiFlightModule getVirtualModuleFromTree() return module; } + + /// /// Tell whether a device requires the presence of a MultiplexerDriver ///