Skip to content

Commit 295612e

Browse files
authored
Merge pull request #116 from mpsonntag/fixSetDim
Fix Matlab crash when setting SetDim Labels
2 parents 95a7a88 + ee35f43 commit 295612e

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

+nix/Dynamic.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ function set_method(obj, val)
2525

2626
if (isempty(val))
2727
nix_mx(strcat(obj.alias, '::set_none_', prop), obj.nix_handle, 0);
28-
elseif(strcmp(prop, 'units') && (~iscell(val)))
29-
%-- BUGFIX: Matlab crashes, if units in Tags and MultiTags
30-
%-- are set using anything else than a cell.
28+
elseif((strcmp(prop, 'units') || strcmp(prop, 'labels')) && (~iscell(val)))
29+
%-- BUGFIX: Matlab crashes, if units in Tags and MultiTags
30+
%-- or labels of SetDimension are set using anything else than a cell.
3131
ME = MException('MATLAB:class:SetProhibited', sprintf(...
32-
'Units can be only set by using cells.'));
32+
'This value only supports cells.'));
3333
throwAsCaller(ME);
3434
else
3535
nix_mx(strcat(obj.alias, '::set_', prop), obj.nix_handle, val);

tests/TestDimensions.m

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,24 @@
2323
assert(strcmp(d1.labels{1}, 'foo'));
2424
assert(strcmp(d1.labels{2}, 'bar'));
2525

26-
% fix this in NIX
27-
%d1.labels = {};
28-
%assert(isempty(d1.labels));
26+
d1.labels = {};
27+
assert(isempty(d1.labels));
28+
29+
try
30+
d1.labels = 'mV';
31+
catch ME
32+
assert(strcmp(ME.identifier, 'MATLAB:class:SetProhibited'));
33+
end;
34+
try
35+
d1.labels = ['mV', 'uA'];
36+
catch ME
37+
assert(strcmp(ME.identifier, 'MATLAB:class:SetProhibited'));
38+
end;
39+
try
40+
d1.labels = 1;
41+
catch ME
42+
assert(strcmp(ME.identifier, 'MATLAB:class:SetProhibited'));
43+
end;
2944
end
3045

3146
function [] = test_sample_dimension( varargin )

0 commit comments

Comments
 (0)