Fix crash when refreshing an unexpanded node. Improve error logging.

This commit is contained in:
Justin Aquadro 2014-03-31 20:53:41 -04:00
parent 3e6240d895
commit f3304f51a1
9 changed files with 58 additions and 11 deletions

View file

@ -3,7 +3,7 @@
<Product Id="*" <Product Id="*"
Name="NBTExplorer" Name="NBTExplorer"
Language="1033" Language="1033"
Version="2.7.2.0" Version="2.7.3.0"
Manufacturer="Justin Aquadro" Manufacturer="Justin Aquadro"
UpgradeCode="0bfb1026-21f2-4552-ad71-ca90aae10a25"> UpgradeCode="0bfb1026-21f2-4552-ad71-ca90aae10a25">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

View file

@ -66,17 +66,48 @@ namespace NBTExplorer
return; return;
} }
if (IsMissingNBTModel(ex)) {
MessageBox.Show("NBTExplorer could not find required assembly \"NBTModel.dll\".\n\nIf you obtained NBTExplorer from a ZIP distribution, make sure you've extracted NBTExplorer and all of its supporting files into another directory before running it.",
"NBTExplorer failed to run", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
return;
}
StringBuilder errorText = new StringBuilder(); StringBuilder errorText = new StringBuilder();
errorText.AppendLine("NBTExplorer encountered the following exception while trying to run: " + ex.GetType().Name); errorText.AppendLine("NBTExplorer encountered the following exception while trying to run: " + ex.GetType().Name);
errorText.AppendLine("Message: " + ex.Message); errorText.AppendLine("Message: " + ex.Message);
while (ex.InnerException != null) { Exception ix = ex;
ex = ex.InnerException; while (ix.InnerException != null) {
ix = ix.InnerException;
errorText.AppendLine(); errorText.AppendLine();
errorText.AppendLine("Caused by Inner Exception: " + ex.GetType().Name); errorText.AppendLine("Caused by Inner Exception: " + ex.GetType().Name);
errorText.AppendLine("Message: " + ex.Message); errorText.AppendLine("Message: " + ex.Message);
} }
try {
using (var writer = new StreamWriter("NBTExplorer.error.log", true)) {
writer.WriteLine("NBTExplorer Error Report");
writer.WriteLine(DateTime.Now);
writer.WriteLine("-------");
writer.WriteLine(errorText);
writer.WriteLine("-------");
ix = ex;
while (ix != null) {
writer.WriteLine(ex.StackTrace);
writer.WriteLine("-------");
ix = ix.InnerException;
}
writer.WriteLine();
}
errorText.AppendLine();
errorText.AppendLine("Additional error detail has been written to NBTExplorer.error.log");
}
catch { }
MessageBox.Show(errorText.ToString(), "NBTExplorer failed to run", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(errorText.ToString(), "NBTExplorer failed to run", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit(); Application.Exit();
} }
@ -93,5 +124,18 @@ namespace NBTExplorer
return false; return false;
} }
private static bool IsMissingNBTModel (Exception ex)
{
if (ex is TypeInitializationException && ex.InnerException != null)
ex = ex.InnerException;
if (ex is FileNotFoundException) {
FileNotFoundException fileEx = ex as FileNotFoundException;
if (fileEx.FileName.Contains("NBTModel"))
return true;
}
return false;
}
} }
} }

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.7.2.0")] [assembly: AssemblyVersion("2.7.3.0")]
[assembly: AssemblyFileVersion("2.7.2.0")] [assembly: AssemblyFileVersion("2.7.3.0")]

View file

@ -91,7 +91,7 @@ namespace NBTExplorer.Model
Release(); Release();
RestoreExpandSet(this, expandSet); RestoreExpandSet(this, expandSet);
return true; return expandSet != null;
} }
} }
} }

View file

@ -231,6 +231,9 @@ namespace NBTExplorer.Model
protected void RestoreExpandSet (DataNode node, Dictionary<string, object> expandSet) protected void RestoreExpandSet (DataNode node, Dictionary<string, object> expandSet)
{ {
if (expandSet == null)
return;
node.Expand(); node.Expand();
foreach (DataNode child in node.Nodes) { foreach (DataNode child in node.Nodes) {

View file

@ -84,7 +84,7 @@ namespace NBTExplorer.Model
Release(); Release();
RestoreExpandSet(this, expandSet); RestoreExpandSet(this, expandSet);
return true; return expandSet != null;
} }
} }
} }

View file

@ -145,7 +145,7 @@ namespace NBTExplorer.Model
Release(); Release();
RestoreExpandSet(this, expandSet); RestoreExpandSet(this, expandSet);
return true; return expandSet != null;
} }
public override bool CanRenameNode public override bool CanRenameNode

View file

@ -106,7 +106,7 @@ namespace NBTExplorer.Model
Release(); Release();
RestoreExpandSet(this, expandSet); RestoreExpandSet(this, expandSet);
return true; return expandSet != null;
} }
} }
} }

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.1.0")]