* commandline:

* DiscImageChef.Settings/Settings.cs:
	  Corrected a share violation when the preferences file exists
	  but it's not ours.
This commit is contained in:
2017-05-14 22:09:21 +01:00
parent 5be233268b
commit 5f0bea2e48
2 changed files with 22 additions and 3 deletions

View File

@@ -1,3 +1,8 @@
2017-05-14 Natalia Portillo <claunia@claunia.com>
* Settings.cs: Corrected a share violation when the
preferences file exists but it's not ours.
2016-09-05 Natalia Portillo <claunia@claunia.com> 2016-09-05 Natalia Portillo <claunia@claunia.com>
* Settings.cs: Added filters. * Settings.cs: Added filters.

View File

@@ -167,6 +167,9 @@ namespace DiscImageChef.Settings
reportsPath = null; reportsPath = null;
} }
FileStream prefsFs = null;
StreamReader prefsSr = null;
try try
{ {
switch(ptID) switch(ptID)
@@ -183,7 +186,9 @@ namespace DiscImageChef.Settings
SaveSettings(); SaveSettings();
} }
NSDictionary parsedPreferences = (NSDictionary)BinaryPropertyListParser.Parse(new FileInfo(preferencesFilePath)); prefsFs = new FileStream(preferencesFilePath, FileMode.Open, FileAccess.Read);
NSDictionary parsedPreferences = (NSDictionary)BinaryPropertyListParser.Parse(prefsFs);
if(parsedPreferences != null) if(parsedPreferences != null)
{ {
NSObject obj; NSObject obj;
@@ -288,13 +293,18 @@ namespace DiscImageChef.Settings
} }
else else
Current.Stats.VerifyStats = false; Current.Stats.VerifyStats = false;
} }
} }
else else
Current.Stats = null; Current.Stats = null;
prefsFs.Close();
} }
else else
{ {
prefsFs.Close();
SetDefaultSettings(); SetDefaultSettings();
SaveSettings(); SaveSettings();
} }
@@ -357,14 +367,18 @@ namespace DiscImageChef.Settings
} }
XmlSerializer xs = new XmlSerializer(Current.GetType()); XmlSerializer xs = new XmlSerializer(Current.GetType());
StreamReader sr = new StreamReader(settingsPath); prefsSr = new StreamReader(settingsPath);
Current = (DicSettings)xs.Deserialize(sr); Current = (DicSettings)xs.Deserialize(prefsSr);
} }
break; break;
} }
} }
catch catch
{ {
if(prefsFs != null)
prefsFs.Close();
if(prefsSr != null)
prefsSr.Close();
SetDefaultSettings(); SetDefaultSettings();
SaveSettings(); SaveSettings();
} }