From d85364444790b2bd4d4d48e454473f1bf97a2fc9 Mon Sep 17 00:00:00 2001 From: Eric Wait <eric@waitphoto.com> Date: Tue, 28 May 2019 11:12:09 -0400 Subject: [PATCH] Better error handling on user data stored in the figure --- src/matlab/+D3d/+UI/+Ctrl/SetUserData.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/matlab/+D3d/+UI/+Ctrl/SetUserData.m b/src/matlab/+D3d/+UI/+Ctrl/SetUserData.m index 4effcdf..0893477 100644 --- a/src/matlab/+D3d/+UI/+Ctrl/SetUserData.m +++ b/src/matlab/+D3d/+UI/+Ctrl/SetUserData.m @@ -1,14 +1,14 @@ function SetUserData(imageData,colors,channelData) -global D3dUICtrlHandles + global D3dUICtrlHandles -if (~isempty(D3dUICtrlHandles)) - data = struct('imageData',imageData,'colors',colors,'channelData',channelData); - for c=1:length(channelData) - channelData(c).color = colors(c,:); + if (~isempty(D3dUICtrlHandles)) + data = struct('imageData',imageData,'colors',colors,'channelData',channelData); + for c=1:length(channelData) + channelData(c).color = colors(c,:); + end + set(D3dUICtrlHandles.hObject,'UserData',data); + else + error('There is no UserData stored in the control window!'); end - set(D3dUICtrlHandles.hObject,'UserData',data); -else - error('There is no UserData stored in the control window!'); -end end -- GitLab