From 72475c063f780ac95740e9c6635af0cf30b38962 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Tue, 17 Dec 2024 09:40:22 +0100 Subject: [PATCH] End create_meter gracefully on canceling uigetfile Also make the script function when a single picture is chosen. --- create_meter.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/create_meter.m b/create_meter.m index a107654..0fc1d30 100644 --- a/create_meter.m +++ b/create_meter.m @@ -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); -- 2.30.2