diff +mpm/PersistentState.m @ 38:16d56bf04117

Change place of storage of the state
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 05 Dec 2018 15:43:13 +0100
parents 29da718b8e7f
children
line wrap: on
line diff
--- a/+mpm/PersistentState.m	Fri Nov 02 14:43:27 2018 +0100
+++ b/+mpm/PersistentState.m	Wed Dec 05 15:43:13 2018 +0100
@@ -1,17 +1,16 @@
 classdef PersistentState < handle
     properties
-        filepath
+        prefGroup
         subpaths
     end
 
     methods
-        function obj = PersistentState(filepath)
-            obj.filepath = filepath;
+        function obj = PersistentState(prefGroup)
+            obj.prefGroup = prefGroup;
 
             try
                 % Read state from file
-                s = load(filepath);
-                obj.subpaths = s.subpaths;
+                obj.subpaths = getpref(prefGroup, 'state');
             catch
                 % If reading the file failed, create an empty state
                 obj.subpaths = containers.Map();
@@ -19,10 +18,7 @@
         end
 
         function s = saveState(obj)
-            s = struct();
-            s.subpaths = obj.subpaths;
-
-            save(obj.filepath, '-struct', 's');
+            setpref(obj.prefGroup, 'state', obj.subpaths);
         end
     end
 end