mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-10 01:46:24 +00:00
Tighter protection around unpredictable ApplicationSettings properties
This commit is contained in:
parent
1596d3365d
commit
24c349ce50
1 changed files with 25 additions and 2 deletions
|
@ -172,7 +172,7 @@ namespace NBTExplorer.Windows
|
||||||
DirectoryDataNode node = new DirectoryDataNode(path);
|
DirectoryDataNode node = new DirectoryDataNode(path);
|
||||||
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
|
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
|
||||||
|
|
||||||
AddPathToHistory(Settings.Default.RecentDirectories, path);
|
AddPathToHistory(GetRecentDirectories(), path);
|
||||||
}
|
}
|
||||||
else if (File.Exists(path)) {
|
else if (File.Exists(path)) {
|
||||||
DataNode node = null;
|
DataNode node = null;
|
||||||
|
@ -183,7 +183,7 @@ namespace NBTExplorer.Windows
|
||||||
|
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
|
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
|
||||||
AddPathToHistory(Settings.Default.RecentFiles, path);
|
AddPathToHistory(GetRecentFiles(), path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,6 +229,26 @@ namespace NBTExplorer.Windows
|
||||||
UpdateUI();
|
UpdateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StringCollection GetRecentFiles ()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return Settings.Default.RecentFiles;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringCollection GetRecentDirectories ()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return Settings.Default.RecentDirectories;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private TreeNode CreateUnexpandedNode (DataNode node)
|
private TreeNode CreateUnexpandedNode (DataNode node)
|
||||||
{
|
{
|
||||||
TreeNode frontNode = new TreeNode(node.NodeDisplay);
|
TreeNode frontNode = new TreeNode(node.NodeDisplay);
|
||||||
|
@ -1125,6 +1145,9 @@ namespace NBTExplorer.Windows
|
||||||
|
|
||||||
private void AddPathToHistory (StringCollection list, string entry)
|
private void AddPathToHistory (StringCollection list, string entry)
|
||||||
{
|
{
|
||||||
|
if (list == null)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (string item in list) {
|
foreach (string item in list) {
|
||||||
if (item == entry) {
|
if (item == entry) {
|
||||||
list.Remove(item);
|
list.Remove(item);
|
||||||
|
|
Loading…
Reference in a new issue