comparison m-toolbox/m/helper/mc.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children ce4df2e95a55
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % A function to properly clear MATLAB memory for LTPDA.
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: mc.m,v 1.11 2011/02/03 13:42:43 ingo Exp $
6 %
7
8 % Remove this object from memory so we can clear classes
9 % prefs = getappdata(0, 'LTPDApreferences');
10 % prefs.misc.default_window = '';
11
12 % TODO: We need to close all GUIs before doing this - Prefs GUI and Repo Gui
13
14 function mc()
15
16 setappdata(0, 'LTPDApreferences', []);
17
18 % Remove the repository manager
19 rm = getappdata(0, 'LTPDARepositoryManager');
20 if ~isempty(rm)
21 % store the connections so they don't get lost
22 rm.manager.closeAllConnections;
23 conns = rm.manager.getConnections;
24 delete(rm);
25 setappdata(0, 'LTPDAConnections', conns);
26 end
27 setappdata(0, 'LTPDARepositoryManager', []);
28
29 evalin('caller', 'clear'); % Deletes the timer-objects
30 clear classes % Deletes the local variables
31 evalin('caller', 'clear classes'); % Deletes the variables in the caller function
32 evalin('base', 'clear classes'); % Deletes the variables in the 'base' workspace
33
34 % Load the preferences again
35 LTPDAprefs.loadPrefs;
36
37 % Make a new Repository Manager
38 conns = getappdata(0, 'LTPDAConnections');
39 rm = LTPDARepositoryManager;
40 if ~isempty(conns)
41 % and put back the existing connections
42 for kk = 1:conns.size
43 conn = conns.get(kk-1);
44 rm.newConnection(char(conn.getHostname), ...
45 char(conn.getDatabase), ...
46 char(conn.getUsername), ...
47 char(conn.getPassword));
48 end
49 end
50 setappdata(0, 'LTPDAConnections', []);
51
52 end