Newer
Older
% -------------------------------
config_file = [prefdir, filesep, tsgqcname, '.mat'];
% save preference mat file
% ------------------------
if exist('tsg', 'var') && isfield( tsg, 'preference')
preference = tsg.preference;
save( config_file, 'preference');
end
% If the data have been modified and not save, the program
% ask to save the data
% --------------------------------------------------------
if strcmp( get( hSaveMenu, 'UserData' ), 'on')
selection = ...
questdlg('The file has been modified. Do you want to save it ?',...
'Save before Quit?',...
'Yes', 'No', 'Yes');
if strcmp(selection, 'Yes')
% call File/Save Menu Callback before before quit
% -----------------------------------------------
SaveMenuCallback;
% quit program
% ------------
quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
selection = ...
questdlg(['Quit ' get(hMainFig, 'Name') '?'],...
['Quit ' get(hMainFig, 'Name') '?'],...
'Yes', 'No', 'Yes');
if strcmp(selection, 'No')
return;
else
quitProgram(DEFAULT_PATH_FILE, hMainFig, hMapFig);
end
% catch error during close windows
% --------------------------------
catch
% display message to console and quit program
% -------------------------------------------
fprintf('abnormal program termination during close user request\n');
quitProgram(DEFAULT_PATH_FILE, hMainFig);

jacques.grelet_ird.fr
committed
end % end of QuitMenuCallback
function quitProgram(DEFAULT_PATH_FILE, varargin)
% close all windows
% -----------------
for ii=1:size(varargin,2)
delete(varargin{ii});
end
% reset userdata property of root Matalab object (0) for next use
% ---------------------------------------------------------------
set(0, 'userdata', []);
% reset Matlab search path to default
% addpath isn't mandatory and failed with compiled applications
% --------------------------------------------------------------
if (~isdeployed)
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_util'] );
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_data'] );
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_io'] );
rmpath( [DEFAULT_PATH_FILE filesep 'tsg_map'] );
end
% Refresh file system caches
% --------------------------
rehash;
% clear base workspace just before quit, this is the only method
% to clear NetCDF variables assign to base workspace with assignin
% ----------------------------------------------------------------
evalin('base','clear all');
end % end of quitProgram
end % end of tsgqc