From e2f5cadbec24e3a9ea2ebc7ea5c90f83f96bd2c6 Mon Sep 17 00:00:00 2001 From: Mauco03 <marco.gaibotti@skywarder.eu> Date: Tue, 25 Feb 2025 21:24:02 +0100 Subject: [PATCH] [handle-value-conversion][classes] Fixed a bug where set method would be called multiple times --- classes/Config.m | 14 ++++++++++---- classes/Environment.m | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/classes/Config.m b/classes/Config.m index 5c7b954..433876d 100644 --- a/classes/Config.m +++ b/classes/Config.m @@ -166,10 +166,16 @@ classdef(Abstract) Config end configObj = varsIn.(varName); - fields = configObj.getProperties('writable'); - for field = fields - if isempty([configObj.(field)]), continue; end - obj.(field) = configObj.(field); + if isa(configObj, 'struct') + % If object is not initzialized yet, copy single fields + fields = configObj.getProperties('writable'); + for field = fields + if isempty([configObj.(field)]), continue; end + obj.(field) = configObj.(field); + end + else + % If object is already initialized, copy the object + obj = configObj; end end end diff --git a/classes/Environment.m b/classes/Environment.m index db82db8..23cc07b 100644 --- a/classes/Environment.m +++ b/classes/Environment.m @@ -14,8 +14,9 @@ classdef Environment < Config %% Cached properties properties(Access = private) - PHI OMEGA + PHI + LAT0 LON0 Z0 @@ -29,8 +30,8 @@ classdef Environment < Config end properties (Dependent) - phi double % [rad] Launchpad Azimuth, user input in degrees omega double % [rad] Launchpad Elevation, user input in degrees + phi double % [rad] Launchpad Azimuth, user input in degrees lat0 double % [deg] Launchpad latitude lon0 double % [deg] Launchpad longitude -- GitLab