mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-09 01:16:25 +00:00
Fix crash when refreshing an unexpanded node. Improve error logging.
This commit is contained in:
parent
3e6240d895
commit
f3304f51a1
9 changed files with 58 additions and 11 deletions
|
@ -3,7 +3,7 @@
|
|||
<Product Id="*"
|
||||
Name="NBTExplorer"
|
||||
Language="1033"
|
||||
Version="2.7.2.0"
|
||||
Version="2.7.3.0"
|
||||
Manufacturer="Justin Aquadro"
|
||||
UpgradeCode="0bfb1026-21f2-4552-ad71-ca90aae10a25">
|
||||
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
|
||||
|
|
|
@ -66,17 +66,48 @@ namespace NBTExplorer
|
|||
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();
|
||||
errorText.AppendLine("NBTExplorer encountered the following exception while trying to run: " + ex.GetType().Name);
|
||||
errorText.AppendLine("Message: " + ex.Message);
|
||||
|
||||
while (ex.InnerException != null) {
|
||||
ex = ex.InnerException;
|
||||
Exception ix = ex;
|
||||
while (ix.InnerException != null) {
|
||||
ix = ix.InnerException;
|
||||
errorText.AppendLine();
|
||||
errorText.AppendLine("Caused by Inner Exception: " + ex.GetType().Name);
|
||||
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);
|
||||
Application.Exit();
|
||||
}
|
||||
|
@ -93,5 +124,18 @@ namespace NBTExplorer
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.7.2.0")]
|
||||
[assembly: AssemblyFileVersion("2.7.2.0")]
|
||||
[assembly: AssemblyVersion("2.7.3.0")]
|
||||
[assembly: AssemblyFileVersion("2.7.3.0")]
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace NBTExplorer.Model
|
|||
Release();
|
||||
RestoreExpandSet(this, expandSet);
|
||||
|
||||
return true;
|
||||
return expandSet != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,6 +231,9 @@ namespace NBTExplorer.Model
|
|||
|
||||
protected void RestoreExpandSet (DataNode node, Dictionary<string, object> expandSet)
|
||||
{
|
||||
if (expandSet == null)
|
||||
return;
|
||||
|
||||
node.Expand();
|
||||
|
||||
foreach (DataNode child in node.Nodes) {
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace NBTExplorer.Model
|
|||
Release();
|
||||
RestoreExpandSet(this, expandSet);
|
||||
|
||||
return true;
|
||||
return expandSet != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace NBTExplorer.Model
|
|||
Release();
|
||||
RestoreExpandSet(this, expandSet);
|
||||
|
||||
return true;
|
||||
return expandSet != null;
|
||||
}
|
||||
|
||||
public override bool CanRenameNode
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace NBTExplorer.Model
|
|||
Release();
|
||||
RestoreExpandSet(this, expandSet);
|
||||
|
||||
return true;
|
||||
return expandSet != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.1.0")]
|
||||
|
|
Loading…
Reference in a new issue