End create_meter gracefully on canceling uigetfile
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 17 Dec 2024 08:40:22 +0000 (09:40 +0100)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 17 Dec 2024 08:40:22 +0000 (09:40 +0100)
Also make the script function when a single picture is chosen.

create_meter.m

index a107654120c2b6f0830baab81c22fabb7e79b644..0fc1d303beb15636c475dab78410308ba6c61521 100644 (file)
@@ -6,8 +6,17 @@ FileType = '*.png';
 last_path = get_last_path();
 [filenames, last_path] = uigetfile([last_path '/' FileType], ...
        'Select all files for meter creation', 'MultiSelect', 'on');
+if (isequal(filenames, 0))
+       path(oldpath);
+       return ;
+end
+filenames = cellstr(filenames);
 update_last_path(last_path);
 mask = load_mask();
+if (isequal(mask, 0))
+       path(oldpath);
+       return ;
+end
 files = struct('name', cell(1, numel(filenames)), 'folder', cell(1,...
        numel(filenames)));
 [files.name] = deal(filenames{:});
@@ -26,7 +35,7 @@ for i = 1:numel(marks_pixels)
        end
 end
 [meter_file_name, meter_path] = uiputfile([path '/*.mtr'], 'Save your meter as...');
-if (meter_file_name ~= 0)
+if (~isequal(meter_file_name, 0))
        save_meter([meter_path '/' meter_file_name], meter)
 end
 path(oldpath);