Skip to content

Commit a46653d

Browse files
Fix dj.config issue on initial MATLAB boot.
1 parent 6c6500d commit a46653d

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

+dj/+internal/Settings.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,14 @@ function envVarUpdate()
147147
% return STATE prior to change
148148
out = STATE;
149149
if any(strcmpi(operation, {'set', 'load'}))
150-
% merge with existing STATE
151-
STATE = rmfield(STATE, intersect(fieldnames(STATE), fieldnames(new)));
152-
names = [fieldnames(STATE); fieldnames(new)];
153-
STATE = orderfields(cell2struct([struct2cell(STATE); struct2cell(new)], names, 1));
150+
if isempty(STATE)
151+
STATE = new;
152+
else
153+
% merge with existing STATE
154+
STATE = rmfield(STATE, intersect(fieldnames(STATE), fieldnames(new)));
155+
names = [fieldnames(STATE); fieldnames(new)];
156+
STATE = orderfields(cell2struct([struct2cell(STATE); struct2cell(new)], names, 1));
157+
end
154158
if strcmpi(operation, 'load')
155159
envVarUpdate();
156160
end

docs-parts/intro/Releases_lang1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
--------------------------
33
* Bugfix: Error on accessing unmanaged Imported/Computed tables (#336) PR #338
44
* Bugfix: Certain characters in attribute comment not escaped properly (#210, #335) PR #338
5+
* Bugfix: `dj.config.load(...)` after initial MATLAB boot throws invalid input error. PR #338
56

67
3.4.0 -- December 11, 2020
78
--------------------------

tests/TestConfig.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ function TestConfig_testLoad(testCase)
197197
base = regexprep(base,'[a-z0-9][A-Z]','${$0(1)}_${lower($0(2))}');
198198
TestConfig.TestConfig_configSingleFileTest(testCase, 'load-custom', ...
199199
[pkg_path '/test_schemas/config_lite.json'], jsondecode(base));
200+
% test load on launch MATLAB
201+
clear functions;
202+
dj.config.load([pkg_path '/test_schemas/config_lite.json']);
200203
% cleanup
201204
dj.config.restore;
202205
end

0 commit comments

Comments
 (0)